Public Types | Public Member Functions | Static Public Member Functions | Public Attributes

CxUtils::Point3D Class Reference

Simple 3D point structure. More...

#include <point3d.h>

Inheritance diagram for CxUtils::Point3D:
Inheritance graph
[legend]

List of all members.

Public Types

enum  Axis { X = 0, Y, Z }
 

Different Axes values.

More...
typedef std::vector< Point3DList
 A List (std::vector) of 3D points.

Public Member Functions

 Point3D (const Point3D &p)
 Copy constructor.
 Point3D (const double x=0, const double y=0, const double z=0)
 Constructor. Sets values.
int Set (const double x, const double y, const double z)
 Sets the values.
int Get (double &x, double &y, double &z) const
 Gets the values.
void Clear ()
 Sets point to origin.
void Floor (const double thresh)
 Sets any value to 0 if the absolute value of the component is less than thresh.
void Print () const
 Prints out point data to console.
bool IsParallel (const Point3D &p) const
 Checks to see if the vectors the poitns represent are parallel.
bool IsCoplanar (const Point3D &p1, const Point3D &p2, const Point3D &p3) const
 Determines if all four points are within the same plane.
bool IsCollinear (const Point3D &p1, const Point3D &p2) const
bool IsInside (const Point3D &p1, const Point3D &p2, const Point3D &p3) const
double Distance () const
 Gets the distance to the point.
double Magnitude () const
 Gets the distance to the point.
double SumOfSquares () const
 Calculates the sum of the squares of the components.
double Distance (const Point3D &p) const
 Gets the distance to the point.
double Dot (const Point3D &p) const
 Treats the 3D points as a vector for calculating the dot product.
Point3DNormalize ()
 Normalizes the vector the point represents.
Point3D GetUnitVector () const
 Gets a copy of the normalized vector. (Same vector but magnitude is 0). This is useful if you are treating points as vectors.
Point3D Rotate (const double angle, const unsigned int axis, const bool angleInDegrees=false) const
 Rotates the point around the origin by the angle given and axis of rotation.
Point3D Rotate (const Point3D &origin, const double angle, const unsigned int axis, const bool angleInDegrees=false) const
 Rotates the point around another point.
Point3D Midpoint (const Point3D &p) const
 Gets the midpoint between points.
Point3Doperator() (const double x, const double y, const double z)
 Sets the values of x, y, and z.
Point3Doperator= (const Point3D &p)
 Sets equal to.
Point3Doperator+= (const Point3D &p)
 Adds the point.
Point3Doperator-= (const Point3D &p)
 Subtracts the point.
Point3Doperator*= (const double val)
 Multiplies the point by a scalar value.
Point3Doperator/= (const double val)
 Divides the point by a scalar value.
Point3Doperator/= (const Point3D &p)
Point3D operator+ (const Point3D &p) const
 Adds the point.
Point3D operator- (const Point3D &p) const
 Subtracts the point.
Point3D operator* (const double scaler) const
 Multiples the point by the scalar value.
Point3D operator/ (const double scaler) const
 Divides the point by the scalar value.
Point3D operator* (const Point3D &p) const
 Calculates the cross product.
Point3D operator/ (const Point3D &p) const

Static Public Member Functions

static double Distance (const Point3D &p1, const Point3D &p2)
 Calculates the distance between points.
static Point3D Midpoint (const Point3D &p1, const Point3D &p2)
 Gets the midpoint between points.
static double Dot (const Point3D &p1, const Point3D &p2)
static bool IsCoplanar (const Point3D &p1, const Point3D &p2, const Point3D &p3, const Point3D &p4)
 Checks to see if four points are coplanar.
static double LinearRegressionSlope (const Point3D::List &points)
 Calculates a linear regression of a list of points and returns slope of the line in 2D XY plane.
static double GetLinearRegressionAngle (const Point3D::List &points)
 Converts the slope of the line of the XY plane points to an angle [-PI, PI].

Public Attributes

double mX
 Distance along X-axis.
double mY
 Distance along Y-axis.
double mZ
 Distance along Z-axis.

Detailed Description

Simple 3D point structure.

Definition at line 55 of file point3d.h.


Member Typedef Documentation

typedef std::vector<Point3D> CxUtils::Point3D::List

A List (std::vector) of 3D points.

Definition at line 58 of file point3d.h.


Member Enumeration Documentation

Different Axes values.

Enumerator:
X 
Y 
Z 

Definition at line 65 of file point3d.h.


Constructor & Destructor Documentation

Point3D::Point3D ( const Point3D p )

Copy constructor.

Parameters:
pPoint to be equal to.

Definition at line 54 of file point3d.cpp.

Point3D::Point3D ( const double  x = 0,
const double  y = 0,
const double  z = 0 
)

