A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: calculating next position within an orbit (f5)

Threaded View

  1. #1
    Senior Member
    Join Date
    Apr 2001
    Location
    Candyland
    Posts
    423

    calculating next position within an orbit (f5)

    i can´t figure out whats wrong
    i´m trying to rotate an object about the origin(x=0, y=0).

    to manage that i first tried to calculate the next x and the y coordinate for my object to move to.
    NOTE: it´s only for one quadrant (where x and y are positive)!
    Code:
    onClipEvent(load){
            // init
    	movingDegree=2;
    	_x=50;
    	_y=100;
    }
    onClipEvent(enterFrame){
            // calculating radius and angle referring to my origin
    	a = Number(_x);
    	b = Number(_y);
    	r = Math.sqrt((a*a)+(b*b));
    	Angle = Math.atan(b/a)*180/Math.PI;
            // works great so far
    
            // now i´m increasing the angle (2 degrees)
            // ... and calculate adjacent leg (nextX) and the opposite leg(nextY) that are the coordinates of my next point at the same time
    
    	nextAngle = Number(Angle+movingDegree);
    	nextX=Number(Math.cos(nextAngle)*r);
    	nextY=Number(Math.sin(nextAngle)*r);
    }
    i get a completely different result when i calculate it with my pocket calculator.
    i don´t get it.
    the file is attached.
    thankful for any help,
    k.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center