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:
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))
Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.
|