scsl  1.1.1
Shimmering Clarity Standard Library
Public Member Functions | Friends | List of all members
scmp::geom::Point2D Class Reference

Point2D is a cartesian (X,Y) pairing. More...

#include <Coord2D.h>

Inheritance diagram for scmp::geom::Point2D:
Inheritance graph
[legend]
Collaboration diagram for scmp::geom::Point2D:
Collaboration graph
[legend]

Public Member Functions

 Point2D ()
 A Point2D defaults to (0,0). More...
 
 Point2D (int _x, int _y)
 Initialize a Point2D At (_x, _y). More...
 
 Point2D (const Polar2D &pol)
 Initialize a Point2D from a Polar2D coordinate. More...
 
int X () const
 Return the X component of the point. More...
 
void X (int _x)
 Set the X component of the point. More...
 
int Y () const
 Return the Y component of the point. More...
 
void Y (int _y)
 Set the Y component of the point. More...
 
std::string ToString ()
 ToString returns a string in the format (x,y). More...
 
void ToPolar (Polar2D &)
 ToPolar converts the Point2D to a polar coordinate in-place. More...
 
void Rotate (Point2D &rotated, double theta)
 Rotate rotates the point by theta radians. More...
 
std::vector< Point2DRotate (std::vector< Polar2D > vertices, double theta)
 Rotate this point around a series of vertices. More...
 
void Translate (const Point2D &other, Point2D &translated)
 Translate adds this point to the first argument, storing the result in the second argument. More...
 
int Distance (const Point2D &other) const
 Distance returns the distance from this point to another. More...
 
- Public Member Functions inherited from scmp::geom::Vector< int, 2 >
 Vector ()
 Construct a unit vector of a given type and size. More...
 
 Vector (std::initializer_list< int > ilst)
 Construct a Vector with initial values. More...
 
int At (size_t index) const
 Return the element At index i. More...
 
void Set (size_t index, int value)
 Set a new value for the vector. More...
 
int Magnitude () const
 Compute the length of the vector. More...
 
void SetEpsilon (int eps)
 Set equivalence tolerance. More...
 
bool IsZero () const
 Determine whether this is a zero vector. More...
 
Vector UnitVector () const
 Obtain the unit vector for this vector. More...
 
bool IsUnitVector () const
 Determine if this is a unit vector. More...
 
int Angle (const Vector< int, N > &other) const
 Compute the Angle between two vectors. More...
 
bool IsParallel (const Vector< int, N > &other) const
 Determine whether two vectors are parallel. More...
 
bool IsOrthogonal (const Vector< int, N > &other) const
 Determine if two vectors are orthogonal or perpendicular to each other. More...
 
Vector ProjectParallel (const Vector< int, N > &basis) const
 Project this vector onto some basis vector. More...
 
Vector ProjectOrthogonal (const Vector< int, N > &basis)
 Project this vector perpendicularly onto some basis vector. More...
 
Vector Cross (const Vector< int, N > &other) const
 Compute the cross product of two vectors. More...
 
Vector operator+ (const Vector< int, N > &other) const
 Vector addition. More...
 
Vector operator- (const Vector< int, N > &other) const
 Vector subtraction. More...
 
Vector operator* (const int k) const
 Scalar multiplication. More...
 
int operator* (const Vector< int, N > &other) const
 Compute the Dot product between two vectors. More...
 
Vector operator/ (const int k) const
 Scalar division. More...
 
bool operator== (const Vector< int, N > &other) const
 Vector equivalence. More...
 
bool operator!= (const Vector< int, N > &other) const
 Vector non-equivalence. More...
 
const int & operator[] (size_t i) const
 Array indexing into vector. More...
 

Friends

std::ostream & operator<< (std::ostream &outs, const Point2D &pt)
 

Detailed Description

Point2D is a cartesian (X,Y) pairing.

Constructor & Destructor Documentation

◆ Point2D() [1/3]

scmp::geom::Point2D::Point2D ( )

A Point2D defaults to (0,0).

◆ Point2D() [2/3]

scmp::geom::Point2D::Point2D ( int  _x,
int  _y 
)

Initialize a Point2D At (_x, _y).

◆ Point2D() [3/3]

scmp::geom::Point2D::Point2D ( const Polar2D pol)

Initialize a Point2D from a Polar2D coordinate.

Member Function Documentation

◆ Distance()

int scmp::geom::Point2D::Distance ( const Point2D other) const

Distance returns the distance from this point to another.

◆ Rotate() [1/2]

void scmp::geom::Point2D::Rotate ( Point2D rotated,
double  theta 
)

Rotate rotates the point by theta radians.

Parameters
rotatedStores the rotated point.
thetaThe Angle (in radians) to Rotate the point.

◆ Rotate() [2/2]

std::vector<Point2D> scmp::geom::Point2D::Rotate ( std::vector< Polar2D vertices,
double  theta 
)

Rotate this point around a series of vertices.

Parameters
verticesA series of vertices to Rotate this point around.
thetaThe Angle to Rotate by.
Returns
A series of rotated points.

◆ ToPolar()

void scmp::geom::Point2D::ToPolar ( Polar2D )

ToPolar converts the Point2D to a polar coordinate in-place.

◆ ToString()

std::string scmp::geom::Point2D::ToString ( )

ToString returns a string in the format (x,y).

◆ Translate()

void scmp::geom::Point2D::Translate ( const Point2D other,
Point2D translated 
)

Translate adds this point to the first argument, storing the result in the second argument.

Parameters
otherThe point to translate by.
translatedThe point to store the translation in.

◆ X() [1/2]

int scmp::geom::Point2D::X ( ) const

Return the X component of the point.

◆ X() [2/2]

void scmp::geom::Point2D::X ( int  _x)

Set the X component of the point.

◆ Y() [1/2]

int scmp::geom::Point2D::Y ( ) const

Return the Y component of the point.

◆ Y() [2/2]

void scmp::geom::Point2D::Y ( int  _y)

Set the Y component of the point.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  outs,
const Point2D pt 
)
friend

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