MCPcopy Index your code
hub / github.com/CadQuery/cadquery / point_cost

Function point_cost

cadquery/occ_impl/solver.py:331–359  ·  view source on GitHub ↗
(
    problem,
    m1: gp_Pnt,
    m2: gp_Pnt,
    T1_0,
    R1_0,
    T2_0,
    R2_0,
    T1,
    R1,
    T2,
    R2,
    val: Optional[float] = None,
    scale: float = 1,
)

Source from the content-addressed store, hash-verified

329
330
331def point_cost(
332 problem,
333 m1: gp_Pnt,
334 m2: gp_Pnt,
335 T1_0,
336 R1_0,
337 T2_0,
338 R2_0,
339 T1,
340 R1,
341 T2,
342 R2,
343 val: Optional[float] = None,
344 scale: float = 1,
345) -> float:
346
347 val = 0 if val is None else val
348
349 m1_dm = ca.DM((m1.X(), m1.Y(), m1.Z()))
350 m2_dm = ca.DM((m2.X(), m2.Y(), m2.Z()))
351
352 dummy = (
353 Transform(m1_dm, T1_0 + T1, R1_0 + R1) - Transform(m2_dm, T2_0 + T2, R2_0 + R2)
354 ) / scale
355
356 if val == 0:
357 return ca.sumsqr(dummy)
358
359 return (ca.sumsqr(dummy) - (val / scale) ** 2) ** 2
360
361
362def axis_cost(

Callers

nothing calls this directly

Calls 1

TransformFunction · 0.85

Tested by

no test coverage detected