Rotate the Square Around Paddle 1 - Demo 13¶
Objective¶
Rotate the square around paddle1’s center.

Demo 13¶
Move the Paddles using the Keyboard¶
Keyboard Input |
Action |
---|---|
w |
Move Left Paddle Up |
s |
Move Left Paddle Down |
k |
Move Right Paddle Down |
i |
Move Right Paddle Up |
d |
Increase Left Paddle’s Rotation |
a |
Decrease Left Paddle’s Rotation |
l |
Increase Right Paddle’s Rotation |
j |
Decrease Right Paddle’s Rotation |
UP |
Move the camera up, moving the objects down |
DOWN |
Move the camera down, moving the objects up |
LEFT |
Move the camera left, moving the objects right |
RIGHT |
Move the camera right, moving the objects left |
q |
Rotate the square around its center |
e |
Rotate the square around paddle 1’s center |
Description¶
Cayley Graph¶

Demo 13¶
src/modelviewprojection/demo13.py¶
163rotation_around_paddle1: float = 0.0
Event Loop¶
src/modelviewprojection/demo13.py¶
213while not glfw.window_should_close(window):
...
src/modelviewprojection/demo13.py¶
254 glColor3f(0.0, 0.0, 1.0)
255 glBegin(GL_QUADS)
256 for ms in square:
257 ms_to_ndc: InvertibleFunction[Vector2D] = compose(
258 # camera space to NDC
259 uniform_scale(1.0 / 10.0),
260 # world space to camera space
261 inverse(translate(camera.position_ws)),
262 # model space to world space
263 compose(translate(paddle1.position),
264 rotate(paddle1.rotation)),
265 # square space to paddle 1 space
266 compose(rotate(rotation_around_paddle1),
267 translate(Vector2D(x=2.0, y=0.0)),
268 rotate(square_rotation)))
269 square_vector_ndc: Vector2D = ms_to_ndc(ms)
270 glVertex2f(square_vector_ndc.x,
271 square_vector_ndc.y)
272 glEnd()