This is just off the top of my head, and it is also 4:45 AM, so please excuse me if the following makes absolutely no sense!
To start, I'll be working on only a 2D, xz plane.
First of all, you said that the rotating object will have a constant radius, and thus it will travel in a circular motion around the "black circle" (which, from now onwards I will simply call the "origin"). So, if we look at this system as a simple circle, the problem really comes down to trying to find the x,z coordinates at a certain point on the circle, so that if you wish to rotate the object around the origin, you can predict it's next position, given that you know it's "orbiting speed."
Fortunately, it shouldn't be too difficult. If we look at as a circle, then, no matter which point we pick on the circumference, if we draw a line from that point to the origin (tracing the radius to that point), we can also draw a vertical line from the point on the circumference such that it's secondary 'z-value' is equal to the 'z-value' of the origin, and a horizontal line from the origin to the secondary end-point of the vertical line. This gives us a right angle triangle.
Before I go any further, I need to state two things. First, I assume that your method will take an angle for the xz plane. Secondly, I assume this angle is between 0 - 360.
OK, now, the angle you pass in will be interpreted as the internal angle, ie the angle between the hypotenuse and the horizontal line. To get this angle, you will need to know which quadrant the point is in, I suppose, so you would have to do something like:
float[] getPositionOnCircle(float angle, float radius, float originX, float originY)
Code: Select all
int quad;
float tZ, tX, newX, newZ, tAngle;
if ( angle >= 0 && angle < 180 )
{
if (angle < 90)
{
quad = 1;
tAngle = angle;
}
else
{
quad = 2;
tAngle = 180 - angle;
}
}
else
{
if (angle <= 270)
{
quad = 3;
tAngle = abs(180-angle);
}
else
{
quad = 4;
tAngle = 360 - angle;
}
}
// Now to get the Z-Offset
tZ = radius*sin(tAngle);
// And with a little help from our friend Pythagoras...
tX = sqrt((radius^2) - (tZ^2));
// These are only Offsets though, so we need to find the actual location:
switch (quad)
{
case 1:
newX = originX+tX;
newZ = originY-tZ;
break;
case 2:
newX = originX - tX;
newZ = originY - tZ;
break;
case 3:
newX = originX - tX;
newZ = originY + tZ;
break;
case 4:
newX = originX + tX;
newZ = originY + tZ;
break;
default:
break;
}
// Now you can just put newX and newY into an array of floats and return it.
If you want to add a third dimension and also retrieve the Y value, you should be able to repeat the process nearly as it is. You will be working on a circle still, but it will be on a different plane. So you will also need to add a dimension for the angle, my suggestion would be a second parameter indicating the "y-angle." This would simply describe the angle between the origin and the point on the y axis.
Again, sorry if none of this makes sense, or if it doesn't work at all, it is way to late/early for me to be trying to do this stuff

[/code]