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

Method rotateAboutCenter

cadquery/cq.py:1053–1085  ·  view source on GitHub ↗

Rotates all items on the stack by the specified angle, about the specified axis The center of rotation is a vector starting at the center of the object on the stack, and ended at the specified point. :param axisEndPoint: the second point of axis of rotation

(self: T, axisEndPoint: VectorLike, angleDegrees: float)

Source from the content-addressed store, hash-verified

1051 exportSVG(self, fileName)
1052
1053 def rotateAboutCenter(self: T, axisEndPoint: VectorLike, angleDegrees: float) -> T:
1054 """
1055 Rotates all items on the stack by the specified angle, about the specified axis
1056
1057 The center of rotation is a vector starting at the center of the object on the stack,
1058 and ended at the specified point.
1059
1060 :param axisEndPoint: the second point of axis of rotation
1061 :type axisEndPoint: a three-tuple in global coordinates
1062 :param angleDegrees: the rotation angle, in degrees
1063 :returns: a CQ object, with all items rotated.
1064
1065 WARNING: This version returns the same CQ object instead of a new one-- the
1066 old object is not accessible.
1067
1068 Future Enhancements:
1069 * A version of this method that returns a transformed copy, rather than modifying
1070 the originals
1071 * This method doesn't expose a very good interface, because the axis of rotation
1072 could be inconsistent between multiple objects. This is because the beginning
1073 of the axis is variable, while the end is fixed. This is fine when operating on
1074 one object, but is not cool for multiple.
1075 """
1076
1077 # center point is the first point in the vector
1078 endVec = Vector(axisEndPoint)
1079
1080 def _rot(obj):
1081 startPt = obj.Center()
1082 endPt = startPt + endVec
1083 return obj.rotate(startPt, endPt, angleDegrees)
1084
1085 return self.each(_rot, False, False)
1086
1087 def rotate(
1088 self: T,

Callers 2

testRotateAboutCenterMethod · 0.80
testEnclosureMethod · 0.80

Calls 2

eachMethod · 0.95
VectorClass · 0.85

Tested by 2

testRotateAboutCenterMethod · 0.64
testEnclosureMethod · 0.64