Simple 3D point structure. More...
#include <point3d.h>
Public Types | |
enum | Axis { X = 0, Y, Z } |
Different Axes values. More... | |
typedef std::vector< Point3D > | List |
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. | |
Point3D & | Normalize () |
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. | |
Point3D & | operator() (const double x, const double y, const double z) |
Sets the values of x, y, and z. | |
Point3D & | operator= (const Point3D &p) |
Sets equal to. | |
Point3D & | operator+= (const Point3D &p) |
Adds the point. | |
Point3D & | operator-= (const Point3D &p) |
Subtracts the point. | |
Point3D & | operator*= (const double val) |
Multiplies the point by a scalar value. | |
Point3D & | operator/= (const double val) |
Divides the point by a scalar value. | |
Point3D & | operator/= (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. |
Simple 3D point structure.
Definition at line 55 of file point3d.h.
typedef std::vector<Point3D> CxUtils::Point3D::List |
Point3D::Point3D | ( | const Point3D & | p ) |
Point3D::Point3D | ( | const double | x = 0 , |
const double | y = 0 , |
||
const double | z = 0 |
||
) |
Constructor. Sets values.
x | Distance along X axis. |
y | Distance along Y axis. |
z | Distance along Z axis. |
Definition at line 71 of file point3d.cpp.
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.
Definition at line 296 of file point3d.cpp.
Calculates the distance between points.
p1 | The first point. |
p2 | The second point. |
Definition at line 710 of file point3d.cpp.
double Point3D::Distance | ( | const Point3D & | p ) | const |
Gets the distance to the point.
p | The point to find the distance to. |
Definition at line 336 of file point3d.cpp.
double Point3D::Dot | ( | const Point3D & | p ) | const |
Treats the 3D points as a vector for calculating the dot product.
[in] | p | the piont to get the dot product with. |
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.
[in] | thresh | The 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.
x | Distance along X axis. |
y | Distance along Y axis. |
z | Distance along Z axis. |
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].
[in] | points | Points to regress. |
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.
Definition at line 386 of file point3d.cpp.
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.
[in] | p1 | Point to check for within a plane. |
[in] | p2 | Point to check for within a plane. |
[in] | p3 | Point to check for within a plane. |
[in] | p4 | Point to check for within a plane. |
Definition at line 511 of file point3d.cpp.
Determines if all four points are within the same plane.
p1 | Point on plane. |
p2 | Point on plane. |
p3 | Point on plane. |
Definition at line 211 of file point3d.cpp.
p1 | First point of triangle. |
p2 | Second point of triangle. |
p3 | Final 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.
p | The vector to see if we are parallel with. |
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.
[in] | points | Points to regress. |
Definition at line 725 of file point3d.cpp.
double Point3D::Magnitude | ( | ) | const |
Gets the distance to the point.
Definition at line 308 of file point3d.cpp.
Gets the midpoint between points.
p | The point to find midpoint to. |
Definition at line 478 of file point3d.cpp.
Gets the midpoint between points.
p1 | First point in segment. |
p2 | Second point in segment. |
Definition at line 493 of file point3d.cpp.
Point3D & Point3D::Normalize | ( | ) |
Normalizes the 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.
[in] | scalar | The value to multiply the point values by. |
Definition at line 679 of file point3d.cpp.
Calculates the cross product.
[in] | p | The point to get cross product with. |
Definition at line 658 of file point3d.cpp.
Point3D & Point3D::operator*= | ( | const double | val ) |
Multiplies the point by a scalar value.
val | The value to multiply with. |
Definition at line 592 of file point3d.cpp.
Adds the point.
p | The point to add. |
Definition at line 628 of file point3d.cpp.
Adds the point.
p | The point to add. |
Definition at line 556 of file point3d.cpp.
Subtracts the point.
p | The point to subtract. |
Definition at line 643 of file point3d.cpp.
Subtracts the point.
p | The point to subtract. |
Definition at line 574 of file point3d.cpp.
Point3D Point3D::operator/ | ( | const double | scalar ) | const |
Divides the point by the scalar value.
[in] | scalar | The value to divide the point values by. |
Definition at line 694 of file point3d.cpp.
Point3D & Point3D::operator/= | ( | const double | val ) |
Divides the point by a scalar value.
val | The value to divide with. |
Definition at line 610 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.
[in] | angle | The amount to rotate. |
[in] | axis | The axis to rotate around, see Point3D::Axis enumerations. |
[in] | angleInDegrees | If 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.
[in] | pivot | The 3D point to rotate around instead of origin. |
[in] | angle | The amount to rotate. |
[in] | axis | The axis to rotate around, see Point3D::Axis enumerations. |
[in] | angleInDegrees | If 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.
x | Distance along X axis. |
y | Distance along Y axis. |
z | Distance along Z axis. |
Definition at line 88 of file point3d.cpp.
double Point3D::SumOfSquares | ( | ) | const |
Calculates the sum of the squares of the components.
Definition at line 321 of file point3d.cpp.
double CxUtils::Point3D::mX |
double CxUtils::Point3D::mY |
double CxUtils::Point3D::mZ |