Constructor. Sets values.

Parameters:
xDistance along X axis.
yDistance along Y axis.
zDistance along Z axis.

Definition at line 71 of file point3d.cpp.


Member Function Documentation

void Point3D::Clear (  )

Sets point to origin.

Definition at line 118 of file point3d.cpp.

double Point3D::Distance (  ) const

Gets the distance to the point.

Returns:
Distance to point.

Definition at line 296 of file point3d.cpp.

double Point3D::Distance ( const Point3D p1,
const Point3D p2 
) [static]

Calculates the distance between points.

Parameters:
p1The first point.
p2The second point.
Returns:
Distance between points.

Definition at line 710 of file point3d.cpp.

double Point3D::Distance ( const Point3D p ) const

Gets the distance to the point.

Parameters:
pThe point to find the distance to.
Returns:
Distance to point.

Definition at line 336 of file point3d.cpp.

static double CxUtils::Point3D::Dot ( const Point3D p1,
const Point3D p2 
) [inline, static]

Definition at line 114 of file point3d.h.

double Point3D::Dot ( const Point3D p ) const

Treats the 3D points as a vector for calculating the dot product.

Parameters:
[in]pthe piont to get the dot product with.
Returns:
The dot product of current point vector with the other point.

Definition at line 352 of file point3d.cpp.

void Point3D::Floor ( const double  thresh )

Sets any value to 0 if the absolute value of the component is less than thresh.

Parameters:
[in]threshThe threshold value to be less than.

Definition at line 132 of file point3d.cpp.

int Point3D::Get ( double &  x,
double &  y,
double &  z 
) const

Gets the values.

Parameters:
xDistance along X axis.
yDistance along Y axis.
zDistance along Z axis.
Returns:
1 if value retrieved, otherwise 0.

Definition at line 106 of file point3d.cpp.

double Point3D::GetLinearRegressionAngle ( const Point3D::List points ) [static]

Converts the slope of the line of the XY plane points to an angle [-PI, PI].

Parameters:
[in]pointsPoints to regress.
Returns:
Angle of line from [-PI, PI].

Definition at line 764 of file point3d.cpp.

Point3D Point3D::GetUnitVector (  ) const

Gets a copy of the normalized vector. (Same vector but magnitude is 0). This is useful if you are treating points as vectors.

Returns:
Copy of the normalized vector that the point represented.

Definition at line 386 of file point3d.cpp.

bool Point3D::IsCollinear ( const Point3D p1,
const Point3D p2 
) const
Returns:
True if the points are in the same line, otherwise false.

Definition at line 229 of file point3d.cpp.

bool Point3D::IsCoplanar ( const Point3D p1,
const Point3D p2,
const Point3D p3,
const Point3D p4 
) [static]

Checks to see if four points are coplanar.

Parameters:
[in]p1Point to check for within a plane.
[in]p2Point to check for within a plane.
[in]p3Point to check for within a plane.
[in]p4Point to check for within a plane.
Returns:
True if the points are all in the same plane.

Definition at line 511 of file point3d.cpp.

bool Point3D::IsCoplanar ( const Point3D p1,
const Point3D p2,
const Point3D p3 
) const

Determines if all four points are within the same plane.

Parameters:
p1Point on plane.
p2Point on plane.
p3Point on plane.
Returns:
True if all points are within the same plane, otherwise false.

Definition at line 211 of file point3d.cpp.

bool Point3D::IsInside ( const Point3D p1,
const Point3D p2,
const Point3D p3 
) const
Returns:
True if the points are within the triangle defined by the three points, but does not check if the point is in the same plane as the triangle.
Parameters:
p1First point of triangle.
p2Second point of triangle.
p3Final point of triangle.

Definition at line 265 of file point3d.cpp.

bool Point3D::IsParallel ( const Point3D p ) const

Checks to see if the vectors the poitns represent are parallel.

Parameters:
pThe vector to see if we are parallel with.
Returns:
True if the vectors the points represent are parallel, otherwise false.

Definition at line 174 of file point3d.cpp.

double Point3D::LinearRegressionSlope ( const Point3D::List points ) [static]

Calculates a linear regression of a list of points and returns slope of the line in 2D XY plane.

Parameters:
[in]pointsPoints to regress.
Returns:
Slope of line. Y/X.

Definition at line 725 of file point3d.cpp.

double Point3D::Magnitude (  ) const

Gets the distance to the point.

Returns:
Distance to point.

Definition at line 308 of file point3d.cpp.

Point3D Point3D::Midpoint ( const Point3D p ) const

Gets the midpoint between points.

Parameters:
pThe point to find midpoint to.
Returns:
Midpoint data.

