RIT VEXU Core API
Loading...
Searching...
No Matches
Point2d Class Reference

Class representing a lattice point. More...

#include <point2d.h>

Public Member Functions

constexpr Point2d ()
 Default constructor for Point2d creating a lattice point at the origin.
constexpr Point2d (int x, int y)
constexpr Point2d (Eigen::Vector2i vector)
constexpr int x () const
 Gets the X coordinate of the point.
constexpr void set_x (int val)
 Sets the x coordinate.
constexpr int y () const
 Gets the Y coordinate of the point.
constexpr void set_y (int val)
 Sets the y coordinate.
constexpr Eigen::Vector2i as_vector () const
 Gets the point as an Eigen::Vector2i.
constexpr Eigen::Vector2d as_vector (Eigen::Vector2d X, Eigen::Vector2d Y) const
constexpr int manhattan_distance (Point2d other) const
 Calculates the manhattan distance between two points.
constexpr int manhattan_norm () const
 Calculates the manhattan distance away from the origin.
constexpr double distance (Point2d other) const
 Calculates the distance (as a continuous number) between two points.
constexpr double norm () const
 Calculates the distance (as a continuous number) away from the origin.
constexpr Point2d inverse () const
constexpr int dot (Point2d other) const
constexpr Point2d operator+ (Point2d other) const
constexpr Point2d & operator+= (Point2d other)
 Adds another point to this point.
constexpr Point2d operator- (Point2d other) const
constexpr Point2d & operator-= (Point2d other)
 Subtracts another point from this point.
constexpr Point2d operator- () const
constexpr Point2d operator* (int scalar) const
constexpr int operator* (Point2d other) const
constexpr Point2d & operator*= (int scalar)
 Multiplies this point by a scalar.
constexpr bool operator== (Point2d other) const

Friends

constexpr Point2d operator* (int scalar, Point2d point)
 Scales the point.

Detailed Description

Class representing a lattice point.

Constructor & Destructor Documentation

◆ Point2d() [1/2]

Point2d::Point2d ( int x,
int y )
inlineconstexpr

Creates a lattice point at the coordinate (x,y)

Parameters
xThe x-coordinate of the point
yThe y-coordinate of the point

◆ Point2d() [2/2]

Point2d::Point2d ( Eigen::Vector2i vector)
inlineconstexpr

Creates a lattice point with the values from the given vector

Parameters
vectorThe vector whose values will be used

Member Function Documentation

◆ as_vector()

Eigen::Vector2d Point2d::as_vector ( Eigen::Vector2d X,
Eigen::Vector2d Y ) const
inlineconstexpr

Gets a vector in the canonical basis corresponding to the point in the basis of X and Y

Parameters
XThe vector corresponding to <1, 0> in the basis of X and Y
YThe vector corresponding to <0, 1> in the basis of X and Y
Returns
The point as a linear combination of the X and Y vectors

◆ dot()

int Point2d::dot ( Point2d other) const
inlineconstexpr

Returns the dot product of two points

[scalar] = [x][otherx] + [y][othery]

Parameters
otherThe other point to find the dot product with
Returns
The scalar-valued dot product

◆ inverse()

Point2d Point2d::inverse ( ) const
inlineconstexpr

Returns the inverse of the point

[x] = -[x] [y] = -[y]

Returns
The inverse of the point

◆ operator*() [1/2]

Point2d Point2d::operator* ( int scalar) const
inlineconstexpr

Returns this point multiplied by a scalar

[x] = [x] * [scalar] [y] = [y] * [scalar]

Parameters
scalarThe scalar to multiply by
Returns
This point multiplied by a scalar

◆ operator*() [2/2]

int Point2d::operator* ( Point2d other) const
inlineconstexpr

Computes the dot product of two points

[scalar] = [x][otherx] + [y][othery]

Parameters
otherThe other point to find the dot product with
Returns
The scalar-valued dot product

◆ operator+()

Point2d Point2d::operator+ ( Point2d other) const
inlineconstexpr

Returns the sum of two points

[x] = [x] + [otherx] [y] = [y] + [otherx]

Parameters
otherThe other point to be added
Returns
The sum of the two points

◆ operator-() [1/2]

Point2d Point2d::operator- ( ) const
inlineconstexpr

Computes the inverse of the point

[x] = -[x] [y] = -[y]

Returns
The inverse of the point

◆ operator-() [2/2]

Point2d Point2d::operator- ( Point2d other) const
inlineconstexpr

Returns the difference of two points

[x] = [x] - [otherx] [y] = [y] - [otherx]

Parameters
otherThe point being subtracted from this one
Returns
The difference of the two points

◆ operator==()

bool Point2d::operator== ( Point2d other) const
inlineconstexpr

Compares two points

Parameters
otherThe other Point2d to compare to
Returns
TRUE if the components of both points are equal, and FALSE if otherwise

The documentation for this class was generated from the following file: