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

Method rotate

cadquery/occ_impl/shapes.py:1124–1152  ·  view source on GitHub ↗

Rotates a shape around an axis. :param startVector: start point of rotation axis :type startVector: either a 3-tuple or a Vector :param endVector: end point of rotation axis :type endVector: either a 3-tuple or a Vector :param angleDegrees: angle to

(
        self: T, startVector: VectorLike, endVector: VectorLike, angleDegrees: float
    )

Source from the content-addressed store, hash-verified

1122 return self.__class__(BRepBuilderAPI_Transform(self.wrapped, Tr, True).Shape())
1123
1124 def rotate(
1125 self: T, startVector: VectorLike, endVector: VectorLike, angleDegrees: float
1126 ) -> T:
1127 """
1128 Rotates a shape around an axis.
1129
1130 :param startVector: start point of rotation axis
1131 :type startVector: either a 3-tuple or a Vector
1132 :param endVector: end point of rotation axis
1133 :type endVector: either a 3-tuple or a Vector
1134 :param angleDegrees: angle to rotate, in degrees
1135 :returns: a copy of the shape, rotated
1136 """
1137 if type(startVector) == tuple:
1138 startVector = Vector(startVector)
1139
1140 if type(endVector) == tuple:
1141 endVector = Vector(endVector)
1142
1143 Tr = gp_Trsf()
1144 Tr.SetRotation(
1145 gp_Ax1(
1146 Vector(startVector).toPnt(),
1147 (Vector(endVector) - Vector(startVector)).toDir(),
1148 ),
1149 radians(angleDegrees),
1150 )
1151
1152 return self._apply_transform(Tr)
1153
1154 def translate(self: T, vector: VectorLike) -> T:
1155 """

Callers 1

makeEllipseMethod · 0.45

Calls 4

_apply_transformMethod · 0.95
VectorClass · 0.85
toPntMethod · 0.80
toDirMethod · 0.80

Tested by

no test coverage detected