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

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 Symbol Documentation

◆ operator<<

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

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