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

Represents a point in 3D space with exact rational coordinates. More...

#include <point.H>

Collaboration diagram for Aleph::Point3D:
[legend]

Public Member Functions

 Point3D ()
 Default constructor.
 
 Point3D (const Geom_Number &x, const Geom_Number &y, const Geom_Number &z)
 Constructs a 3D point from x, y, and z coordinates.
 
 Point3D (const Point3D &)=default
 
Point3Doperator= (const Point3D &)=default
 
const Geom_Numberget_x () const
 Gets the x-coordinate.
 
const Geom_Numberget_y () const
 Gets the y-coordinate.
 
const Geom_Numberget_z () const
 Gets the z-coordinate.
 
bool operator== (const Point3D &p) const
 Checks for exact equality between two 3D points.
 
bool operator!= (const Point3D &p) const
 Checks for inequality between two 3D points.
 
Point3D operator+ (const Point3D &p) const
 Vector addition.
 
Point3D operator- (const Point3D &p) const
 Vector subtraction.
 
Point3Doperator+= (const Point3D &p)
 Vector addition and assignment.
 
Point3Doperator-= (const Point3D &p)
 Vector subtraction and assignment.
 
Point3D operator- () const
 Unary negation.
 
Point3D operator* (const Geom_Number &s) const
 Scalar multiplication.
 
Point3D operator/ (const Geom_Number &s) const
 Scalar division.
 
Geom_Number dot (const Point3D &p) const
 Dot product.
 
Point3D cross (const Point3D &p) const
 Cross product.
 
Geom_Number distance_squared_to (const Point3D &p) const
 Squared Euclidean distance to another point.
 
Geom_Number norm_squared () const
 Squared Euclidean norm (magnitude).
 
Geom_Number norm () const
 Euclidean norm (magnitude).
 
Geom_Number distance_to (const Point3D &p) const
 Euclidean distance to another point.
 
Point3D normalize () const
 Returns a normalized copy of this vector (unit vector).
 
Point to_2d () const
 Projects this 3D point to a 2D point by dropping the z-coordinate.
 

Static Public Member Functions

static Point3D from_2d (const Point &p)
 Lifts a 2D point to 3D, setting its z-coordinate to 0.
 
static Point3D from_2d (const Point &p, const Geom_Number &z)
 Lifts a 2D point to 3D with a specified z-coordinate.
 

Private Attributes

Geom_Number x_
 
Geom_Number y_
 
Geom_Number z_
 

Detailed Description

Represents a point in 3D space with exact rational coordinates.

Extends the 2D geometry module with a basic 3D point type. All operations use exact Geom_Number arithmetic.

Definition at line 2972 of file point.H.

Constructor & Destructor Documentation

◆ Point3D() [1/3]

Aleph::Point3D::Point3D ( )
inline

Default constructor.

Initializes a point at the origin (0,0,0).

Definition at line 2980 of file point.H.

◆ Point3D() [2/3]

Aleph::Point3D::Point3D ( const Geom_Number x,
const Geom_Number y,
const Geom_Number z 
)
inline

Constructs a 3D point from x, y, and z coordinates.

Parameters
xThe x-coordinate.
yThe y-coordinate.
zThe z-coordinate.

Definition at line 2988 of file point.H.

◆ Point3D() [3/3]

Aleph::Point3D::Point3D ( const Point3D )
default

Member Function Documentation

◆ cross()

Point3D Aleph::Point3D::cross ( const Point3D p) const
inline

Cross product.

Parameters
pThe other vector.
Returns
A new Point3D representing the cross product vector.

Definition at line 3112 of file point.H.

References x_, y_, and z_.

Referenced by Aleph::Segment3D::contains(), Aleph::Triangle3D::normal(), Aleph::scalar_triple_product(), and TEST_F().

◆ distance_squared_to()

Geom_Number Aleph::Point3D::distance_squared_to ( const Point3D p) const
inline

Squared Euclidean distance to another point.

Parameters
pThe other point.
Returns
The squared distance.

Definition at line 3126 of file point.H.

References Aleph::divide_and_conquer_partition_dp(), x_, y_, and z_.

Referenced by distance_to(), Aleph::Segment3D::length_squared(), and TEST_F().

◆ distance_to()

Geom_Number Aleph::Point3D::distance_to ( const Point3D p) const
inline

Euclidean distance to another point.

Parameters
pThe other point.
Returns
The distance.

Definition at line 3157 of file point.H.

References distance_squared_to(), and Aleph::square_root().

Referenced by Aleph::Segment3D::distance_to(), and Aleph::Segment3D::length().

◆ dot()

Geom_Number Aleph::Point3D::dot ( const Point3D p) const
inline

Dot product.

Parameters
pThe other vector.
Returns
The scalar result of the dot product.

Definition at line 3102 of file point.H.

References x_, y_, and z_.

Referenced by Aleph::Segment3D::contains(), Aleph::Segment3D::distance_to(), Aleph::scalar_triple_product(), and TEST_F().

◆ from_2d() [1/2]

static Point3D Aleph::Point3D::from_2d ( const Point p)
inlinestatic

Lifts a 2D point to 3D, setting its z-coordinate to 0.

Parameters
pThe 2D point.
Returns
A new Point3D.

Definition at line 3185 of file point.H.

References Aleph::Point::get_x(), and Aleph::Point::get_y().

