MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / rotateXYZ

Function rotateXYZ

inprogress/rotatingcubebext.py:95–115  ·  view source on GitHub ↗
(x, y, z, ax, ay, az)

Source from the content-addressed store, hash-verified

93
94
95def rotateXYZ(x, y, z, ax, ay, az):
96 # NOTE: Rotates around the origin (0, 0, 0)
97
98 # Rotate along x axis:
99 rotatedX = x
100 rotatedY = (y * math.cos(ax)) - (z * math.sin(ax))
101 rotatedZ = (y * math.sin(ax)) + (z * math.cos(ax))
102 x, y, z = rotatedX, rotatedY, rotatedZ
103
104 # Rotate along y axis:
105 rotatedX = (z * math.sin(ay)) + (x * math.cos(ay))
106 rotatedY = y
107 rotatedZ = (z * math.cos(ay)) - (x * math.sin(ay))
108 x, y, z = rotatedX, rotatedY, rotatedZ
109
110 # Rotate along z axis:
111 rotatedX = (x * math.cos(az)) - (y * math.sin(az))
112 rotatedY = (x * math.sin(az)) + (y * math.cos(az))
113 rotatedZ = z
114
115 return (rotatedX, rotatedY, rotatedZ)
116
117
118def transformPoint(point1, point2, scalex=None, scaley=None, translatex=None, translatey=None):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected