#include <bn_fixed_point.h>
template<int Precision>
fixed_point_t class
Defines a two-dimensional point using fixed point precision.
Constructors, destructors, conversion operators
- fixed_point_t() defaulted constexpr
- Default constructor.
-
fixed_point_t(fixed_
t<Precision> x, fixed_ t<Precision> y) constexpr - Constructor.
- fixed_point_t(const point& point) constexpr
- Constructor.
Public functions
-
auto x() const -> fixed_
t<Precision> constexpr - Returns the horizontal coordinate.
-
void set_x(fixed_
t<Precision> x) constexpr - Sets the horizontal coordinate.
-
auto y() const -> fixed_
t<Precision> constexpr - Returns the vertical coordinate.
-
void set_y(fixed_
t<Precision> y) constexpr - Sets the vertical coordinate.
-
auto multiplication(int value) const -> fixed_
point_ t constexpr - Returns the multiplication of this point by the given integer value.
-
auto multiplication(fixed_
t<Precision> value) const -> fixed_ point_ t constexpr - Returns the multiplication of this point by the given fixed point value, using half precision to try to avoid overflow.
-
auto safe_multiplication(int value) const -> fixed_
point_ t constexpr - Returns the multiplication of this point by the given integer value.
-
auto safe_multiplication(fixed_
t<Precision> value) const -> fixed_ point_ t constexpr - Returns the multiplication of this point by the given fixed point value, casting them to int64_t to try to avoid overflow.
-
auto unsafe_multiplication(int value) const -> fixed_
point_ t constexpr - Returns the multiplication of this point by the given integer value.
-
auto unsafe_multiplication(fixed_
t<Precision> value) const -> fixed_ point_ t constexpr - Returns the multiplication of this point by the given fixed point value without trying to avoid overflow.
-
auto division(int value) const -> fixed_
point_ t constexpr - Returns the division of this point by the given integer value.
-
auto division(fixed_
t<Precision> value) const -> fixed_ point_ t constexpr - Returns the division of this point by the given fixed point value, using half precision to try to avoid overflow.
-
auto safe_division(int value) const -> fixed_
point_ t constexpr - Returns the division of this value by the given integer value.
-
auto safe_division(fixed_
t<Precision> value) const -> fixed_ point_ t constexpr - Returns the division of this point by the given fixed point value, casting them to int64_t to try to avoid overflow.
-
auto unsafe_division(int value) const -> fixed_
point_ t constexpr - Returns the division of this value by the given integer value.
-
auto unsafe_division(fixed_
t<Precision> value) const -> fixed_ point_ t constexpr - Returns the division of this point by the given fixed point value without trying to avoid overflow.
-
auto operator-() const -> fixed_
point_ t constexpr - Returns a fixed_
point_ t that is formed by changing the sign of both coordinates. -
auto operator+=(const fixed_
point_ t& other) -> fixed_ point_ t& constexpr - Adds the given fixed_
point_ t to this one. -
auto operator-=(const fixed_
point_ t& other) -> fixed_ point_ t& constexpr - Subtracts the given fixed_
point_ t to this one. -
auto operator*=(int value) -> fixed_
point_ t& constexpr - Multiplies both coordinates by the given factor.
-
auto operator*=(fixed_
t<Precision> value) -> fixed_ point_ t& constexpr - Multiplies both coordinates by the given factor.
-
auto operator/=(int value) -> fixed_
point_ t& constexpr - Divides both coordinates by the given divisor.
-
auto operator/=(fixed_
t<Precision> value) -> fixed_ point_ t& constexpr - Divides both coordinates by the given divisor.
Friends
-
auto operator+(const fixed_
point_ t& a, const fixed_ point_ t& b) -> fixed_ point_ t constexpr - Returns the sum of a and b.
-
auto operator-(const fixed_
point_ t& a, const fixed_ point_ t& b) -> fixed_ point_ t constexpr - Returns b subtracted from a.
-
auto operator*(const fixed_
point_ t& a, int b) -> fixed_ point_ t constexpr - Returns a multiplied by b.
-
auto operator*(const fixed_
point_ t& a, fixed_ t<Precision> b) -> fixed_ point_ t constexpr - Returns a multiplied by b.
-
auto operator/(const fixed_
point_ t& a, int b) -> fixed_ point_ t constexpr - Returns a divided by b.
-
auto operator/(const fixed_
point_ t& a, fixed_ t<Precision> b) -> fixed_ point_ t constexpr - Returns a divided by b.
-
auto operator==(const fixed_
point_ t& a, const fixed_ point_ t& b) -> bool defaulted constexpr - Default equal operator.
Function documentation
template<int Precision>
bn:: fixed_point_t<Precision>:: fixed_point_t(fixed_ t<Precision> x,
fixed_ t<Precision> y) constexpr
Constructor.
Parameters | |
---|---|
x | Horizontal coordinate. |
y | Vertical coordinate. |
template<int Precision>
bn:: fixed_point_t<Precision>:: fixed_point_t(const point& point) constexpr
Constructor.
Parameters | |
---|---|
point | Integer point. |
template<int Precision>
fixed_ point_ t& bn:: fixed_point_t<Precision>:: operator+=(const fixed_ point_ t& other) constexpr
Adds the given fixed_
Parameters | |
---|---|
other | fixed_ |
Returns | Reference to this. |
template<int Precision>
fixed_ point_ t& bn:: fixed_point_t<Precision>:: operator-=(const fixed_ point_ t& other) constexpr
Subtracts the given fixed_
Parameters | |
---|---|
other | fixed_ |
Returns | Reference to this. |
template<int Precision>
fixed_ point_ t& bn:: fixed_point_t<Precision>:: operator*=(int value) constexpr
Multiplies both coordinates by the given factor.
Parameters | |
---|---|
value | Integer multiplication factor. |
Returns | Reference to this. |
template<int Precision>
fixed_ point_ t& bn:: fixed_point_t<Precision>:: operator*=(fixed_ t<Precision> value) constexpr
Multiplies both coordinates by the given factor.
Parameters | |
---|---|
value | Fixed point multiplication factor. |
Returns | Reference to this. |
template<int Precision>
fixed_ point_ t& bn:: fixed_point_t<Precision>:: operator/=(int value) constexpr
Divides both coordinates by the given divisor.
Parameters | |
---|---|
value | Valid integer divisor (!= 0). |
Returns | Reference to this. |
template<int Precision>
fixed_ point_ t& bn:: fixed_point_t<Precision>:: operator/=(fixed_ t<Precision> value) constexpr
Divides both coordinates by the given divisor.
Parameters | |
---|---|
value | Valid fixed point divisor (!= 0). |
Returns | Reference to this. |