Skip to content

Vector2D

Canonical path: NemAll_Python_Geometry.Vector2D

Representation class for 2D Vector.

To3D property writable

To3D: Vector3D

convert to 3D3

X property writable

X: float

Get the X coordinate reference.

Y property writable

Y: float

Get the Y coordinate reference.

CrossProduct

CrossProduct(vec: Vector2D) -> Vector3D

Cross(vector) product operator.

Formula: Va = Va x Vb Va is this Vector

Parameters:

Returns:

DotProduct

DotProduct(vec: Vector2D) -> float

Dot(sxcalar) product.

Formula: S = Va . Vb = Va1 * Va2 + Vb1 * Vb2 Va is this Vector

Parameters:

Returns:

  • float

    double.

GetAngle

GetAngle() -> Angle

Get vector angle.

Returns:

  • Angle

    Angle in a range <0, 2*PI> (normalized 2pi).

GetAngleSigned

GetAngleSigned() -> Angle

Get vector angle.

equivalent to zfno()

Returns:

  • Angle

    Angle in a range <-PI..0..PI>

GetCoords

GetCoords() -> tuple[float, float]

Get copy of X, Y coordinates.

Returns:

  • tuple[float, float]

    tuple(X coordinate of vector, Y coordinate of vector)

GetLength

GetLength() -> float

Get vector length.

Formula: Result(double) = ||Va|| Va is this vector

Returns:

  • float

    double.

IsZero

IsZero() -> bool

Check the coords [0.0, 0.0] (binary comparison)

Returns:

  • bool

    Is zero? true/false

Normalize overloaded

Normalize()

Normalize vector.

Formula: Vn(a1/||Va||, a2/||Va||) Va is this vector This method is checked and throwing a geometry exception when vector is zero.

Normalize(length: float)

Normalize vector to new length.

Formula: Vn(a1 * length / ||Va||, a2 * length / ||Va||) Va is this vector This method is checked and throwing a geometry exception when vector is zero.

Parameters:

  • length (float) –

    new length of vector.

Orthogonal

Orthogonal(counterClockwise: bool = True) -> Vector2D

Compute orthogonal vector

Method calculate orthogonal vector. Sample:

vec = Vector2D(100., 0) vec.Orthogonal()

vec = (0., 100.);

Parameters:

  • counterClockwise (bool, default: True ) –

    Orientation of orthogonal vector

Returns:

Reverse

Reverse() -> Vector2D

Compute reversed vector

Method calculate vector with reversed orientation.

Returns:

Set overloaded

Set(vec: Vector2D)

Initialize from vector 2D.

Parameters:

Set(x: float, y: float)

Initialize from x,y coordinates.

Parameters:

  • x (float) –

    coordinate.

  • y (float) –

    coordinate.

Set(startPoint: Point2D, endPoint: Point2D)

Initialize vector from two points.

Parameters:

  • startPoint (Point2D) –

    start point of vector.

  • endPoint (Point2D) –

    end point of vector.

Values

Values() -> list[float]

Get copy of X,Y coordinates as python list

Returns:

  • list[float]

    X coordinate of vector.,

  • list[float]

    Y coordinate of vector.

__add__

__add__(vec: Vector2D) -> Vector2D

Addition operator.

Formula: Vc = Va + Vb Va is this Vector.

Parameters:

Returns:

__eq__

__eq__(vec: Vector2D) -> bool

Comparison of vectors without tolerance.

Be careful, this method work without tolerance!

Parameters:

Returns:

  • bool

    True when points are equal, otherwise false.

__iadd__

__iadd__(vec: Vector2D) -> Vector2D

Addition assignment operator.

Formula: Va = Va + Vb Va is this Vector.

Parameters:

Returns:

__idiv__

__idiv__(divider: float) -> Vector2D

Multiply the vector by a factor (scalar multiplication)

Parameters:

  • divider (float) –

    scaling divider

Returns:

__imul__ overloaded

__imul__(matrix: Matrix2D) -> Vector2D

Matrix transformation.

Formula: Vector(this) = Vector(this) * matrix

Parameters:

  • matrix (Matrix2D) –

    Transformation matrix.

Returns:

__imul__(factor: float) -> Vector2D

Multiply the vector by a factor (scalar multiplication)

Parameters:

  • factor (float) –

    Scale factor

Returns:

__init__ overloaded

__init__()

Initialize

__init__(vec: Vector2D)

Copy constructor.

Parameters:

  • vec (Vector2D) –

    Vector which will be copied.

__init__(angle: Angle, length: float)

Constructor.

Create vector from the angle and from the length. Formula: [X_COORD, Y_COORD] = [lengthcos(angle), lengthsin(angle)]

Parameters:

  • angle (Angle) –

    base angle.

  • length (float) –

    length of vector (must be greater then zero).

__init__(x: float, y: float)

Constructor.

Initialize vector from single coordinates.

Parameters:

  • x (float) –

    X coordinate of vector.

  • y (float) –

    Y coordinate of vector.

__init__(startPoint: Point2D, endPoint: Point2D)

Constructor.

Initialize vector from two points.

Parameters:

  • startPoint (Point2D) –

    start point of vector.

  • endPoint (Point2D) –

    end point of vector.

__init__(endPoint: Point2D)

Create a vector from a 2D point

Parameters:

  • endPoint (Point2D) –

    End point of the vector (startpoint is 0./0.)

__init__(vec: Vector3D)

Copy constructor.

Copy only X_COORD and Y_COORD from vector.

Parameters:

  • vec (Vector3D) –

    2D vector which will be copied to the 3D vector.

__isub__

__isub__(vec: Vector2D) -> Vector2D

Subtraction assignment operator.

Formula: Va = Va - Vb Va is this Vector.

Parameters:

Returns:

__mul__ overloaded

__mul__(vec: Vector2D) -> Vector3D

Cross(vector) product operator.

Formula: Vc = Va x Vb Va is this Vector

Parameters:

Returns:

__mul__(matrix: Matrix2D) -> Vector2D

Matrix transformation.

Formula: Result = Vector(this) * matrix

Parameters:

  • matrix (Matrix2D) –

    Transformation matrix.

Returns:

__mul__(factor: float) -> Vector2D

Multiply the vector by a factor (scalar multiplication)

Parameters:

  • factor (float) –

    Scale factor

Returns:

__ne__

__ne__(vec: Vector2D) -> bool

Comparison of vectors without tolerance.

Be careful, this method work without tolerance!

Parameters:

Returns:

  • bool

    True when points are not equal, otherwise false.

__repr__

__repr__() -> str

Convert to string

__sub__

__sub__(vec: Vector2D) -> Vector2D

Subtraction operator.

Formula: Vc = Va - Vb Va is this Vector

Parameters:

Returns:

__truediv__

__truediv__(divider: float) -> Vector2D

Multiply the vector by a factor (scalar multiplication)

Parameters:

  • divider (float) –

    scaling divider

Returns:

Placeholder