ARC Math

Software: Other

Avatar
Darcey, Moderator
Posted: 29 July 2011 10:25 AM   Total Posts: 209

Anyone know how to Calculate the Y coordinate of an ARC based on a variable rotation.

Central Arc Angle = 140;
Arc Radius = 10;

Angle of rotation will flow through 0 to 140, so when rotation is at n I can get y (height) of arc at that time.

Result would be something like
0,0,0,0,00,1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1,0,0,0,0,0
depending on what rotation I am on.


Basically need the Y on the arc over time (rotating 3D object) only on 0 to 140 degrees of a circle.

Trying to do this with a single equation rather than multiple equations using an if to output this value from an equation that is not even related to arc but just for simple number sequence output.


H                 70
H         35               105
H
H   0                             140
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I need the height (H) from X at 0 to 140 degrees.

Thanks

Darcey

   

Avatar
Darcey, Moderator
Posted: 29 July 2011 11:01 AM   Total Posts: 209   [ # 1 ]

http://www.allforthecode.co.uk/away3d/images/arc_attack.jpg

 

   

Avatar
Darcey, Moderator
Posted: 29 July 2011 11:18 AM   Total Posts: 209   [ # 2 ]

lol… No worries me over complicating things…

http://www.allforthecode.co.uk/away3d/images/simple.jpg

 

   

Avatar
theMightyAtom, Sr. Member
Posted: 29 July 2011 11:28 AM   Total Posts: 669   [ # 3 ]

All you need to do is plot the arc from -70 to 70 degrees.
To get the series to start at 0,0 just add an offset.


Something like:

this.addEventListener(Event.ENTER_FRAME,nextPos);
var 
angle:Number = -70;
var 
radius:Number 10;

var 
startRadians:Number = -70 * (Math.PI 180);
var 
startPosX:Number Math.sin(startRadians) * radius;  
var 
startPosY:Number Math.cos(startRadians) * radius;  

var 
radians:Number;
var 
xpos:Number;
var 
ypos:Number;

function 
nextPos(evt:Event):void{
 radians 
angle * (Math.PI 180); 
 
xpos = (Math.sin(radians) * radius) - startPosX;
 
ypos =  Math.cos(radians) * radius startPosY;
 
trace "xpos =" xpos " ypos=" ypos); 
 
angle++;
 
 if(
angle 70){
  this
.removeEventListener(Event.ENTER_FRAME,nextPos);
 
}

Well, when I say something like, I mean “tested and working” wink

 

   

Avatar
Darcey, Moderator
Posted: 29 July 2011 12:45 PM   Total Posts: 209   [ # 4 ]

Will have a tinker with that thanks.

I think I will go down the route of manually entering:

1. Work out rotation range degrees min and degrees max (facing camera) using my visual debug class.

2. Correct degrees to limit at 360 so 358, 359, 0, 1, 2, 3

3. Offset the range to ensure a value of 0 to 140 degrees is always given

4. And work an if statement to give 0,1,2,3,4,5,4,3,2,1,0 based on if > 70

Especially since the planes vector (x,y,z) doesn’t change on the change of rotationY.

http://www.allforthecode.co.uk/away3d/arc_01/index.html.
The ARC Would be the green lines

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X