Skip to content

Vector3D

Class full path: NemAll_Python_Geometry.Vector3D

Representation class for 3D Vector.

Attributes

X: float property writable

Get the X coordinate reference.

Y: float property writable

Get the Y coordinate reference.

Z: float property writable

Get the Z coordinate reference.

Functions

CrossProduct(vec)

Cross(vector) product operator.

Formula: Va = Va x Vb Va is this Vector

Parameters:

Name Type Description Default
vec Vector3D

Vector(Vb).

required

DotProduct(vec)

Dot(sxcalar) product.

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

Parameters:

Name Type Description Default
vec Vector3D

Vector(Vb).

required

Returns:

Type Description
float

double.

GetCoords()

Get copy of X,Y,Z coordinates

Returns:

Type Description
float

tuple(X coordinate of vector,

float

Y coordinate of vector,

float

Z coordinate of vector)

GetLength()

Get vector length.

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

Returns:

Type Description
float

double.

GetLengthSquare()

Get vector length without square-root in calculation.

Returns:

Type Description
float

double.

IsZero()

Check the coords [0.0, 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:

Type Description
bool

Is zero? true/false

Normal(vec)

Does the same as Cross(vector) product but does not change the operands.

Formula: Vc = Va x Vb Va is this Vector

Parameters:

Name Type Description Default
vec Vector3D

Vector(Vb).

required

Normalize overload

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.

Returns:

Type Description
object

Geometry error code

Normalize(length)

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:

Name Type Description Default
length float

new length of vector.

required

Returns:

Type Description
object

Geometry error code

Project(vec)

Projection operator.

Formula: Vc = / . Va Va is this Vector

Parameters:

Name Type Description Default
vec Vector3D

Vector(Vb).

required

Returns:

Type Description
Vector3D

new Vector(Vc).

Reverse()

Compute reversed vector

Method calculate vector with reversed orientation.

Returns:

Type Description
Vector3D

Reversed vector

Set overload

Set(vec)

Initialize from vector 3D.

Parameters:

Name Type Description Default
vec Vector3D

Vector.

required
Set(x, y, z)

Initialize from x,y,z coordinates.

Parameters:

Name Type Description Default
x float

coordinate.

required
y float

coordinate.

required
z float

coordinate.

required
Set(startPoint, endPoint)

Initialize vector from two points.

Parameters:

Name Type Description Default
startPoint Point3D

start point of vector.

required
endPoint Point3D

end point of vector.

required

Values()

Get copy of X,Y,Z coordinates as python list

Returns:

Type Description
list[float]

X coordinate of vector.,

list[float]

Y coordinate of vector.,

list[float]

Z coordinate of vector.

__add__(vec)

Addition operator.

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

Parameters:

Name Type Description Default
vec Vector3D

Vector(Vb).

required

Returns:

Type Description
Vector3D

new Vector(Vc).

__eq__(vec)

Comparison of vectors without tolerance.

Be careful, this method work without tolerance!

Parameters:

Name Type Description Default
vec Vector3D

Compared vector.

required

Returns:

Type Description
bool

True when points are equal, otherwise false.

__iadd__(vec)

Addition assignment operator.

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

Parameters:

Name Type Description Default
vec Vector3D

Vb Vector.

required

Returns:

Type Description
Vector3D

Reference to vector.

__idiv__(divider)

Multiply the vector by a factor (scalar multiplication)

Parameters:

Name Type Description Default
divider float

scaling divider

required

Returns:

Type Description
Vector3D

New vector

__imul__ overload

__imul__(vec)

Cross(vector) product operator.

Formula: Va = Va x Vb Va is this Vector

Parameters:

Name Type Description Default
vec Vector3D

Vector(Vb).

required

Returns:

Type Description
Vector3D

Reference to the cross(vector) product of vectors.

__imul__(factor)

Multiply the vector by a factor (scalar multiplication)

Parameters:

Name Type Description Default
factor float

Scale factor

required

Returns:

Type Description
Vector3D

New vector

__imul__(matrix)

2D matrix transformation.

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

Parameters:

Name Type Description Default
matrix Matrix2D

2D transformation matrix.

required

Returns:

Type Description
Vector3D

Point.

__imul__(matrix)

3D matrix transformation.

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

Parameters:

Name Type Description Default
matrix Matrix3D

3D transformation matrix.

required

Returns:

Type Description
Vector3D

Point.

__init__ overload

__init__()

Initialize

__init__(vec)

Copy constructor.

Copy only X_COORD and Y_COORD from vector, Z_COORD is set to zero.

Parameters:

Name Type Description Default
vec Vector2D

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

required
__init__(vec)

Copy constructor.

Parameters:

Name Type Description Default
vec Vector3D

vector which will be copied.

required
__init__(x, y, z)

Constructor.

Initialize vector from single coordinates.

Parameters:

Name Type Description Default
x float

X coordinate of vector.

required
y float

Y coordinate of vector.

required
z float

Z coordinate of vector.

required
__init__(startPoint, endPoint)

Constructor.

Initialize vector from two points.

Parameters:

Name Type Description Default
startPoint Point3D

start point of vector.

required
endPoint Point3D

end point of vector.

required
__init__(endPoint)

Create a vector from a 3D point

Parameters:

Name Type Description Default
endPoint Point3D

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

required

__isub__(vec)

Subtraction assignment operator.

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

Parameters:

Name Type Description Default
vec Vector3D

Vb Vector.

required

Returns:

Type Description
Vector3D

Reference to vector.

__mul__ overload

__mul__(vec)

Cross(vector) product operator.

Formula: Vc = Va x Vb Va is this Vector

Parameters:

Name Type Description Default
vec Vector3D

Vector(Vb).

required

Returns:

Type Description
Vector3D

new Vector(Vc).

__mul__(factor)

Multiply the vector by a factor (scalar multiplication)

Parameters:

Name Type Description Default
factor float

Scale factor

required

Returns:

Type Description
Vector3D

New vector

__mul__(matrix)

2D matrix transformation.

Formula: Result = Vector(this) * matrix

Parameters:

Name Type Description Default
matrix Matrix2D

2D transformation matrix.

required

Returns:

Type Description
Vector3D

Point.

__mul__(matrix)

3D matrix transformation.

Formula: Result = Vector(this) * matrix

Parameters:

Name Type Description Default
matrix Matrix3D

3D transformation matrix.

required

Returns:

Type Description
Vector3D

Point.

__ne__(vec)

Comparison of vectors without tolerance.

Be careful, this method work without tolerance!

Parameters:

Name Type Description Default
vec Vector3D

Compared vector.

required

Returns:

Type Description
bool

True when points are not equal, otherwise false.

__repr__()

Convert to string

__sub__(vec)

Subtraction operator.

Formula: Vc = Va - Vb Va is this Vector

Parameters:

Name Type Description Default
vec Vector3D

Vector(Vb).

required

Returns:

Type Description
Vector3D

new Vector(Vc).

__truediv__(divider)

Multiply the vector by a factor (scalar multiplication)

Parameters:

Name Type Description Default
divider float

scaling divider

required

Returns:

Type Description
Vector3D

New vector