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

This topic is 2185 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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

Share on other sites

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)

Share on other sites

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

Share on other sites

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".

• 9
• 18
• 29
• 11
• 24