• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# [SOLVED] Objects orbiting speed is bound to its distance from source

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

4 replies to this topic

### #1Sollum  Members

Posted 26 July 2013 - 02:10 PM

Good evening,

I've got stuck on simple math issue, which i don't know how to solve. Problem is with object rotation around another object (orbiting). Speed of rotation differs depending on distance from source.

        public boolean tryToFinishRotate()
{
boolean success = false;

if (Parent != null)
{
float an = RotationAngle.get();
an += RotationPerCycle.get();
RotationAngle.set(an);

float d = Distance.get();

float xp = Parent.PlacementPoint.getD1();
float yp = Parent.PlacementPoint.getD2();
float zp = Parent.PlacementPoint.getD3();
float ap = Parent.PlacementPoint.getD4();

float vx = (float) (Math.cos(an) - Math.sin(an));
float vy = (float) (Math.sin(an) + Math.cos(an));

xp += vx * d;
yp += vy * d;

PlacementPoint.set(xp, yp, zp, ap);
}
else
{
success = true;
}

return success;
}


Issue is, that both VX and VY are sort of direction vector, and by doing

X += VX * D (distance)

Y += VY * D (distance)

I am simply multiplying vector, which sort of binds orbiting speed to distance.

What i need to do is to adjust rotation angle, depending on distance from the source, but i am kinda out of ideas at this point :|

Anyone could give me some guidance?

Edited by Sollum, 28 July 2013 - 05:25 AM.

### #2Bacterius  Members

Posted 26 July 2013 - 07:16 PM

1. what are you trying to model here

2. why do you use a position/velocity approach to move your object, do you need a dynamical system or is a static, "on rails" orbiting motion fine

I'm asking because in real life, orbiting speed around a gravitational body is, in fact, bound to distance (at least in a circular orbit), and you may not be aware of this. Secondly, if you need a dynamical system, surely a position/velocity/acceleration approach would be much more flexible, otherwise you could just calculate the object's position on its orbit directly as a function of time and not have to worry about velocity at all.

So it's not clear what you are trying to do here, and giving us some more information about what you are looking for at a higher level will help us help you (and give more specific answers)

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

### #3DT....  Members

Posted 26 July 2013 - 10:32 PM

What i need to do is to adjust rotation angle, depending on distance from the source, but i am kinda out of ideas at this point :|

Anyone could give me some guidance?

http://math.tutorvista.com/geometry/arc-length-formula.html

http://www.regentsprep.org/Regents/math/algtrig/ATM1/arclengthlesson.htm

### #4Sollum  Members

Posted 27 July 2013 - 02:52 AM

1. what are you trying to model here

2. why do you use a position/velocity approach to move your object, do you need a dynamical system or is a static, "on rails" orbiting motion fine

I'm asking because in real life, orbiting speed around a gravitational body is, in fact, bound to distance (at least in a circular orbit), and you may not be aware of this. Secondly, if you need a dynamical system, surely a position/velocity/acceleration approach would be much more flexible, otherwise you could just calculate the object's position on its orbit directly as a function of time and not have to worry about velocity at all.

So it's not clear what you are trying to do here, and giving us some more information about what you are looking for at a higher level will help us help you (and give more specific answers)

1) I am trying to model proper rotation of objects around other objects

2) Frankly, no idea what should be used to achieve my goal

There are two sets of rules to object movement:

Distancing away

Rotation

My goal is to move sphere for same lenght on different distances from source.

Edit: I've made a picture of what i want to achieve

al1 - traveling distance of o2 (object 2) should always be the same, whilst distance changes from d1 to d2

o2 rotates around o1

Edited by Sollum, 27 July 2013 - 03:56 AM.

### #5Sollum  Members

Posted 28 July 2013 - 05:24 AM

After turning ON my brain and reading a bit about arc lenght, i think i've done it, but i am not entirely sure i have done it right.

        public boolean tryToFinishRotate()
{
boolean success = false;

if (Parent != null)
{
float d = Distance.get();

float an = RotationAngle.get();
if (d > 0)
an += (float) (RotationPerCycle.get() / d);
RotationAngle.set(an);

float xp = Parent.PlacementPoint.getD1();
float yp = Parent.PlacementPoint.getD2();
float zp = Parent.PlacementPoint.getD3();
float ap = Parent.PlacementPoint.getD4();

float vx = (float) (Math.cos(an) - Math.sin(an));
float vy = (float) (Math.sin(an) + Math.cos(an));

//System.out.println(vx + " " + vy);

xp += vx * d;
yp += vy * d;

PlacementPoint.set(xp, yp, zp, ap);
}
else
{
success = true;
}

return success;
}


RotationPerCycle has a different meaning now tho. Now its more like "Distance traveled per cycle".

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.