Vector3D
Canonical path: NemAll_Python_Geometry.Vector3D
Representation class for 3D Vector.
CrossProduct
CrossProduct(vec: Vector3D)
Cross(vector) product operator.
This is a mutator method - it changes the object, on which it is called.
For an accessor method, see Normal()
Parameters:
-
vec
(Vector3D
) –Vector(Vb).
Examples:
Calculate a cross product vector of a unit vector along X axis and another one along Y axis
DotProduct
DotProduct(vec: Vector3D) -> float
Dot(sxcalar) product.
Formula: S = Va . Vb = Va1 * Va2 + Vb1 * Vb2 Va is this Vector
Parameters:
-
vec
(Vector3D
) –Vector(Vb).
Returns:
-
float
–double.
Examples:
Calculate dot product of a unit vector along X axis and a vector perpendiular to it
Calculate dot product of the same vector and a vector parallel to it
GetCoords
GetCoords() -> tuple[float, float, float]
GetLength
GetLengthSquare
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:
-
bool
–Is zero? true/false
Normal
Cross(vector) product operator.
This is an accessor method - it returns a new vector.
For a mutator method, see CrossProduct()
Parameters:
-
vec
(Vector3D
) –Vector(Vb).
Examples:
Calculate a cross product vector of a unit vector along X axis and another one along Y axis
Normalize
overloaded
Normalize() -> eGeometryErrorCode
Normalize the vector to a unit vector
This is a mutator method - it changes the object, on which it is called. It returns only an error code.
Returns:
-
eGeometryErrorCode
–Geometry error code
Examples:
>>> vec = Vector3D(1, 1, 1)
>>> vec.Normalize()
NemAll_Python_Geometry.eGeometryErrorCode.eOK
>>> vec
Vector3D(0.577..., 0.577..., 0.577...)
Normalising a zero vector results in a geometry error
Normalize(length: float) -> eGeometryErrorCode
Normalize the vector to a defined length
This is a mutator method - it changes the object, on which it is called. It returns only an error code.
Parameters:
-
length
(float
) –new length of vector.
Returns:
-
eGeometryErrorCode
–Geometry error code
Examples:
Project
Reverse
Reverse() -> Vector3D
Compute reversed vector
Method calculate vector with reversed orientation.
Returns:
-
Vector3D
–Reversed vector
Set
overloaded
Set(vec: Vector3D)
Initialize from x,y,z coordinates.
Parameters:
-
x
(float
) –coordinate.
-
y
(float
) –coordinate.
-
z
(float
) –coordinate.
Values
Get copy of X,Y,Z coordinates as python list
Returns:
-
list[float]
–list with vector coordinates X, Y and Z
__add__
__eq__
__eq__(vec: Vector3D) -> bool
Comparison of vectors without tolerance.
Be careful, this method work without tolerance!
Parameters:
-
vec
(Vector3D
) –Compared vector.
Returns:
-
bool
–True when points are equal, otherwise false.
__iadd__
__idiv__
__idiv__(divider: float) -> Vector3D
Multiply the vector by a factor (scalar multiplication)
Parameters:
-
divider
(float
) –scaling divider
Returns:
-
Vector3D
–New vector
Examples:
__imul__
overloaded
__imul__(factor: float) -> Vector3D
Multiply the vector by a factor (scalar multiplication)
Parameters:
-
factor
(float
) –Scale factor
Returns:
-
Vector3D
–New vector
Examples:
__init__
overloaded
Initialize
__init__(vec: Vector2D)
Copy constructor.
Copy only X_COORD and Y_COORD from vector, Z_COORD is set to zero.
Parameters:
-
vec
(Vector2D
) –2D vector which will be copied to the 3D vector.
__init__(vec: Vector3D)
Constructor.
Initialize vector from single coordinates.
Parameters:
-
x
(float
) –X coordinate of vector.
-
y
(float
) –Y coordinate of vector.
-
z
(float
) –Z coordinate of vector.
__init__(endPoint: Point3D)
Create a vector from a 3D point
Parameters:
-
endPoint
(Point3D
) –End point of the vector (startpoint is 0./0./0.)
__isub__
__mul__
overloaded
__mul__(factor: float) -> Vector3D
Multiply the vector by a factor (scalar multiplication)
Parameters:
-
factor
(float
) –Scale factor
Returns:
-
Vector3D
–New vector
Examples:
__ne__
__ne__(vec: Vector3D) -> bool
Comparison of vectors without tolerance.
Be careful, this method work without tolerance!
Parameters:
-
vec
(Vector3D
) –Compared vector.
Returns:
-
bool
–True when points are not equal, otherwise false.