Skip to content

Point2D

Canonical path: NemAll_Python_Geometry.Point2D

Representation class for 2D point

To3D property

To3D: Point3D

convert to 3D3

X property writable

X: float

Get the x coordinate.

Y property writable

Y: float

Get the y coordinate.

GetCoords

GetCoords() -> tuple[float, float]

Get individual point coordinates

Returns:

  • float

    X coordinate

  • float

    Y coordinate

GetDistance

GetDistance(point: Point2D) -> float

Calculate the distance between this and a given point, according to the formula:

Parameters:

Returns:

  • float

    Distance from this point to given point

Examples:

>>> Point2D(0.0, 3.0).GetDistance(Point2D(4.0, 0.0))
5.0

IsZero

IsZero() -> bool

Check the coords [0.0,0.0].

If the coords are zero, the return value is true. If the coords aren't zero, the return value is false.

Returns:

  • bool

    bool.

Examples:

>>> Point2D(1.0, 2.0).IsZero()
False
>>> Point2D(0.0, 0.0).IsZero()
True

Set overloaded

Set(point: Point2D)

Override with another point

Parameters:

Examples:

>>> this_point = Point2D(1, 2)
>>> other_point = Point2D(3, 2)
>>> this_point.Set(other_point)
>>> this_point
Point2D(3, 2)
Set(x: float, y: float)

Override coordinates with new values

Parameters:

  • x (float) –

    coordinate.

  • y (float) –

    coordinate.

Examples:

>>> some_point = Point2D(1, 2)
>>> some_point.Set(3, 2)
>>> some_point
Point2D(3, 2)

SetX

SetX(x: float)

Set the X coordinate

Parameters:

  • x (float) –

    coordinate.

SetY

SetY(y: float)

Set the Y coordinate

Parameters:

  • y (float) –

    coordinate.

Values

Values() -> list[float]

Get copy of X,Y coordinates as python list.

Returns:

  • list[float]

    List of X,Y coordinates in exactly this order

Examples:

>>> point = Point2D(1.0, 2.0)
>>> point.Values()
[1.0, 2.0]

__add__ overloaded

__add__(point: Point2D) -> Point2D

Add a vector to the point

Parameters:

Returns:

Examples:

>>> Point2D(1.0, 2.0) + Vector2D(1.0, 2.0)
Point2D(2, 4)
__add__(vec: Vector2D) -> Point2D

Add a point to the point

Parameters:

Returns:

Examples:

>>> Point2D(1.0, 2.0) + Point2D(1.0, 2.0)
Point2D(2, 4)

__eq__

__eq__(point: Point2D) -> bool

Comparison of points without tolerance.

Be careful, this method work without tolerance!

Parameters:

  • point (Point2D) –

    Compared point.

Returns:

  • bool

    True when points are equal, otherwise false.

__iadd__

__iadd__(point: Point2D) -> Point2D

In-place point translation by a point

This is not standard math operation and is implemented only as practical use case for point moving in Allplan. In this case given operand point represent offset from Zero point. For standard move operation please use Move method with Vector2D operand.

Parameters:

Returns:

Examples:

>>> point =  Point2D(1.0, 2.0)
>>> point += Point2D(3.0, 2.0)
>>> point
Point2D(4, 4)

__init__ overloaded

__init__()

Initialize

__init__(point: Point2D)

Copy constructor.

Parameters:

  • point (Point2D) –

    Point which will be copied.

__init__(point: Point3D)

Explicit copy constructor.

Copy only X_COORD and Y_COORD from point

Parameters:

  • point (Point3D) –

    3D Point which will be copied to the 2D point.

__init__(refPoint: Point2D, point: Point2D)

Constructor.

Initialize point from point in local coordinate system. Formula: Result = refPoint + point

Parameters:

  • refPoint (Point2D) –

    Reference point.

  • point (Point2D) –

    Relative point.

__init__(x: float, y: float)

Constructor.

Initialize point from single coordinates in world coordinate system.

Parameters:

  • x (float) –

    X coordinate of point.

  • y (float) –

    Y coordinate of point.

__isub__

__isub__(point: Point2D) -> Point2D

In-place negative point translation by a point

This is not standard math operation and is implemented only as practical use case for point moving in Allplan. In this case given operand point represent offset from Zero point. For standard move operation please use Move method with Vector2D operand.

Parameters:

Returns:

Examples:

>>> point =  Point2D(1.0, 2.0)
>>> point -= Point2D(3.0, 2.0)
>>> point
Point2D(-2, 0)

__itruediv__

__itruediv__(divider: float) -> Point2D

In-place division operator for a division by a scalar.

Parameters:

  • divider (float) –

    Divider.

Returns:

Examples:

>>> point = Point2D(2.0, 4.0)
>>> point /= 2.0
>>> point
Point2D(1, 2)

__mul__

__mul__(matrix: Matrix2D) -> Point2D

Matrix transformation

Parameters:

  • matrix (Matrix2D) –

    Transformation Matrix.

Returns:

Examples:

rotation_3 is a transformation matrix that rotates by 90° around the origin.

>>> Point2D(1.0, 2.0) * rotation_3
Point2D(-2, 1)

__ne__

__ne__(point: Point2D) -> bool

Comparison of points without tolerance.

Be careful, this method works without tolerance!

Parameters:

  • point (Point2D) –

    Compared point.

Returns:

  • bool

    True when points are not equal, otherwise false.

__repr__

__repr__() -> str

Convert to string

__sub__ overloaded

__sub__(vec: Vector2D) -> Point2D

Subtract a vector from the point

Parameters:

Returns:

Examples:

>>> Point2D(1.0, 2.0) - Vector2D(1.0, 2.0)
Point2D(0, 0)
__sub__(point: Point2D) -> Point2D

Subtract a point from the point

Parameters:

Returns:

Examples:

>>> Point2D(1.0, 2.0) - Point2D(1.0, 2.0)
Point2D(0, 0)

__truediv__

__truediv__(divider: float) -> Point2D

Division by a scalar

Parameters:

  • divider (float) –

    Divider.

Returns:

Examples:

>>> Point2D(2.0, 4.0) / 2.0
Point2D(1, 2)
Placeholder