Rotate a line
I want to simulate the minute hand of a clock and am doing so by multiplying the other line vertex with the rotation matrix. Is there a simpler way e.g. rotating the actual graphic object symbolically?
I want to simulate the minute hand of a clock and am doing so by multiplying the other line vertex with the rotation matrix. Is there a simpler way e.g. rotating the actual graphic object symbolically?
This is a situation where using polar coordinates can be quite helpful. Hope the code below helps.
def sec_to_rad( n ):
theta = 2*n*pi/60
return (sin(theta),cos(theta))
sum([line([(0,0),sec_to_rad(i)],axes=False)+text("{}".format(i),sec_to_rad(i)) for i in range(60)]).show(aspect_ratio=1)
To see above in action see here.
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2015-10-06 00:28:10 +0100
Seen: 933 times
Last updated: Oct 06 '15