Move to the points of an (tilted) oval?

Mick Collins mickclns at mac.com
Sat Dec 19 18:09:55 EST 2009


Here is a modification of Jacques Hausser's handler to allow an oval  
(ellipse) tilted by thetaDeg degrees and repeating once or many times  
(or 4000000000 for forever, around 125 years if you wanna get picky)

on dotest
    put 30 into stepSize
    repeat with i = 0 to 360 step stepSize
       Orbite the long name of grc "laGrc", 130, 40, 250, 250, i, 1
    end repeat
end dotest


command Orbite theObject, ax,bx,centerX,centerY,thetaDeg,nRepeat
    --  theObject: long name of the object to be rotated (so you can  
use any kind of object)
    --  ax,bx: half length  of the horizontal and the vertical axes  
of the orbite (if equal, the move will be circular)
    --  centerX,centerY: center of rotation
    put thetaDeg *pi/180 into thetaRad
    put cos(thetaRad) into cosT
    put sin(thetaRad) into sinT
    repeat nRepeat times
       if the mouse is down then exit repeat -- or any other exit test
       repeat with i = 0 to 90
          put round(ax*cos(4*i*pi/180)*cosT-bx*sin(4*i*pi/180)*sinT) 
+centerx, round(bx*sin(4*i*pi/180)*cosT+ax*cos(4*i*pi/180)*sinT) +  
centery into laloc
          set the loc of theobject to laloc
          wait 5 millisecond -- can be tuned for speed and softness  
of the move
       end repeat
    end repeat
end Orbite




More information about the use-livecode mailing list