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();
an = (float) Math.toRadians(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));
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?