Line2D
Canonical path: NemAll_Python_Geometry.Line2D
Representation of a two-dimensional line
RefPoint
property
writable
RefPoint: Point2D
Get the reference point.
Coordinates of points will be recalculated with new reference point. Formula: m_Points[i] = m_RefPoint + m_Points[i] - refPoint
StartRelPoint
property
writable
StartRelPoint: Point2D
Get the start point in relative coordinate system
EqualRef
EqualRef(line: Line2D) -> bool
Check, whether the reference point of another line is equal to the reference point of this line.
Reference point of a line is by default (0,0), regardless of the start point of the line.
Parameters:
-
line
(Line2D
) –Line to compare
Returns:
-
bool
–True if the reference points are equal, False otherwise
Examples:
Extend
Extend the line at the end
Parameters:
-
delta
(float
) –size of extension
Examples:
line_4
is a line from (0, 0) to (5, 5). Extending it by 1.0 results in:
Extending by a negative value trims the line:
GetAngle
GetAngle() -> Angle
GetCenterPoint
GetCenterPoint() -> Point2D
Get the center point in world coordinate system
Returns:
-
Point2D
–Center point in world coordinate system
Examples:
line_4
is a line from (0, 0) to (5, 5). The center point is at:
GetCoords
GetCoords() -> tuple[float, float, float, float]
Get coordinates in world coordinate.
Returns:
-
float
–Start point X coordinate
-
float
–Start point Y coordinate
-
float
–End point X coordinate
-
float
–End point Y coordinate
GetEndPoint
GetEndPoint() -> Point2D
GetEndRelPoint
GetEndRelPoint() -> Point2D
GetStartPoint
GetStartPoint() -> Point2D
GetStartRelPoint
GetStartRelPoint() -> Point2D
GetVector
GetVector() -> Vector2D
IsPoint
Check, whether the line is a point (start point equal end point)
Returns:
-
bool
–Line is a point: true/false
Set
overloaded
Set(line: Line2D)
Set line points in world coordinate system.
Used world coordinates.
Parameters:
-
x1
(float
) –X coordinate of start point.
-
y1
(float
) –Y coordinate of start point.
-
x2
(float
) –X coordinate of end point.
-
y2
(float
) –Y coordinate of end point.
SetEndPoint
SetEndPoint(endPoint: Point2D)
SetEndRelPoint
SetEndRelPoint(endPoint: Point2D)
SetRefPoint
SetRefPoint(refPoint: Point2D)
Set reference point in world coordinate system.
Coordinates of points will be recalculated with new reference point. Formula: m_Points[i] = m_RefPoint + m_Points[i] - refPoint
Parameters:
-
refPoint
(Point2D
) –new reference point.
SetStartPoint
SetStartPoint(startPoint: Point2D)
SetStartRelPoint
SetStartRelPoint(startPoint: Point2D)
TrimEnd
Trim the line at the end
Parameters:
-
ds
(float
) –The length by which the line will be trimmed. Negative value extends the line.
Examples:
line_4
is a line from (0, 0) to (5, 5). Trimming it by 1.0 results in:
Trimming by a negative value extends the line:
TrimStart
Trim the line at the start
Parameters:
-
ds
(float
) –The length by which the line will be trimmed. Negative value extends the line.
Raises:
-
ValueError
–When the ds length is larger than the line's length.
__eq__
__eq__(line: Line2D) -> bool
Comparison of lines.
Be careful, this method work without tolerance!
Parameters:
-
line
(Line2D
) –line to be compared.
Returns:
-
bool
–True when lines are equal, otherwise false.
__init__
overloaded
Initialize
__init__(line: Line2D)
__init__(line3D: Line3D)
Constructor.
Reference point is initialized to [0.0, 0.0]. Used world coordinates.
Parameters:
-
x1
(float
) –X coordinate of start point.
-
y1
(float
) –Y coordinate of start point.
-
x2
(float
) –X coordinate of end point.
-
y2
(float
) –Y coordinate of end point.