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

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

◆ operator<<

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

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