# How do i get this angle??

• ### Question

• hi.

i have just coded a 360° spring with litdevs formula. QSV762

the only problem i have now is: How do i get the angle, so i you can rotate the spring to "look" thowards the axis??

i hope someone can help me here...
Live for nothing, OR CODE FOR SOMETHING!
Friday, November 27, 2009 8:05 PM

• Not absolutely certain what you want, but try:

Shapes.Rotate(Spring,theta*180/Math.Pi-90)

Note that we have to convert from radians to degrees and there is a 90deg offset between the calculated theta (X axis is theta = 0) and that used by Rotate (Y axis is 0 degrees).
• Marked as answer by Friday, November 27, 2009 8:27 PM
Friday, November 27, 2009 8:20 PM

### All replies

• Not absolutely certain what you want, but try:

Shapes.Rotate(Spring,theta*180/Math.Pi-90)

Note that we have to convert from radians to degrees and there is a 90deg offset between the calculated theta (X axis is theta = 0) and that used by Rotate (Y axis is 0 degrees).
• Marked as answer by Friday, November 27, 2009 8:27 PM
Friday, November 27, 2009 8:20 PM
• exactly! thx so much!

updated code: RBL234

btw, is this actually the way you code springs? i mean: speed = relative to distance like i did here?

Live for nothing, OR CODE FOR SOMETHING!
Friday, November 27, 2009 8:27 PM
• A spring uses Hooke's law: restoring force (acceleration) is proportional to extension (distance from equilibrium position).

You have:

Spring_Speed = (Spring_Speed*0.8)-(200 - Spring_Distance_To_Axis)*0.2

So the change in spring speed (acceleration) is proportional to extension (distance from spring centre '200').

Your spring moves like a spring because the equations are reasonable - also the car looks good - the vertical window size was a bit big for my display so I had to raise the ground to see the action.
Friday, November 27, 2009 8:37 PM
• oh. i didnt know something like Hooke's law existed..

about the car. is there a smarter solution? or is mine already fine?

woops.. sry^^

Live for nothing, OR CODE FOR SOMETHING!
Friday, November 27, 2009 8:42 PM