Vectors¶
- class py123d.geometry.Vector2D[source]¶
Class to represents 2D vectors, in x, y direction.
Example
>>> from py123d.geometry import Vector2D >>> v1 = Vector2D(3.0, 4.0) >>> v2 = Vector2D(1.0, 2.0) >>> v3 = v1 + v2 >>> v3 Vector2D(4.0, 6.0) >>> v1.array array([3., 4.]) >>> v1.magnitude 5.0
Public Data Attributes:
xThe x component of the vector.
yThe y component of the vector.
arrayThe vector as array of shape (2,), indexed by
Vector2DIndex.magnitudeThe magnitude (length) of the 2D vector.
vector_2dThe
Vector2Ditself.Inherited from
ArrayMixinarrayThe array representation of the geometric entity.
shapeReturn the shape of the array.
Public Methods:
from_array(array[, copy])Constructs a
Vector2Dfrom a numpy array of shape (2,), indexed byVector2DIndex.Inherited from
ArrayMixinfrom_array(array[, copy])Create an instance from a NumPy array.
from_list(values)Create an instance from a list of values.
tolist()Convert the array to a Python list.
to_list()Convert the array to a Python list.
copy()Return a copy of the object with a copied array.
- classmethod from_array(array, copy=True)[source]¶
Constructs a
Vector2Dfrom a numpy array of shape (2,), indexed byVector2DIndex.
- property array: ndarray[tuple[Any, ...], dtype[float64]]¶
The vector as array of shape (2,), indexed by
Vector2DIndex.
- copy()¶
Return a copy of the object with a copied array.
- Return type:
ArrayMixin
- class py123d.geometry.Vector3D[source]¶
Class to represents 3D vectors, in x, y, z direction.
Example
>>> from py123d.geometry import Vector3D >>> v1 = Vector3D(1.0, 2.0, 3.0) >>> v2 = Vector3D(4.0, 5.0, 6.0) >>> v3 = v1 + v2 >>> v3 Vector3D(5.0, 7.0, 9.0) >>> v1.array array([1., 2., 3.]) >>> v1.magnitude 3.7416573867739413
Public Data Attributes:
xThe x component of the vector.
yThe y component of the vector.
zThe z component of the vector.
arrayThe vector as array of shape (3,), indexed by
Vector3DIndex.magnitudeThe magnitude (length) of the 3D vector.
vector_3dThe
Vector3Ditself.vector_2dThe 2D vector projection (x, y) of the 3D vector.
Inherited from
ArrayMixinarrayThe array representation of the geometric entity.
shapeReturn the shape of the array.
Public Methods:
from_array(array[, copy])Constructs a
Vector3Dfrom a numpy array of shape (3,), indexed byVector3DIndex.Inherited from
ArrayMixinfrom_array(array[, copy])Create an instance from a NumPy array.
from_list(values)Create an instance from a list of values.
tolist()Convert the array to a Python list.
to_list()Convert the array to a Python list.
copy()Return a copy of the object with a copied array.
- classmethod from_array(array, copy=True)[source]¶
Constructs a
Vector3Dfrom a numpy array of shape (3,), indexed byVector3DIndex.
- property array: ndarray[tuple[Any, ...], dtype[float64]]¶
The vector as array of shape (3,), indexed by
Vector3DIndex.
- copy()¶
Return a copy of the object with a copied array.
- Return type:
ArrayMixin