|
21 | 21 | # SOFTWARE. |
22 | 22 | """Trimmed curve class.""" |
23 | 23 |
|
24 | | -import geomdl.operations as geomdl_operations |
| 24 | +import numpy as np |
25 | 25 | from pint import Quantity |
26 | 26 |
|
27 | 27 | from ansys.api.geometry.v0.commands_pb2 import IntersectCurvesRequest |
28 | 28 | from ansys.api.geometry.v0.commands_pb2_grpc import CommandsStub |
29 | 29 | from ansys.geometry.core.connection.client import GrpcClient |
30 | 30 | from ansys.geometry.core.connection.conversions import trimmed_curve_to_grpc_trimmed_curve |
31 | 31 | from ansys.geometry.core.errors import protect_grpc |
| 32 | +from ansys.geometry.core.math.matrix import Matrix44 |
32 | 33 | from ansys.geometry.core.math.point import Point3D |
33 | | -from ansys.geometry.core.misc.measurements import DEFAULT_UNITS |
| 34 | +from ansys.geometry.core.math.vector import Vector3D |
| 35 | +from ansys.geometry.core.misc.measurements import DEFAULT_UNITS, Angle |
34 | 36 | from ansys.geometry.core.shapes.curves.curve import Curve |
35 | 37 | from ansys.geometry.core.shapes.curves.curve_evaluation import CurveEvaluation |
36 | 38 | from ansys.geometry.core.shapes.parameterization import Interval |
@@ -154,6 +156,31 @@ def intersect_curve(self, other: "TrimmedCurve") -> list[Point3D]: |
154 | 156 | Point3D([point.x, point.y, point.z], unit=DEFAULT_UNITS.SERVER_LENGTH) |
155 | 157 | for point in res.points |
156 | 158 | ] |
| 159 | + |
| 160 | + def transformed_copy(self, matrix: Matrix44) -> "TrimmedCurve": |
| 161 | + """Return a copy of the trimmed curve transformed by the given matrix. |
| 162 | +
|
| 163 | + Parameters |
| 164 | + ---------- |
| 165 | + matrix : Matrix44 |
| 166 | + Transformation matrix to apply to the curve. |
| 167 | +
|
| 168 | + Returns |
| 169 | + ------- |
| 170 | + TrimmedCurve |
| 171 | + A new trimmed curve with the transformation applied. |
| 172 | + """ |
| 173 | + transformed_geometry = self.geometry.transformed_copy(matrix) |
| 174 | + transformed_start = self.start.transform(matrix) |
| 175 | + transformed_end = self.end.transform(matrix) |
| 176 | + |
| 177 | + return TrimmedCurve( |
| 178 | + transformed_geometry, |
| 179 | + transformed_start, |
| 180 | + transformed_end, |
| 181 | + self.interval, |
| 182 | + self.length, |
| 183 | + ) |
157 | 184 |
|
158 | 185 | def __repr__(self) -> str: |
159 | 186 | """Represent the trimmed curve as a string.""" |
|
0 commit comments