extract transform_ocs_direction() from transform_thickness()
@@ -114,20 +114,26 @@ class OCSTransform:
transform_scale_factor = transform_length
+ def transform_ocs_direction(self, direction: Vec3) -> Vec3:
+ """Transform an OCS direction from the old OCS into the new OCS."""
+ # OCS origin is ALWAYS the WCS origin!
+ old_wcs_direction = self.old_ocs.to_wcs(direction)
+ new_wcs_direction = self.m.transform_direction(old_wcs_direction)
+ return self.new_ocs.from_wcs(new_wcs_direction)
+
def transform_thickness(self, thickness: float) -> float:
- """Transform the thickness attribute from the old OCS into the new OCS.
+ """Transform the thickness attribute of an OCS entity from the old OCS
+ into the new OCS.
Thickness is always applied in the z-axis direction of the OCS
a.k.a. extrusion vector.
"""
- old_wcs_thickness = self.old_ocs.to_wcs(Vec3(0, 0, thickness))
- new_wcs_thickness = self.m.transform_direction(old_wcs_thickness)
- new_ocs_thickness = self.new_ocs.from_wcs(new_wcs_thickness)
# Only the z-component of the thickness vector transformed into the
# new OCS is relevant for the extrusion in the direction of the new
# OCS z-axis.
# Input and output thickness can be negative!
+ new_ocs_thickness = self.transform_ocs_direction(Vec3(0, 0, thickness))
return new_ocs_thickness.z
def transform_vertex(self, vertex: "Vertex") -> Vec3:
