minimal single precision rotation degradation

Post your FreeBASIC source, examples, tips and tricks here. Please don’t post code without including an explanation.
Post Reply
dafhi
Posts: 1641
Joined: Jun 04, 2005 9:51

minimal single precision rotation degradation

Post by dafhi »

new example

Code: Select all

var w = 800,  midx=w/2
var h = 600,  midy=h/2, y_invert = h-1 - midy

screenres w,h

dim as v2 p = (100,0)

'' these 3 variables double precision will keep length remarkably stable
var iangle = cdbl(3.14159/5) 'worst-case scenario i could find after minutes of searching
var cosa=cos(iangle), sina=sin(iangle)

while inkey=""
  pset (midx + p.x, y_invert - p.y)
  for i as long = 1 to 100000
  var x2=p.x
  p.x=p.x*cosa-p.y*sina
  p.y=p.y*cosa+x2*sina
  next
  sleep 1
Wend
Post Reply