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

Line objects are represented by the OdGeLine2d and OdGeLine3d classes and inherit functionality of the OdGeLinearEnt2d and OdGeLinearEnt3d classes respectively. This topic demonstrates the most common operations with lines as an object of the OdGeLine3d class. The functionality of 2D line objects is similar.

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

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

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

OdGePoint3d p1 = line.pointOnLine();

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

OdGeVector3d v = line.direction();

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

double distance1 = line1.distanceTo(p1);
double distance2 = line1.distanceTo(line2);

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

if (line1.isOn(p1))

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

if (line1.isParallelTo(line2))

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

if (line1.isPerpendicularTo(line2))

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

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

See Also

Working with Rays

Working with Line Segments

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