Ask Your Question
0

Rotate a line

asked 2015-10-05 17:28:10 -0500

dyfroedd gravatar image

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?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-10-05 22:26:01 -0500

fidbc gravatar image

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.

edit flag offensive delete link more

Comments

Hey - Thanks so much for taking the time to answer. Nice one-liner too. Gratefully.

dyfroedd gravatar imagedyfroedd ( 2015-10-06 14:04:11 -0500 )edit

@dyfroedd: you are welcome. You can also mark my answer as accepted too if it did respond your question ;-)

fidbc gravatar imagefidbc ( 2015-10-06 14:30:23 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2015-10-05 17:28:10 -0500

Seen: 212 times

Last updated: Oct 05 '15