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

Function point_in_plane_cost

cadquery/occ_impl/solver.py:400–435  ·  view source on GitHub ↗
(
    problem,
    m1: gp_Pnt,
    m2: gp_Pln,
    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

398
399
400def point_in_plane_cost(
401 problem,
402 m1: gp_Pnt,
403 m2: gp_Pln,
404 T1_0,
405 R1_0,
406 T2_0,
407 R2_0,
408 T1,
409 R1,
410 T2,
411 R2,
412 val: Optional[float] = None,
413 scale: float = 1,
414) -> float:
415
416 val = 0 if val is None else val
417
418 m1_dm = ca.DM((m1.X(), m1.Y(), m1.Z()))
419
420 m2_dir = m2.Axis().Direction()
421 m2_pnt = m2.Axis().Location().Translated(val * gp_Vec(m2_dir))
422
423 m2_dir_dm = ca.DM((m2_dir.X(), m2_dir.Y(), m2_dir.Z()))
424 m2_pnt_dm = ca.DM((m2_pnt.X(), m2_pnt.Y(), m2_pnt.Z()))
425
426 dummy = (
427 ca.dot(
428 Rotate(m2_dir_dm, R2_0 + R2),
429 Transform(m2_pnt_dm, T2_0 + T2, R2_0 + R2)
430 - Transform(m1_dm, T1_0 + T1, R1_0 + R1),
431 )
432 / scale
433 )
434
435 return dummy ** 2
436
437
438def point_on_line_cost(

Callers

nothing calls this directly

Calls 3

RotateFunction · 0.85
TransformFunction · 0.85
dotMethod · 0.80

Tested by

no test coverage detected