## 12. `Xrotaround()`

: Rotation around a
point

Rotation of coordinates around a given point is the
composition of three of the basic transforms, in order
of application:

A translation that moves the given point `p`

to the origin.

A rotation around the origin.

Another translation that moves the origin back to point
`p`

.

homcoord.py

# - - - X r o t a r o u n d
def Xrotaround ( p, theta ):
'''Rotation of theta radians around point p.
'''
#-- 1 --
# [ t1 := an Xform that translates point p to the origin
# r := an Xform that rotates theta radians around the origin
# t2 := an Xform that translates the origin to point p ]
t1 = Xlate ( [ -v
for v in p.xy() ] )
r = Xrotate ( theta )
t2 = Xlate ( p.xy() )
#-- 2 --
# [ return an Xform instance representing t1, then r, then t2 ]
return t1.compose(r).compose(t2)