Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Polar_Point Class Reference

Polar representation of a 2D point. More...

#include <point.H>

Inheritance diagram for Aleph::Polar_Point:
[legend]
Collaboration diagram for Aleph::Polar_Point:
[legend]

Public Types

enum  Quadrant { First , Second , Third , Fourth }
 Enumerates polar quadrants in counterclockwise order. More...
 

Public Member Functions

const Geom_Numberget_r () const
 Gets the radius (magnitude) of the polar point.
 
const Geom_Numberget_theta () const
 Gets the angle (theta) of the polar point.
 
 Polar_Point (const Geom_Number &r, const Geom_Number &theta)
 Constructs a polar point from a radius and an angle.
 
 Polar_Point (const Point &p)
 Constructs a polar point from a Cartesian point.
 
Quadrant get_quadrant () const
 Returns the quadrant where the point lies.
 
std::string to_string () const
 Converts the polar point to a string representation "[r,theta]".
 
 Polar_Point ()=default
 Default constructor.
 
- Public Member Functions inherited from Aleph::Geom_Object
 Geom_Object ()=default
 
virtual ~Geom_Object ()=default
 

Private Attributes

Geom_Number r_ = 0
 
Geom_Number theta_ = 0
 

Friends

class Point
 

Detailed Description

Polar representation of a 2D point.

Author
Leandro Rabindranath León

Polar coordinates are convenient for algorithms that rely on angles or rotations. Instances can be constructed from Cartesian coordinates and are convertible back into Point objects.

Definition at line 725 of file point.H.

Member Enumeration Documentation

◆ Quadrant

Enumerates polar quadrants in counterclockwise order.

Enumerator
First 
Second 
Third 
Fourth 

Definition at line 770 of file point.H.

Constructor & Destructor Documentation

◆ Polar_Point() [1/3]

Aleph::Polar_Point::Polar_Point ( const Geom_Number r,
const Geom_Number theta 
)
inline

Constructs a polar point from a radius and an angle.

Parameters
rThe distance from the origin (radius).
thetaThe angle in radians from the positive x-axis.

Definition at line 750 of file point.H.

◆ Polar_Point() [2/3]

Aleph::Polar_Point::Polar_Point ( const Point p)
inlineexplicit

Constructs a polar point from a Cartesian point.

Parameters
pThe Cartesian point to convert. The origin is assumed to be (0,0).

Definition at line 760 of file point.H.

References Aleph::arctan2(), Aleph::euclidean_distance(), Aleph::Point::get_x(), Aleph::Point::get_y(), r_, theta_, and y.

◆ Polar_Point() [3/3]

Aleph::Polar_Point::Polar_Point ( )
default

Default constructor.

Note
Initializes a polar point at the origin (r=0, theta=0).

Member Function Documentation

◆ get_quadrant()

Quadrant Aleph::Polar_Point::get_quadrant ( ) const
inline

Returns the quadrant where the point lies.

Note
The origin (0,0) is considered to be in the First quadrant.
Returns
The Quadrant enum value.

Definition at line 777 of file point.H.

References Aleph::and, Aleph::divide_and_conquer_partition_dp(), First, Fourth, Aleph::Point::get_x(), Aleph::Point::get_y(), Second, and Third.

◆ get_r()

const Geom_Number & Aleph::Polar_Point::get_r ( ) const
inline

Gets the radius (magnitude) of the polar point.

Returns
A const reference to the radius r.

Definition at line 737 of file point.H.

References r_.

◆ get_theta()

const Geom_Number & Aleph::Polar_Point::get_theta ( ) const
inline

Gets the angle (theta) of the polar point.

Returns
A const reference to the angle theta in radians.

Definition at line 743 of file point.H.

References theta_.

◆ to_string()

std::string Aleph::Polar_Point::to_string ( ) const
inline

Converts the polar point to a string representation "[r,theta]".

Returns
A std::string representing the polar coordinates.

Definition at line 796 of file point.H.

References Aleph::geom_number_to_double(), r_, and theta_.

Friends And Related Symbol Documentation

◆ Point

friend class Point
friend

Definition at line 727 of file point.H.

Member Data Documentation

◆ r_

Geom_Number Aleph::Polar_Point::r_ = 0
private

Definition at line 729 of file point.H.

Referenced by Polar_Point(), get_r(), and to_string().

◆ theta_

Geom_Number Aleph::Polar_Point::theta_ = 0
private

Definition at line 730 of file point.H.

Referenced by Polar_Point(), get_theta(), and to_string().


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