template<int Precision>
bn::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_point_t to this one.

Parameters
other fixed_point_t to add.
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_point_t to this one.

Parameters
other fixed_point_t to subtract.
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.