I'm using the tried and tested formula to rotate a 2D vector but it's length is decreasing each time it's calculated. Is this due to single precision float innacuracy, or is the formula wrong (got it off the net, somewhere)?
Graphics 640,480,0,2
SetBuffer BackBuffer()
origin_x = 320
origin_y = 240
vector_x# = 100
vector_y# = 0
ang# = 10
While Not KeyHit(1)
Cls
; Rotate vector by ang#.
vector_x = (vector_x * Cos(ang)) - (vector_y * Sin(ang))
vector_y = (vector_y * Cos(ang)) + (vector_x * Sin(ang))
Line origin_x, origin_y, origin_x+vector_x, origin_y+vector_y
Flip True
Wend
End
|