bn::point class
#include <bn_point.h>

Defines a two-dimensional point using integer precision.

Constructors, destructors, conversion operators

point() defaulted constexpr
Default constructor.
point(int x, int y) constexpr
Constructor.

Public functions

auto x() const -> int constexpr
Returns the horizontal coordinate.
void set_x(int x) constexpr
Sets the horizontal coordinate.
auto y() const -> int constexpr
Returns the vertical coordinate.
void set_y(int y) constexpr
Sets the vertical coordinate.
auto operator-() const -> point constexpr
Returns a point that is formed by changing the sign of both coordinates.
auto operator+=(const point& other) -> point& constexpr
Adds the given point to this one.
auto operator-=(const point& other) -> point& constexpr
Subtracts the given point to this one.
auto operator*=(int value) -> point& constexpr
Multiplies both coordinates by the given factor.
auto operator/=(int value) -> point& constexpr
Divides both coordinates by the given divisor.

Friends

auto operator+(const point& a, const point& b) -> point constexpr
Returns the sum of a and b.
auto operator-(const point& a, const point& b) -> point constexpr
Returns b subtracted from a.
auto operator*(const point& a, int b) -> point constexpr
Returns a multiplied by b.
auto operator/(const point& a, int b) -> point constexpr
Returns a divided by b.
auto operator==(const point& a, const point& b) -> bool defaulted constexpr
Default equal operator.

Function documentation

bn::point::point(int x, int y) constexpr

Constructor.

Parameters
x Horizontal coordinate.
y Vertical coordinate.

point& bn::point::operator+=(const point& other) constexpr

Adds the given point to this one.

Parameters
other point to add.
Returns Reference to this.

point& bn::point::operator-=(const point& other) constexpr

Subtracts the given point to this one.

Parameters
other point to subtract.
Returns Reference to this.

point& bn::point::operator*=(int value) constexpr

Multiplies both coordinates by the given factor.

Parameters
value Integer multiplication factor.
Returns Reference to this.

point& bn::point::operator/=(int value) constexpr

Divides both coordinates by the given divisor.

Parameters
value Valid integer divisor (!= 0).
Returns Reference to this.