11"""Provides the ``Cone`` class."""
22
3+ from functools import cached_property
34
45from beartype import beartype as check_input_types
56from beartype .typing import Union
@@ -169,7 +170,7 @@ def project_point(self, point: Point3D) -> "ConeEvaluation":
169170 v = line_eval .parameter
170171
171172 cone_radius = self .radius .m + v * np .tan (self .half_angle .m )
172- point_radius = np .linalg .norm (point - line_eval .position () )
173+ point_radius = np .linalg .norm (point - line_eval .position )
173174 dist_to_cone = (point_radius - cone_radius ) * np .cos (self .half_angle .m )
174175 v += dist_to_cone * np .sin (self .half_angle .m )
175176
@@ -232,6 +233,7 @@ def parameter(self) -> ParamUV:
232233 """The parameter that the evaluation is based upon."""
233234 return self ._parameter
234235
236+ @cached_property
235237 def position (self ) -> Point3D :
236238 """
237239 The position of the evaluation.
@@ -244,9 +246,10 @@ def position(self) -> Point3D:
244246 return (
245247 self .cone .origin
246248 + self .parameter .v * self .cone .dir_z
247- + self .__radius_v () * self .__cone_normal ()
249+ + self .__radius_v * self .__cone_normal
248250 )
249251
252+ @cached_property
250253 def normal (self ) -> UnitVector3D :
251254 """
252255 The normal to the surface.
@@ -257,26 +260,30 @@ def normal(self) -> UnitVector3D:
257260 The normal unit vector to the cone at this evaluation.
258261 """
259262 return UnitVector3D (
260- self .__cone_normal () * np .cos (self .cone .half_angle .m )
263+ self .__cone_normal * np .cos (self .cone .half_angle .m )
261264 - self .cone .dir_z * np .sin (self .cone .half_angle .m )
262265 )
263266
267+ @cached_property
264268 def __radius_v (self ) -> Real :
265269 """Private radius helper method."""
266270 return self .cone .radius .m + self .parameter .v * np .tan (self .cone .half_angle .m )
267271
272+ @cached_property
268273 def __cone_normal (self ) -> Vector3D :
269274 """Private normal helper method."""
270275 return (
271276 np .cos (self .parameter .u ) * self .cone .dir_x + np .sin (self .parameter .u ) * self .cone .dir_y
272277 )
273278
279+ @cached_property
274280 def __cone_tangent (self ) -> Vector3D :
275281 """Private tangent helper method."""
276282 return (
277283 - np .sin (self .parameter .u ) * self .cone .dir_x + np .cos (self .parameter .u ) * self .cone .dir_y
278284 )
279285
286+ @cached_property
280287 def u_derivative (self ) -> Vector3D :
281288 """
282289 The first derivative with respect to u.
@@ -286,8 +293,9 @@ def u_derivative(self) -> Vector3D:
286293 Vector3D
287294 The first derivative with respect to u.
288295 """
289- return self .__radius_v () * self .__cone_tangent ()
296+ return self .__radius_v * self .__cone_tangent
290297
298+ @cached_property
291299 def v_derivative (self ) -> Vector3D :
292300 """
293301 The first derivative with respect to v.
@@ -297,8 +305,9 @@ def v_derivative(self) -> Vector3D:
297305 Vector3D
298306 The first derivative with respect to v.
299307 """
300- return self .cone .dir_z + np .tan (self .cone .half_angle .m ) * self .__cone_normal ()
308+ return self .cone .dir_z + np .tan (self .cone .half_angle .m ) * self .__cone_normal
301309
310+ @cached_property
302311 def uu_derivative (self ) -> Vector3D :
303312 """
304313 The second derivative with respect to u.
@@ -308,8 +317,9 @@ def uu_derivative(self) -> Vector3D:
308317 Vector3D
309318 The second derivative with respect to u.
310319 """
311- return - self .__radius_v () * self .__cone_normal ()
320+ return - self .__radius_v * self .__cone_normal
312321
322+ @cached_property
313323 def uv_derivative (self ) -> Vector3D :
314324 """
315325 The second derivative with respect to u and v.
@@ -319,8 +329,9 @@ def uv_derivative(self) -> Vector3D:
319329 Vector3D
320330 The second derivative with respect to u and v.
321331 """
322- return np .tan (self .cone .half_angle .m ) * self .__cone_tangent ()
332+ return np .tan (self .cone .half_angle .m ) * self .__cone_tangent
323333
334+ @cached_property
324335 def vv_derivative (self ) -> Vector3D :
325336 """
326337 The second derivative with respect to v.
@@ -332,6 +343,7 @@ def vv_derivative(self) -> Vector3D:
332343 """
333344 return Vector3D ([0 , 0 , 0 ])
334345
346+ @cached_property
335347 def min_curvature (self ) -> Real :
336348 """
337349 The minimum curvature of the cone.
@@ -343,6 +355,7 @@ def min_curvature(self) -> Real:
343355 """
344356 return 0
345357
358+ @cached_property
346359 def min_curvature_direction (self ) -> UnitVector3D :
347360 """
348361 The minimum curvature direction.
@@ -352,8 +365,9 @@ def min_curvature_direction(self) -> UnitVector3D:
352365 UnitVector3D
353366 The minimum curvature direction.
354367 """
355- return UnitVector3D (self .v_derivative () )
368+ return UnitVector3D (self .v_derivative )
356369
370+ @cached_property
357371 def max_curvature (self ) -> Real :
358372 """
359373 The maximum curvature of the cone.
@@ -363,8 +377,9 @@ def max_curvature(self) -> Real:
363377 Real
364378 The maximum curvature of the cone.
365379 """
366- return 1.0 / self .__radius_v ()
380+ return 1.0 / self .__radius_v
367381
382+ @cached_property
368383 def max_curvature_direction (self ) -> UnitVector3D :
369384 """
370385 The maximum curvature direction.
@@ -374,4 +389,4 @@ def max_curvature_direction(self) -> UnitVector3D:
374389 UnitVector3D
375390 The maximum curvature direction.
376391 """
377- return UnitVector3D (self .u_derivative () )
392+ return UnitVector3D (self .u_derivative )
0 commit comments