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

CxUtils::Segment3D Class Reference

Simple 3D Line Segment structure. Class contains methods for basic geometric relationships between segments and points in 3D space. More...

#include <segment3d.h>

List of all members.

Public Types

enum  Axis { X = 0, Y, Z }
 

Different Axes values.

More...
typedef std::vector< Segment3DList
 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.
Segment3Doperator= (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.

Detailed Description

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.


Member Typedef Documentation

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

List (std::vector) of 3D segments.

Definition at line 56 of file segment3d.h.


Member Enumeration Documentation

Different Axes values.

Enumerator:
X 
Y 
Z 

Definition at line 63 of file segment3d.h.


Constructor & Destructor Documentation

Segment3D::Segment3D (  )

Constructor. Initializes data members.

Definition at line 50 of file segment3d.cpp.

Segment3D::Segment3D ( const Segment3D segment )

Copy constructor.

Parameters:
[in]segmentThe segment to be equal to.

Definition at line 63 of file segment3d.cpp.

Segment3D::Segment3D ( const Point3D p1,
const Point3D p2,
const double  width = 0.0 
)

Constructor.

Parameters:
[in]p1The source/first point in the segment.
[in]p2The destination/second point in the segment.
[in]widthThe 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.


Member Function Documentation

void Segment3D::Clear (  )

Sets to defaults.

Definition at line 115 of file segment3d.cpp.

bool Segment3D::DoesIntersect ( const Segment3D segment1,
const Segment3D segment2 
) [static]

Checks to see if two segments intersect.

Parameters:
[in]segment1The first segment to compare with.
[in]segment2The second segment to compare with..
Returns:
True if the two segments intersect with each other, otherwise false.

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.

Parameters:
[in]segment1The first segment to compare with.
[in]segment2The second segment to compare with..
[out]intersectionPointThe point where the segments intersect.
Returns:
True if the two segments intersect with each other, otherwise false.

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.

Parameters:
[in]segmentThe segment to check for intersection with triangle.
[in]p1Point defining a triangle.
[in]p2Point defining a triangle.
[in]p3Point defining a triangle.
Returns:
True if the segment intersects with the triangle.

Definition at line 769 of file segment3d.cpp.

bool Segment3D::DoesIntersectXY ( const Segment3D segment1,
const Segment3D segment2 
) [static]

Checks to see if two segments intersect in the XY plane.

Parameters:
[in]segment1The first segment to compare with in the XY plane.
[in]segment2The second segment to compare with in the XY plane.
Returns:
True if the two segments intersect with each in the XY plane, otherwise false.

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.

Parameters:
[in]segment1The first segment to compare with in the XY plane.
[in]segment2The second segment to compare with in the XY plane.
[out]intersectionPointThe point where the segments intersect in the XY plane.
Returns:
True if the two segments intersect with each in the XY plane, otherwise false.

Definition at line 711 of file segment3d.cpp.

Segment3D Segment3D::Flip (  )

Flips the source and destination values.

Returns:
A copy of the current segment with the source and destination points switched.

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.

Parameters:
[in]degreesIf true, result is returned in degrees, otherwise in radians.
Returns:
Angle within the desired plane.

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.

Parameters:
[in]degreesIf true, result is returned in degrees, otherwise in radians.
Returns:
Angle within the desired plane.

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.

Parameters:
[in]degreesIf true, result is returned in degrees, otherwise in radians.
Returns:
Angle within the desired plane.

Definition at line 279 of file segment3d.cpp.

Point3D Segment3D::GetClosestPointOnSegment ( const Point3D point ) const

Gets the point on segment closest to point. Ignores segment width.

Parameters:
[in]pointPoint to find closest point to on segment.
Returns:
Point on segment closest to point.

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.

Parameters:
[in]pointThe point to get closest point on segment from.
[in]segmentThe segment to get closest point.
Returns:
The closest point on segment.

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.

Parameters:
[in]pointThe point to get distance to segment from.
Returns:
The distance from the point to the segment.

Definition at line 297 of file segment3d.cpp.

double Segment3D::GetDistanceToPoint ( const Point3D point,
const Segment3D segment 
) [static]

Gets the shortest distance from the point to the line segment.

Parameters:
[in]pointThe point to get distance to segment from.
[in]segmentThe segment to get distance to point from.
Returns:
The distance from the point to the segment.

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.

Parameters:
[in]segmentThe segment to get distance to.
Returns:
Shortest between two segments.

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.

Parameters:
[in]segment1The first segment.
[in]segment2The second segment.
Returns:
Shortest between two segments.

Definition at line 946 of file segment3d.cpp.

double Segment3D::GetDistanceX (  ) const
Returns:
Distance from source to destination along axis.

Definition at line 144 of file segment3d.cpp.

double Segment3D::GetDistanceY (  ) const
Returns:
Distance from source to destination along axis.

Definition at line 155 of file segment3d.cpp.

double Segment3D::GetDistanceZ (  ) const
Returns:
Distance from source to destination along axis.

Definition at line 165 of file segment3d.cpp.

double Segment3D::GetDotProduct (  ) const
Returns:
Dot product of the line segment.

Definition at line 176 of file segment3d.cpp.

double Segment3D::GetMagnitude (  ) const
Returns:
Normal of the segment (segment length).

Definition at line 208 of file segment3d.cpp.

Point3D Segment3D::GetMidpoint (  ) const
Returns:
Midpoint of the segment.

Definition at line 356 of file segment3d.cpp.

double Segment3D::GetNorm (  ) const
Returns:
Normal of the segment (segment length).

Definition at line 192 of file segment3d.cpp.

Segment3D Segment3D::GetProjectionXY (  ) const
Returns:
Projection of the segment within the 2D plane.

Definition at line 369 of file segment3d.cpp.

Segment3D Segment3D::GetProjectionXZ (  ) const
Returns:
Projection of the segment within the 2D plane.

Definition at line 383 of file segment3d.cpp.

Segment3D Segment3D::GetProjectionYZ (  ) const
Returns:
Projection of the segment within the 2D plane.

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.

Returns:
Vector composed of (GetDistanceX(), GetDistanceY(), GetDistanceZ()).

Definition at line 345 of file segment3d.cpp.

double Segment3D::GetVolume (  ) const
Returns:
Volumn of the 3D segment (based on width and magnitude).

Definition at line 224 of file segment3d.cpp.

bool Segment3D::IsParallel ( const Segment3D segment ) const

Checks to see if the two segments are paralell.

Parameters:
[in]segmentThe segment to compare with for paralellism.
Returns:
True if in parallel, otherwise false.

Definition at line 133 of file segment3d.cpp.

bool Segment3D::IsParallel ( const Segment3D segment1,
const Segment3D segment2 
) [static]

Compares to segments to find out if they are parallel.

Parameters:
[in]segment1The first segment.
[in]segment2The second segment.
Returns:
True if the two segments are in parallel, otherwise false.

Definition at line 849 of file segment3d.cpp.

Segment3D & Segment3D::operator= ( const Segment3D segment )

Sets equal to.

Parameters:
[in]segmentSegment to be equal to.
Returns:
The modified segment that is a copy.

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.

Parameters:
[in]angleThe amount to rotate.
[in]axisThe axis to rotate around, see Segment3D::Axis enumerations.
[in]angleInDegreesIf 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.

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

Definition at line 457 of file segment3d.cpp.


Member Data Documentation

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.

Width of the segment.

Definition at line 127 of file segment3d.h.


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