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

Method toLocalCoords

cadquery/occ_impl/geom.py:704–730  ·  view source on GitHub ↗

Project the provided coordinates onto this plane :param obj: an object or vector to convert :type vector: a vector or shape :return: an object of the same type, but converted to local coordinates Most of the time, the z-coordinate returned will be zero, because mos

(self, obj)

Source from the content-addressed store, hash-verified

702 self.origin = self.toWorldCoords((x, y))
703
704 def toLocalCoords(self, obj):
705 """Project the provided coordinates onto this plane
706
707 :param obj: an object or vector to convert
708 :type vector: a vector or shape
709 :return: an object of the same type, but converted to local coordinates
710
711
712 Most of the time, the z-coordinate returned will be zero, because most
713 operations based on a plane are all 2D. Occasionally, though, 3D
714 points outside of the current plane are transformed. One such example is
715 :py:meth:`Workplane.box`, where 3D corners of a box are transformed to
716 orient the box in space correctly.
717
718 """
719 from .shapes import Shape
720
721 if isinstance(obj, Vector):
722 return obj.transform(self.fG)
723 elif isinstance(obj, Shape):
724 return obj.transformShape(self.fG)
725 else:
726 raise ValueError(
727 "Don't know how to convert type {} to local coordinates".format(
728 type(obj)
729 )
730 )
731
732 def toWorldCoords(self, tuplePoint) -> Vector:
733 """Convert a point in local coordinates to global coordinates

Callers 10

testYZPlaneOriginsMethod · 0.95
testXYPlaneOriginsMethod · 0.95
testXZPlaneOriginsMethod · 0.95
testPlaneMethodsMethod · 0.95
_findFromPointMethod · 0.80
_findFromEdgeMethod · 0.80
_addPendingEdgeMethod · 0.80
eachMethod · 0.80
testPlaneBasicsMethod · 0.80
testOffsetPlanesMethod · 0.80

Calls 2

transformMethod · 0.80
transformShapeMethod · 0.80

Tested by 6

testYZPlaneOriginsMethod · 0.76
testXYPlaneOriginsMethod · 0.76
testXZPlaneOriginsMethod · 0.76
testPlaneMethodsMethod · 0.76
testPlaneBasicsMethod · 0.64
testOffsetPlanesMethod · 0.64