Kernel SDK Developer's Guide > Working with the Ge Library > Working with Lines > Working with Rays
Working with Rays

Rays are considered to be semi-infinite lines running from a start point to infinity. Ray objects are represented by the OdGeRay2d and OdGeRay3d classes and inherit the functionality of the OdGeLinearEnt2d and OdGeLinearEnt3d classes respectively. This topic demonstrates the most common operations with rays as an object of the OdGeRay3d class. The functionality of 2D ray objects is similar.

For creation of a ray object, you can use one of the OdGeLine3d() constructors:

  • OdGeRay3d::OdGeRay3d() — Default constructor. Creates a ray with the start point of (0,0,0) and the direction of (0,0,0).
  • OdGeRay3d::OdGeRay3d(const OdGeRay3d& line) — Creates a ray cloned from the source ray object.
  • OdGeRay3d::OdGeRay3d(const OdGePoint3d& point, const OdGeVector3d& vect) — Creates a ray passing through the point with the direction of vect.
  • OdGeRay3d::OdGeRay3d(const OdGePoint3d& point1, const OdGePoint3d& point2) — Creates a ray passing through the non-coincident point1 and point2.

The pointOnLine() method returns the arbitrary point of the ray:

OdGePoint3d point1 = ray1.pointOnLine();

The direction() method returns the direction vector of the ray:

OdGeVector3d direction = ray1.direction();

The distanceTo() method finds the distance to the point on the ray closest to the specified point or curve:

double distance1 = ray1.distanceTo(point2);
double distance2 = ray1.distanceTo(line);

The isOn() method is used to determine if the specified point is on the ray:

if (ray1.isOn(point1))

The isParallelTo() method is used to determine if the ray is parallel to the specified line:

if (ray1.isParallelTo(line1))

The isPerpendicularTo() method is used to determine if the ray is perpendicular to the specified line:

if (ray1.isPerpendicularTo(line1))

The intersectWith() method is used to determine if the ray intersects the specified line or plane and find the intersection point:

if (ray1.intersectWith(line2, p1))
if (ray1.intersectWith(plane1, p1))

See Also

Working with Lines

Working with Line Segments

Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.