Line segment objects are represented by the OdGeLineSeg2d and OdGeLineSeg3d classes and inherit the functionality of the OdGeLinearEnt2d and OdGeLinearEnt3d classes respectively. This topic demonstrates the most common operations with line segments as an object of the OdGeLineSeg3d class. The functionality of 2D line segment objects is similar.
For creation of a line object you can use one of the OdGeLineSeg3d() constructors:
The startPoint() method returns the start point of the line segment:
OdGePoint3d point1 = seg1.startPoint();
The endPoint() method returns the end point of the line segment:
OdGePoint3d point1 = seg1.endPoint();
The midPoint() method returns the middle point of the line segment:
OdGePoint3d point1 = seg1.midPoint();
The baryComb() method returns the point of the line segment calculated as the weighted average of the start and endpoints depending on the input weight parameter blendCoeff. If blendCoeff is 0.0, this function returns the start point of the line segment. If blendCoeff is 1.0, this function returns the endpoint of the line segment. If blendCoeff is between 0.0 and 1.0, the returned point lies on the line segment. For example, to get the middle point of the line segment :
OdGePoint3d point1 = seg1.baryComb(0.5);
If the parameter is out of 1...0 the returned point is on the indefinite line that is coincident with the line segment.
The pointOnLine() method returns an arbitrary point of the line segment:
OdGePoint3d point1 = seg1.pointOnLine();
The direction() method returns the direction vector of the line segment:
OdGeVector3d direction = seg1.direction();
The distanceTo() method finds the distance to the point on the line segment closest to the specified point or curve:
double distance1 = seg1.distanceTo(point2);
double distance2 = seg1.distanceTo(line);
The isOn() method is used to determine if the specified point is on the line segment:
if (seg1.isOn(point1))
The isParallelTo() method is used to determine if the segment is parallel to a specified line:
if (seg1.isParallelTo(line1))
The isPerpendicularTo() method is used to determine if the line is perpendicular to a specified line:
if (seg1.isPerpendicularTo(line1))
The intersectWith() method is used to determine if the line intersects the specified line or plane and finds the intersection point:
if (seg1.intersectWith(line2, p1))
if (seg1.intersectWith(plane1, p1))
Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.
|