Simple 3D Line Segment structure. Class contains methods for basic geometric relationships between segments and points in 3D space. More...
#include <segment3d.h>
Public Types | |
enum | Axis { X = 0, Y, Z } |
Different Axes values. More... | |
typedef std::vector< Segment3D > | List |
List (std::vector) of 3D segments. | |
Public Member Functions | |
Segment3D () | |
Constructor. Initializes data members. | |
Segment3D (const Segment3D &segment) | |
Copy constructor. | |
Segment3D (const Point3D &p1, const Point3D &p2, const double width=0.0) | |
Constructor. | |
Segment3D | Flip () |
Flips the source and destination values. | |
void | Clear () |
Sets to defaults. | |
bool | IsParallel (const Segment3D &segment) const |
Checks to see if the two segments are paralell. | |
double | GetDistanceX () const |
double | GetDistanceY () const |
double | GetDistanceZ () const |
double | GetDotProduct () const |
double | GetNorm () const |
double | GetMagnitude () const |
double | GetVolume () const |
double | GetAngleXY (const bool degrees=false) const |
Calculates the angle of the segment within the desired plane. | |
double | GetAngleXZ (const bool degrees=false) const |
Calculates the angle of the segment within the desired plane. | |
double | GetAngleYZ (const bool degrees=false) const |
Calculates the angle of the segment within the desired plane. | |
double | GetDistanceToPoint (const Point3D &point) const |
Gets the shortest distance from the point to the line segment. | |
double | GetDistanceToSegment (const Segment3D &segment) const |
Gets the distance between the two segments. | |
Point3D | GetClosestPointOnSegment (const Point3D &point) const |
Gets the point on segment closest to point. Ignores segment width. | |
Vector3D | GetVector () const |
Gets a vector representing the line segment composed of the dx, dy, and dz values of segment. | |
Point3D | GetMidpoint () const |
Segment3D | GetProjectionXY () const |
Segment3D | GetProjectionXZ () const |
Segment3D | GetProjectionYZ () const |
Segment3D | Rotate (const double angle, const unsigned int axis, const bool angleInDegrees=false) const |
Rotates the segment around the origin by the angle given and axis of rotation. | |
Segment3D | Rotate (const Point3D &origin, const double angle, const unsigned int axis, const bool angleInDegrees=false) const |
Rotates the segment around the origin by the angle given and axis of rotation. | |
Segment3D & | operator= (const Segment3D &segment) |
Sets equal to. | |
Static Public Member Functions | |
static bool | DoesIntersect (const Segment3D &segment1, const Segment3D &segment2) |
Checks to see if two segments intersect. | |
static bool | DoesIntersectXY (const Segment3D &segment1, const Segment3D &segment2) |
Checks to see if two segments intersect in the XY plane. | |
static bool | DoesIntersect (const Segment3D &segment1, const Segment3D &segment2, Point3D &intersectionPoint) |
Checks to see if two segments intersect. | |
static bool | DoesIntersectXY (const Segment3D &segment1, const Segment3D &segment2, Point3D &intersectionPoint) |
Checks to see if two segments intersect in the XY plane. | |
static bool | DoesIntersect (const Segment3D &segment, const Point3D &p1, const Point3D &p2, const Point3D &p3) |
Checks to see if a segment intersect with a triangle. | |
static bool | IsParallel (const Segment3D &segment1, const Segment3D &segment2) |
Compares to segments to find out if they are parallel. | |
static double | GetDistanceToPoint (const Point3D &point, const Segment3D &segment) |
Gets the shortest distance from the point to the line segment. | |
static double | GetDistanceToSegment (const Segment3D &segment1, const Segment3D &segment2) |
Gets the distance between the two segments. | |
static Point3D | GetClosestPointOnSegment (const Point3D &point, const Segment3D &segment) |
Gets a point on the segment closest to a point. Ignores segment width. | |
Public Attributes | |
Point3D | mPoint1 |
First point in the segment (source). | |
Point3D | mPoint2 |
Second point in the segment (destination). | |
double | mWidth |
Width of the segment. |
Simple 3D Line Segment structure. Class contains methods for basic geometric relationships between segments and points in 3D space.
Definition at line 53 of file segment3d.h.
typedef std::vector<Segment3D> CxUtils::Segment3D::List |
List (std::vector) of 3D segments.
Definition at line 56 of file segment3d.h.
Segment3D::Segment3D | ( | ) |
Constructor. Initializes data members.
Definition at line 50 of file segment3d.cpp.
Segment3D::Segment3D | ( | const Segment3D & | segment ) |
Copy constructor.
[in] | segment | The segment to be equal to. |
Definition at line 63 of file segment3d.cpp.
Constructor.
[in] | p1 | The source/first point in the segment. |
[in] | p2 | The destination/second point in the segment. |
[in] | width | The width of the segment Only used for distance calculations and volume. Set to 0 for infinitely thin line segment. |
Definition at line 82 of file segment3d.cpp.
void Segment3D::Clear | ( | ) |
Sets to defaults.
Definition at line 115 of file segment3d.cpp.
Checks to see if two segments intersect.
[in] | segment1 | The first segment to compare with. |
[in] | segment2 | The second segment to compare with.. |
Definition at line 500 of file segment3d.cpp.
bool Segment3D::DoesIntersect | ( | const Segment3D & | segment1, |
const Segment3D & | segment2, | ||
Point3D & | intersectionPoint | ||
) | [static] |
Checks to see if two segments intersect.
[in] | segment1 | The first segment to compare with. |
[in] | segment2 | The second segment to compare with.. |
[out] | intersectionPoint | The point where the segments intersect. |
Definition at line 519 of file segment3d.cpp.
bool Segment3D::DoesIntersect | ( | const Segment3D & | segment, |
const Point3D & | p1, | ||
const Point3D & | p2, | ||
const Point3D & | p3 | ||
) | [static] |
Checks to see if a segment intersect with a triangle.
[in] | segment | The segment to check for intersection with triangle. |
[in] | p1 | Point defining a triangle. |
[in] | p2 | Point defining a triangle. |
[in] | p3 | Point defining a triangle. |
Definition at line 769 of file segment3d.cpp.
Checks to see if two segments intersect in the XY plane.
[in] | segment1 | The first segment to compare with in the XY plane. |
[in] | segment2 | The second segment to compare with in the XY plane. |
Definition at line 601 of file segment3d.cpp.
bool Segment3D::DoesIntersectXY | ( | const Segment3D & | segment1, |
const Segment3D & | segment2, | ||
Point3D & | intersectionPoint | ||
) | [static] |
Checks to see if two segments intersect in the XY plane.
[in] | segment1 | The first segment to compare with in the XY plane. |
[in] | segment2 | The second segment to compare with in the XY plane. |
[out] | intersectionPoint | The point where the segments intersect in the XY plane. |
Definition at line 711 of file segment3d.cpp.
Segment3D Segment3D::Flip | ( | ) |
Flips the source and destination values.
Definition at line 100 of file segment3d.cpp.
double Segment3D::GetAngleXY | ( | const bool | degrees = false ) |
const |
Calculates the angle of the segment within the desired plane.
[in] | degrees | If true, result is returned in degrees, otherwise in radians. |
Definition at line 241 of file segment3d.cpp.
double Segment3D::GetAngleXZ | ( | const bool | degrees = false ) |
const |
Calculates the angle of the segment within the desired plane.
[in] | degrees | If true, result is returned in degrees, otherwise in radians. |
Definition at line 260 of file segment3d.cpp.
double Segment3D::GetAngleYZ | ( | const bool | degrees = false ) |
const |
Calculates the angle of the segment within the desired plane.
[in] | degrees | If true, result is returned in degrees, otherwise in radians. |
Definition at line 279 of file segment3d.cpp.
Gets the point on segment closest to point. Ignores segment width.
[in] | point | Point to find closest point to on segment. |
Definition at line 332 of file segment3d.cpp.
Point3D Segment3D::GetClosestPointOnSegment | ( | const Point3D & | point, |
const Segment3D & | segment | ||
) | [static] |
Gets a point on the segment closest to a point. Ignores segment width.
[in] | point | The point to get closest point on segment from. |
[in] | segment | The segment to get closest point. |
Definition at line 1049 of file segment3d.cpp.
double Segment3D::GetDistanceToPoint | ( | const Point3D & | point ) | const |
Gets the shortest distance from the point to the line segment.
[in] | point | The point to get distance to segment from. |
Definition at line 297 of file segment3d.cpp.
Gets the shortest distance from the point to the line segment.
[in] | point | The point to get distance to segment from. |
[in] | segment | The segment to get distance to point from. |
Definition at line 892 of file segment3d.cpp.
double Segment3D::GetDistanceToSegment | ( | const Segment3D & | segment ) | const |
Gets the distance between the two segments.
If the segment has a width associated with it, this value is used in the distance measurement.
[in] | segment | The segment to get distance to. |
Definition at line 317 of file segment3d.cpp.
double Segment3D::GetDistanceToSegment | ( | const Segment3D & | segment1, |
const Segment3D & | segment2 | ||
) | [static] |
Gets the distance between the two segments.
If the segment has a width associated with it, this value is used in the distance measurement.
[in] | segment1 | The first segment. |
[in] | segment2 | The second segment. |
Definition at line 946 of file segment3d.cpp.
double Segment3D::GetDistanceX | ( | ) | const |
Definition at line 144 of file segment3d.cpp.
double Segment3D::GetDistanceY | ( | ) | const |
Definition at line 155 of file segment3d.cpp.
double Segment3D::GetDistanceZ | ( | ) | const |
Definition at line 165 of file segment3d.cpp.
double Segment3D::GetDotProduct | ( | ) | const |
Definition at line 176 of file segment3d.cpp.
double Segment3D::GetMagnitude | ( | ) | const |
Definition at line 208 of file segment3d.cpp.
Point3D Segment3D::GetMidpoint | ( | ) | const |
Definition at line 356 of file segment3d.cpp.
double Segment3D::GetNorm | ( | ) | const |
Definition at line 192 of file segment3d.cpp.
Segment3D Segment3D::GetProjectionXY | ( | ) | const |
Definition at line 369 of file segment3d.cpp.
Segment3D Segment3D::GetProjectionXZ | ( | ) | const |
Definition at line 383 of file segment3d.cpp.
Segment3D Segment3D::GetProjectionYZ | ( | ) | const |
Definition at line 397 of file segment3d.cpp.
Vector3D Segment3D::GetVector | ( | ) | const |
Gets a vector representing the line segment composed of the dx, dy, and dz values of segment.
Definition at line 345 of file segment3d.cpp.
double Segment3D::GetVolume | ( | ) | const |
Definition at line 224 of file segment3d.cpp.
bool Segment3D::IsParallel | ( | const Segment3D & | segment ) | const |
Checks to see if the two segments are paralell.
[in] | segment | The segment to compare with for paralellism. |
Definition at line 133 of file segment3d.cpp.
Compares to segments to find out if they are parallel.
[in] | segment1 | The first segment. |
[in] | segment2 | The second segment. |
Definition at line 849 of file segment3d.cpp.
Sets equal to.
[in] | segment | Segment to be equal to. |
Definition at line 1080 of file segment3d.cpp.
Segment3D Segment3D::Rotate | ( | const double | angle, |
const unsigned int | axis, | ||
const bool | angleInDegrees = false |
||
) | const |
Rotates the segment 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 Segment3D::Axis enumerations. |
[in] | angleInDegrees | If true the value of angle is in degrees, if false it is in radians (default). |
Definition at line 417 of file segment3d.cpp.
Segment3D Segment3D::Rotate | ( | const Point3D & | pivot, |
const double | angle, | ||
const unsigned int | axis, | ||
const bool | angleInDegrees = false |
||
) | const |
Rotates the segment around the origin by the angle given and axis of rotation.
[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 Segment3D::Axis enumerations. |
[in] | angleInDegrees | If true the value of angle is in degrees, if false it is in radians (default). |
Definition at line 457 of file segment3d.cpp.
First point in the segment (source).
Definition at line 125 of file segment3d.h.
Second point in the segment (destination).
Definition at line 126 of file segment3d.h.
double CxUtils::Segment3D::mWidth |
Width of the segment.
Definition at line 127 of file segment3d.h.