Skip to content

Line2D

Class full path: NemAll_Python_Geometry.Line2D

Representation class for 2D line.

Attributes

EndPoint: Point2D property writable

Get the end point in world coordinate system

EndRelPoint: Point2D property writable

Get the end point in relative coordinate system.

RefPoint: Point2D property writable

Get the point.

Coordinates of points will be recalculated with new point. Formula: m_Points[i] = m_RefPoint + m_Points[i] - refPoint

StartPoint: Point2D property writable

Get the start point in world coordinate system.

StartRelPoint: Point2D property writable

Get the start point in relative coordinate system

Functions

EqualRef(line)

Test for equal points

Parameters:

Name Type Description Default
line Line2D

line for comparision

required

Returns:

Type Description
bool

True if points are equal else return false.

Extend(delta)

Extend the line

Parameters:

Name Type Description Default
delta float

size of extension

required

GetAngle()

Get angle of line

Returns:

Type Description
Angle

Angle of the line

GetCenterPoint()

Get the center point in world coordinate system

Returns:

Type Description
Point2D

Center point in world coordinate system

GetCoords()

Get coordinates in world coordinate.

Returns:

Type Description
float

tuple(X coordinate of start point,

float

Y coordinate of start point,

float

X coordinate of end point,

float

Y coordinate of end point)

GetEndPoint()

Get the end point in world coordinate system

Returns:

Type Description
Point2D

point.

GetEndRelPoint()

Get the end point in relative coordinate system.

Returns:

Type Description
Point2D

constant point.

GetRefPoint()

Get the point.

Returns:

Type Description
Point2D

constant point.

GetStartPoint()

Get the start point in world coordinate system.

Returns:

Type Description
Point2D

point.

GetStartRelPoint()

Get the start point in relative coordinate system

Returns:

Type Description
Point2D

constant point.

GetVector()

Get the vector.

Returns:

Type Description
Vector2D

vector.

IsPoint()

Check, whether the line is a point (start point equal end point)

Returns:

Type Description
bool

Line is a point: true/false

Reverse()

Reverse orientation of the line

Set overload

Set(line)

Initialize line from line.

Parameters:

Name Type Description Default
line Line2D

Line2D.

required
Set(x1, y1, x2, y2)

Set line points in world coordinate system.

Used world coordinates.

Parameters:

Name Type Description Default
x1 float

X coordinate of start point.

required
y1 float

Y coordinate of start point.

required
x2 float

X coordinate of end point.

required
y2 float

Y coordinate of end point.

required
Set(point1, point2)

Set line points in world coordinate system.

Set line from two points. Used world coordinates.

Parameters:

Name Type Description Default
point1 Point2D

Point2D start point of line.

required
point2 Point2D

Point2D end point of line.

required
Set(refPoint, point1, point2)

Set line points.

Used local coordinate system for point1 and point2. refPoint used global coordinate system.

Parameters:

Name Type Description Default
refPoint Point2D

refPoint point of line.

required
point1 Point2D

Point2D start point of line.

required
point2 Point2D

Point2D end point of line.

required

SetEndPoint(endPoint)

Set end point in world coordinate system.

Parameters:

Name Type Description Default
endPoint Point2D

New start point.

required

SetEndRelPoint(endPoint)

Set end point in local coordinate system.

Parameters:

Name Type Description Default
endPoint Point2D

New start point.

required

SetRefPoint(refPoint)

Set point in world coordinate system.

Coordinates of points will be recalculated with new point. Formula: m_Points[i] = m_RefPoint + m_Points[i] - refPoint

Parameters:

Name Type Description Default
refPoint Point2D

new point.

required

SetStartPoint(startPoint)

Set start point in world coordinate system.

Parameters:

Name Type Description Default
startPoint Point2D

New start point.

required

SetStartRelPoint(startPoint)

Set start point in local coordinate system.

Parameters:

Name Type Description Default
startPoint Point2D

New start point.

required

TrimEnd(ds)

Trim line at the end

     Start                         End
     Point                         Point
       o-----------------------------o
                             <-------+
                               ds > 0
     Result:
       o--------------------o

Parameters:

Name Type Description Default
ds float

dimension value the line is modified

required
A

value >0 shortens the line

required
A

value <0 extend the line

required
If

the line is shorten larger than its actual length a exception is throw

required

TrimStart(ds)

Trim line at the start

     Start                         End
     Point                         Point
       o-----------------------------o
       +------->
        ds > 0

     Result:
                o--------------------o

Parameters:

Name Type Description Default
ds float

dimension value the line is modified

required
A

value >0 shortens the line

required
A

value <0 extend the line

required
If

the line is shorten larger than its actual length a exception is throw

required

__eq__(line)

Comparison of lines without tolerance.

Be careful, this method work without tolerance!

Parameters:

Name Type Description Default
line Line2D

Compared line.

required

Returns:

Type Description
object

True when lines are equal, otherwise false.

__init__ overload

__init__()

Initialize

__init__(line)

Copy constructor.

Parameters:

Name Type Description Default
line Line2D

Line which will be copied.

required
__init__(line3D)

Copy constructor to convert a 3D line

Parameters:

Name Type Description Default
line3D Line3D

3D line

required
__init__(point1, point2)

Constructor.

Initialize line from two points. Reference point is initialized to [0.0, 0.0]. Used world coordinates.

Parameters:

Name Type Description Default
point1 Point2D

Point2D start point of line.

required
point2 Point2D

Point2D end point of line.

required
__init__(startPoint, vec)

Constructor.

Initialize line from point and relative vector to point. Reference point is initialized to [0.0, 0.0]. Used world coordinates.

Parameters:

Name Type Description Default
startPoint Point2D

Point2D start point of line.

required
vec Vector2D

Vector2D vector of end point relative to the point1.

required
__init__(x1, y1, x2, y2)

Constructor.

Reference point is initialized to [0.0, 0.0]. Used world coordinates.

Parameters:

Name Type Description Default
x1 float

X coordinate of start point.

required
y1 float

Y coordinate of start point.

required
x2 float

X coordinate of end point.

required
y2 float

Y coordinate of end point.

required
__init__(refPoint, point1, point2)

Constructor.

Used local coordinate system for point1 and point2. refPoint used global coordinate system.

Parameters:

Name Type Description Default
refPoint Point2D

point of line.

required
point1 Point2D

start point of line.

required
point2 Point2D

end point of line.

required

__mul__(matrix)

Matrix transformation.

Parameters:

Name Type Description Default
matrix Matrix2D

transformation matrix.

required

Returns:

Type Description
object

Line2D transformed line.

__repr__()

Convert to string