def test_ocs_points_to_ocs(): ucs = UCS(ux=(0, 0, -1), uz=(1, 0, 0)) points = [(1, 2, 3), (4, 5, 6), (9, 8, 7)] # tests only the actual state - as it is - not granted results are correct expected = [ Vector(-1.4547842173342707, 1.6981174520612865, 3), Vector(-3.0545253372991867, 5.6275993961721635, 6), Vector(-3.8776861825487807, 11.400155694974972, 7), ] result = list(ucs.ocs_points_to_ocs(points, extrusion=Vector(2, 4, 7))) assert result == expected
def _ucs_and_ocs_transformation(self, ucs: UCS, vector_names: Sequence, angle_names: Sequence = None) -> None: """ Transforms entity for given `ucs` to the parent coordinate system (most likely the WCS). Transforms the entity vectors and angles attributes from `ucs` to the parent coordinate system. Takes established OCS by the extrusion vector :attr:`dxf.extrusion` into account. """ extrusion = self.dxf.extrusion vectors = (self.dxf.get_default(name) for name in vector_names) ocs_vectors = ucs.ocs_points_to_ocs(vectors, extrusion=extrusion) for name, value in zip(vector_names, ocs_vectors): self.dxf.set(name, value) if angle_names is not None: angles = (self.dxf.get_default(name) for name in angle_names) ocs_angles = ucs.ocs_angles_to_ocs_deg(angles=angles, extrusion=extrusion) for name, value in zip(angle_names, ocs_angles): self.dxf.set(name, value) self.dxf.extrusion = ucs.direction_to_wcs(extrusion)