none
How do i get this angle?? RRS feed

  • 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

Answers

  • 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 Dudeson Friday, November 27, 2009 8:27 PM
    Friday, November 27, 2009 8:20 PM
    Moderator

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 Dudeson Friday, November 27, 2009 8:27 PM
    Friday, November 27, 2009 8:20 PM
    Moderator
  • 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?

    could you maybe also help with this thread: http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/b8b52fe3-d0ae-4aed-905b-9970094d638f ?
    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
    Moderator
  • 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