Definition at line 478 of file point3d.cpp.

Point3D Point3D::Midpoint ( const Point3D p1,
const Point3D p2 
) [static]

Gets the midpoint between points.

Parameters:
p1First point in segment.
p2Second point in segment.
Returns:
Midpoint data.

Definition at line 493 of file point3d.cpp.

Point3D & Point3D::Normalize (  )

Normalizes the vector the point represents.

Returns:
The normalized vector the point represents.

Definition at line 365 of file point3d.cpp.

Point3D & Point3D::operator() ( const double  x,
const double  y,
const double  z 
)

Sets the values of x, y, and z.

Reimplemented in CxUtils::Gcc.

Definition at line 525 of file point3d.cpp.

Point3D Point3D::operator* ( const double  scalar ) const

Multiples the point by the scalar value.

Parameters:
[in]scalarThe value to multiply the point values by.
Returns:
A copy of the point with the values multiplied by the scalar value.

Definition at line 679 of file point3d.cpp.

Point3D Point3D::operator* ( const Point3D p ) const

Calculates the cross product.

Parameters:
[in]pThe point to get cross product with.
Returns:
The cross product of thet wo points.

Definition at line 658 of file point3d.cpp.

Point3D & Point3D::operator*= ( const double  val )

Multiplies the point by a scalar value.

Parameters:
valThe value to multiply with.
Returns:
The result of multiplication.

Definition at line 592 of file point3d.cpp.

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

Adds the point.

Parameters:
pThe point to add.
Returns:
The result of addition.

Definition at line 628 of file point3d.cpp.

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

Adds the point.

Parameters:
pThe point to add.
Returns:
The result of addition.

Definition at line 556 of file point3d.cpp.

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

Subtracts the point.

Parameters:
pThe point to subtract.
Returns:
The result of subtraction.

Definition at line 643 of file point3d.cpp.

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

Subtracts the point.

Parameters:
pThe point to subtract.
Returns:
The result of subtraction.

Definition at line 574 of file point3d.cpp.

Point3D CxUtils::Point3D::operator/ ( const Point3D p ) const [inline]

Definition at line 111 of file point3d.h.

Point3D Point3D::operator/ ( const double  scalar ) const

Divides the point by the scalar value.

Parameters:
[in]scalarThe value to divide the point values by.
Returns:
A copy of the point with the values divided by the scalar value.

Definition at line 694 of file point3d.cpp.

Point3D & Point3D::operator/= ( const double  val )

Divides the point by a scalar value.

Parameters:
valThe value to divide with.
Returns:
The result of division by scaler value.

Definition at line 610 of file point3d.cpp.

Point3D& CxUtils::Point3D::operator/= ( const Point3D p ) [inline]

Definition at line 105 of file point3d.h.

Point3D & Point3D::operator= ( const Point3D p )

Sets equal to.

Reimplemented in CxUtils::Gcc.

Definition at line 538 of file point3d.cpp.

void Point3D::Print (  ) const

Prints out point data to console.

Reimplemented in CxUtils::Gcc.

Definition at line 154 of file point3d.cpp.

Point3D Point3D::Rotate ( const double  angle,
const unsigned int  axis,
const bool  angleInDegrees = false 
) const

Rotates the point around the origin by the angle given and axis of rotation.

Parameters:
[in]angleThe amount to rotate.
[in]axisThe axis to rotate around, see Point3D::Axis enumerations.
[in]angleInDegreesIf true the value of angle is in degrees, if false it is in radians (default).

Definition at line 407 of file point3d.cpp.

Point3D Point3D::Rotate ( const Point3D pivot,
const double  angle,
const unsigned int  axis,
const bool  angleInDegrees = false 
) const

Rotates the point around another point.

Parameters:
[in]pivotThe 3D point to rotate around instead of origin.
[in]angleThe amount to rotate.
[in]axisThe axis to rotate around, see Point3D::Axis enumerations.
[in]angleInDegreesIf true the value of angle is in degrees, if false it is in radians (default).

Definition at line 441 of file point3d.cpp.

int Point3D::Set ( const double  x,
const double  y,
const double  z 
)

Sets the values.

Parameters:
xDistance along X axis.
yDistance along Y axis.
zDistance along Z axis.
Returns:
1 if value set, otherwise 0.

Definition at line 88 of file point3d.cpp.

double Point3D::SumOfSquares (  ) const

Calculates the sum of the squares of the components.

Returns:
Sum of the squares of the components.

Definition at line 321 of file point3d.cpp.


Member Data Documentation

Distance along X-axis.

Definition at line 123 of file point3d.h.

Distance along Y-axis.

Definition at line 124 of file point3d.h.

Distance along Z-axis.

Definition at line 125 of file point3d.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines