MCPcopy
hub / github.com/CadQuery/cadquery / _computeXdir

Method _computeXdir

cadquery/cq.py:522–534  ·  view source on GitHub ↗

Figures out the X direction based on the given normal. :param normal: The direction that's normal to the plane. :type normal: A Vector :return A vector representing the X direction.

(normal)

Source from the content-addressed store, hash-verified

520 return abs(n0.dot(p0.sub(p1))) < self.ctx.tolerance
521
522 def _computeXdir(normal):
523 """
524 Figures out the X direction based on the given normal.
525
526 :param normal: The direction that&#x27;s normal to the plane.
527 :type normal: A Vector
528 :return A vector representing the X direction.
529 """
530 xd = Vector(0, 0, 1).cross(normal)
531 if xd.Length < self.ctx.tolerance:
532 # this face is parallel with the x-y plane, so choose x to be in global coordinates
533 xd = Vector(1, 0, 0)
534 return xd
535
536 if centerOption not in {"CenterOfMass", "ProjectedOrigin", "CenterOfBoundBox"}:
537 raise ValueError("Undefined centerOption value provided.")

Callers

nothing calls this directly

Calls 2

VectorClass · 0.85
crossMethod · 0.80

Tested by

no test coverage detected