tensorbay.geometry.vector¶
Vector, Vector2D, Vector3D.
Vector
is the base class of Vector2D
and Vector3D
. It contains the
coordinates of a 2D vector or a 3D vector.
Vector2D
contains the coordinates of a 2D vector, extending Vector
.
Vector3D
contains the coordinates of a 3D vector, extending Vector
.
- class tensorbay.geometry.vector.Vector(x: float, y: float, z: Optional[float] = None)[source]¶
Bases:
tensorbay.utility.user.UserSequence
[float
]This class defines the basic concept of Vector.
Vector
contains the coordinates of a 2D vector or a 3D vector.- Parameters
x – The x coordinate of the vector.
y – The y coordinate of the vector.
z – The z coordinate of the vector.
Examples
>>> Vector(1, 2) Vector2D(1, 2)
>>> Vector(1, 2, 3) Vector3D(1, 2, 3)
- static loads(contents: Dict[str, float]) Union[tensorbay.geometry.vector.Vector2D, tensorbay.geometry.vector.Vector3D] [source]¶
Loads a
Vector
from a dict containing coordinates of the vector.- Parameters
contents – A dict containing coordinates of the vector.
- Returns
Examples
>>> contents = {"x": 1.0, "y": 2.0} >>> Vector.loads(contents) Vector2D(1.0, 2.0)
>>> contents = {"x": 1.0, "y": 2.0, "z": 3.0} >>> Vector.loads(contents) Vector3D(1.0, 2.0, 3.0)
- class tensorbay.geometry.vector.Vector2D(*args: float, **kwargs: float)[source]¶
Bases:
tensorbay.utility.user.UserSequence
[float
]This class defines the concept of Vector2D.
Vector2D
contains the coordinates of a 2D vector.- Parameters
x – The x coordinate of the 2D vector.
y – The y coordinate of the 2D vector.
Examples
>>> Vector2D(1, 2) Vector2D(1, 2)
- classmethod loads(contents: Dict[str, float]) tensorbay.geometry.vector._V2 [source]¶
Load a
Vector2D
object from a dict containing coordinates of a 2D vector.- Parameters
contents – A dict containing coordinates of a 2D vector.
- Returns
The loaded
Vector2D
object.
Examples
>>> contents = {"x": 1.0, "y": 2.0} >>> Vector2D.loads(contents) Vector2D(1.0, 2.0)
- property x: float¶
Return the x coordinate of the vector.
- Returns
X coordinate in float type.
Examples
>>> vector_2d = Vector2D(1, 2) >>> vector_2d.x 1
- property y: float¶
Return the y coordinate of the vector.
- Returns
Y coordinate in float type.
Examples
>>> vector_2d = Vector2D(1, 2) >>> vector_2d.y 2
- class tensorbay.geometry.vector.Vector3D(*args: float, **kwargs: float)[source]¶
Bases:
tensorbay.utility.user.UserSequence
[float
]This class defines the concept of Vector3D.
Vector3D
contains the coordinates of a 3D Vector.- Parameters
x – The x coordinate of the 3D vector.
y – The y coordinate of the 3D vector.
z – The z coordinate of the 3D vector.
Examples
>>> Vector3D(1, 2, 3) Vector3D(1, 2, 3)
- classmethod loads(contents: Dict[str, float]) tensorbay.geometry.vector._V3 [source]¶
Load a
Vector3D
object from a dict containing coordinates of a 3D vector.- Parameters
contents – A dict contains coordinates of a 3D vector.
- Returns
The loaded
Vector3D
object.
Examples
>>> contents = {"x": 1.0, "y": 2.0, "z": 3.0} >>> Vector3D.loads(contents) Vector3D(1.0, 2.0, 3.0)
- property x: float¶
Return the x coordinate of the vector.
- Returns
X coordinate in float type.
Examples
>>> vector_3d = Vector3D(1, 2, 3) >>> vector_3d.x 1
- property y: float¶
Return the y coordinate of the vector.
- Returns
Y coordinate in float type.
Examples
>>> vector_3d = Vector3D(1, 2, 3) >>> vector_3d.y 2
- property z: float¶
Return the z coordinate of the vector.
- Returns
Z coordinate in float type.
Examples
>>> vector_3d = Vector3D(1, 2, 3) >>> vector_3d.z 3