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

Polar2D is a pairing of a radius r and angle θ from some reference point; in this library, it is assumed to be the Cartesian origin (0, 0). More...

#include <Coord2D.h>

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

Public Member Functions

 Polar2D ()
 Construct a zero polar coordinate. More...
 
 Polar2D (double _r, double _theta)
 Construct a polar coordinate from a radius and angle. More...
 
 Polar2D (const Point2D &point)
 Construct a polar coordinate from a point. More...
 
double R () const
 Return the radius component of this coordinate. More...
 
void R (const double _r)
 Set the radius component of this coordinate. More...
 
double Theta () const
 Return the angle component of this coordinate. More...
 
void Theta (const double _theta)
 Set the angle component of this coordinate. More...
 
std::string ToString ()
 Return the coordinate in string form. More...
 
void ToPoint (Point2D &point)
 Construct a Point2D representing this Polar2D. More...
 
void Rotate (Polar2D &rotated, double delta)
 Rotate polar coordinate by some angle. More...
 
void RotateAround (const Point2D &other, Point2D &result, double delta)
 Rotate this polar coordinate around a 2D point. More...
 
- Public Member Functions inherited from scmp::geom::Vector< double, 2 >
 Vector ()
 Construct a unit vector of a given type and size. More...
 
 Vector (std::initializer_list< double > ilst)
 Construct a Vector with initial values. More...
 
double At (size_t index) const
 Return the element At index i. More...
 
void Set (size_t index, double value)
 Set a new value for the vector. More...
 
double Magnitude () const
 Compute the length of the vector. More...
 
void SetEpsilon (double 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...
 
double Angle (const Vector< double, N > &other) const
 Compute the Angle between two vectors. More...
 
bool IsParallel (const Vector< double, N > &other) const
 Determine whether two vectors are parallel. More...
 
bool IsOrthogonal (const Vector< double, N > &other) const
 Determine if two vectors are orthogonal or perpendicular to each other. More...
 
Vector ProjectParallel (const Vector< double, N > &basis) const
 Project this vector onto some basis vector. More...
 
Vector ProjectOrthogonal (const Vector< double, N > &basis)
 Project this vector perpendicularly onto some basis vector. More...
 
Vector Cross (const Vector< double, N > &other) const
 Compute the cross product of two vectors. More...
 
Vector operator+ (const Vector< double, N > &other) const
 Vector addition. More...
 
Vector operator- (const Vector< double, N > &other) const
 Vector subtraction. More...
 
Vector operator* (const double k) const
 Scalar multiplication. More...
 
double operator* (const Vector< double, N > &other) const
 Compute the Dot product between two vectors. More...
 
Vector operator/ (const double k) const
 Scalar division. More...
 
bool operator== (const Vector< double, N > &other) const
 Vector equivalence. More...
 
bool operator!= (const Vector< double, N > &other) const
 Vector non-equivalence. More...
 
const double & operator[] (size_t i) const
 Array indexing into vector. More...
 

Friends

std::ostream & operator<< (std::ostream &, const Polar2D &)
 

Detailed Description

Polar2D is a pairing of a radius r and angle θ from some reference point; in this library, it is assumed to be the Cartesian origin (0, 0).

Constructor & Destructor Documentation

◆ Polar2D() [1/3]

scmp::geom::Polar2D::Polar2D ( )

Construct a zero polar coordinate.

A Polar2D can be initialised as a zeroised polar coordinate, by specifying the radius and Angle directly, or via conversion from a Point2D.

◆ Polar2D() [2/3]

scmp::geom::Polar2D::Polar2D ( double  _r,
double  _theta 
)

Construct a polar coordinate from a radius and angle.

Parameters
_rA radius
_thetaAn angle

◆ Polar2D() [3/3]

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

Construct a polar coordinate from a point.

This construct uses the origin (0,0) as the reference point.

Parameters
pointA 2D Cartesian point.

Member Function Documentation

◆ R() [1/2]

double scmp::geom::Polar2D::R ( ) const

Return the radius component of this coordinate.

◆ R() [2/2]

void scmp::geom::Polar2D::R ( const double  _r)

Set the radius component of this coordinate.

◆ Rotate()

void scmp::geom::Polar2D::Rotate ( Polar2D rotated,
double  delta 
)

Rotate polar coordinate by some angle.

Parameters
rotatedThe rotated Polar2D will be stored in this coordinate.
deltaThe angle to rotate by.

◆ RotateAround()

void scmp::geom::Polar2D::RotateAround ( const Point2D other,
Point2D result,
double  delta 
)

Rotate this polar coordinate around a 2D point.

Parameters
otherThe reference point.
resultThe point where the result will stored.
deltaThe angle to rotate by.

◆ Theta() [1/2]

double scmp::geom::Polar2D::Theta ( ) const

Return the angle component of this coordinate.

◆ Theta() [2/2]

void scmp::geom::Polar2D::Theta ( const double  _theta)

Set the angle component of this coordinate.

◆ ToPoint()

void scmp::geom::Polar2D::ToPoint ( Point2D point)

Construct a Point2D representing this Polar2D.

◆ ToString()

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

Return the coordinate in string form.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  ,
const Polar2D  
)
friend

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