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