Referenced by TEST_F().

◆ from_2d() [2/2]

static Point3D Aleph::Point3D::from_2d ( const Point p,
const Geom_Number z 
)
inlinestatic

Lifts a 2D point to 3D with a specified z-coordinate.

Parameters
pThe 2D point.
zThe value for the z-coordinate.
Returns
A new Point3D.

Definition at line 3196 of file point.H.

References Aleph::Point::get_x(), and Aleph::Point::get_y().

◆ get_x()

const Geom_Number & Aleph::Point3D::get_x ( ) const
inline

Gets the x-coordinate.

Definition at line 2996 of file point.H.

References x_.

Referenced by Aleph::operator<<(), Aleph::GeomSerializer::to_geojson(), and Aleph::GeomSerializer::to_wkt().

◆ get_y()

const Geom_Number & Aleph::Point3D::get_y ( ) const
inline

Gets the y-coordinate.

Definition at line 2998 of file point.H.

References y_.

Referenced by Aleph::operator<<(), Aleph::GeomSerializer::to_geojson(), and Aleph::GeomSerializer::to_wkt().

◆ get_z()

const Geom_Number & Aleph::Point3D::get_z ( ) const
inline

Gets the z-coordinate.

Definition at line 3000 of file point.H.

References z_.

Referenced by Aleph::operator<<(), Aleph::GeomSerializer::to_geojson(), and Aleph::GeomSerializer::to_wkt().

◆ norm()

Geom_Number Aleph::Point3D::norm ( ) const
inline

Euclidean norm (magnitude).

Returns
The length of the vector from the origin.

Definition at line 3147 of file point.H.

References norm_squared(), and Aleph::square_root().

Referenced by normalize().

◆ norm_squared()

Geom_Number Aleph::Point3D::norm_squared ( ) const
inline

Squared Euclidean norm (magnitude).

Returns
The squared length of the vector from the origin.

Definition at line 3138 of file point.H.

References x_, y_, and z_.

Referenced by Aleph::Triangle3D::double_area_squared(), Aleph::Triangle3D::is_degenerate(), norm(), and TEST_F().

◆ normalize()

Point3D Aleph::Point3D::normalize ( ) const
inline

Returns a normalized copy of this vector (unit vector).

Returns
A Point3D with a magnitude of 1.
Exceptions
std::domain_errorif normalizing the zero vector is attempted.

Definition at line 3167 of file point.H.

References ah_domain_error_if, and norm().

◆ operator!=()

bool Aleph::Point3D::operator!= ( const Point3D p) const
inline

Checks for inequality between two 3D points.

Parameters
pThe other point.
Returns
true if any coordinate is different.

Definition at line 3017 of file point.H.

◆ operator*()

Point3D Aleph::Point3D::operator* ( const Geom_Number s) const
inline

Scalar multiplication.

Parameters
sThe scalar value.
Returns
A new Point3D with each coordinate multiplied by s.

Definition at line 3082 of file point.H.

References x_, y_, and z_.

◆ operator+()

Point3D Aleph::Point3D::operator+ ( const Point3D p) const
inline

Vector addition.

Parameters
pThe other point to add.
Returns
A new Point3D representing the component-wise sum.

Definition at line 3027 of file point.H.

References x_, y_, and z_.

◆ operator+=()

Point3D & Aleph::Point3D::operator+= ( const Point3D p)
inline

Vector addition and assignment.

Parameters
pThe other point to add.
Returns
A reference to this modified point.

Definition at line 3047 of file point.H.

References x_, y_, and z_.

◆ operator-() [1/2]

Point3D Aleph::Point3D::operator- ( ) const
inline

Unary negation.

Returns
A new Point3D with all coordinates negated.

Definition at line 3072 of file point.H.

References x_, y_, and z_.

◆ operator-() [2/2]

Point3D Aleph::Point3D::operator- ( const Point3D p) const
inline

Vector subtraction.

Parameters
pThe other point to subtract.
Returns
A new Point3D representing the component-wise difference.

Definition at line 3037 of file point.H.

References x_, y_, and z_.

◆ operator-=()

Point3D & Aleph::Point3D::operator-= ( const Point3D p)
inline

Vector subtraction and assignment.

Parameters
pThe other point to subtract.
Returns
A reference to this modified point.

Definition at line 3060 of file point.H.

References x_, y_, and z_.

◆ operator/()

Point3D Aleph::Point3D::operator/ ( const Geom_Number s) const
inline

Scalar division.

Parameters
sThe scalar value.
Returns
A new Point3D with each coordinate divided by s.

Definition at line 3092 of file point.H.

References x_, y_, and z_.

◆ operator=()

Point3D & Aleph::Point3D::operator= ( const Point3D )
default

◆ operator==()

bool Aleph::Point3D::operator== ( const Point3D p) const
inline

Checks for exact equality between two 3D points.

Parameters
pThe other point.
Returns
true if all three coordinates are identical.

Definition at line 3007 of file point.H.

References Aleph::and, x_, y_, and z_.

◆ to_2d()

Point Aleph::Point3D::to_2d ( ) const
inline

Projects this 3D point to a 2D point by dropping the z-coordinate.

Returns
A Point with the x and y coordinates of this point.

Definition at line 3178 of file point.H.

References x_, and y_.

Referenced by TEST_F().

Member Data Documentation

◆ x_

◆ y_

◆ z_


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