| 1 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 2 |
|
| 3 |
from Metadata import export, constmethod |
| 4 |
from PyObjectBase import PyObjectBase |
| 5 |
from Axis import Axis as AxisPy |
| 6 |
from Vector import Vector |
| 7 |
from Placement import Placement |
| 8 |
from Rotation import Rotation |
| 9 |
from typing import Union |
| 10 |
|
| 11 |
@export( |
| 12 |
Constructor=True, |
| 13 |
Delete=True, |
| 14 |
) |
| 15 |
class CoordinateSystem(PyObjectBase): |
| 16 |
""" |
| 17 |
Base.CoordinateSystem class. |
| 18 |
|
| 19 |
An orthonormal right-handed coordinate system in 3D space. |
| 20 |
|
| 21 |
CoordinateSystem() |
| 22 |
Empty constructor. |
| 23 |
|
| 24 |
Author: Juergen Riegel ([email protected]) |
| 25 |
Licence: LGPL |
| 26 |
""" |
| 27 |
|
| 28 |
Axis: AxisPy = None |
| 29 |
"""Set or get axis.""" |
| 30 |
|
| 31 |
XDirection: Vector = None |
| 32 |
"""Set or get X-direction.""" |
| 33 |
|
| 34 |
YDirection: Vector = None |
| 35 |
"""Set or get Y-direction.""" |
| 36 |
|
| 37 |
ZDirection: Vector = None |
| 38 |
"""Set or get Z-direction.""" |
| 39 |
|
| 40 |
Position: Vector = None |
| 41 |
"""Set or get position.""" |
| 42 |
|
| 43 |
def setAxes(self, axis: Union[AxisPy, Vector], xDir: Vector) -> None: |
| 44 |
""" |
| 45 |
setAxes(axis, xDir) -> None |
| 46 |
|
| 47 |
Set axis or Z-direction, and X-direction. |
| 48 |
The X-direction is determined from the orthonormal compononent of `xDir` |
| 49 |
with respect to `axis` direction. |
| 50 |
|
| 51 |
axis : Base.Axis, Base.Vector |
| 52 |
xDir : Base.Vector |
| 53 |
""" |
| 54 |
... |
| 55 |
|
| 56 |
@constmethod |
| 57 |
def displacement(self, coordSystem2: "CoordinateSystem") -> Placement: |
| 58 |
""" |
| 59 |
displacement(coordSystem2) -> Base.Placement |
| 60 |
|
| 61 |
Computes the placement from this to the passed coordinate system `coordSystem2`. |
| 62 |
|
| 63 |
coordSystem2 : Base.CoordinateSystem |
| 64 |
""" |
| 65 |
... |
| 66 |
|
| 67 |
def transformTo(self, vector: Vector) -> Vector: |
| 68 |
""" |
| 69 |
transformTo(vector) -> Base.Vector |
| 70 |
|
| 71 |
Computes the coordinates of the point in coordinates of this coordinate system. |
| 72 |
|
| 73 |
vector : Base.Vector |
| 74 |
""" |
| 75 |
... |
| 76 |
|
| 77 |
def transform(self, trans: Union[Rotation, Placement]) -> None: |
| 78 |
""" |
| 79 |
transform(trans) -> None |
| 80 |
|
| 81 |
Applies a transformation on this coordinate system. |
| 82 |
|
| 83 |
trans : Base.Rotation, Base.Placement |
| 84 |
""" |
| 85 |
... |
| 86 |
|
| 87 |
def setPlacement(self, placement: Placement) -> None: |
| 88 |
""" |
| 89 |
setPlacement(placement) -> None |
| 90 |
|
| 91 |
Set placement to the coordinate system. |
| 92 |
|
| 93 |
placement : Base.Placement |
| 94 |
""" |
| 95 |
... |