Spinning
If I have 10 points at random locations within a circle (which are stars) and each star is a class, of which contains a vector for direction. I want all the stars to be spinning in the same direction, so how do i determine what the vector should be?
If the stars are rotating about a fixed axis in a circular orbit then the velocity vector will be orthogonal (at right angles) to the radius vector (from the axis of rotation to the star). If the star has polar coordinates (r,theta) then the velocity vector will be directed along the unit vector
for anti-clockwise rotation... and
for clockwise rotation.
The magnitude of the velocity (speed) will be a function of the radius. If you want all of the stars to orbit at the same angular rate, given by w (radians per second), then the tangential speed is given by
and so the velocity is given by
with the appropriate choice of v for the direction desired.
Good luck,
Timkin
v = - sin(theta) i + cos(theta)j
for anti-clockwise rotation... and
v = sin(theta) i - cos(theta)j
for clockwise rotation.
The magnitude of the velocity (speed) will be a function of the radius. If you want all of the stars to orbit at the same angular rate, given by w (radians per second), then the tangential speed is given by
V = r*w
and so the velocity is given by
V = r*w*v
with the appropriate choice of v for the direction desired.
Good luck,
Timkin
I do appreciate the detailed (and correct) response, but I''m not using polar coordinates. Is there another using plain x,y,z coords?
...
Okay, in this case, you will probably want each star to have the same speed huh?
You need to use "corner speed". Just determine the amount of degrees-per-second that a star should move.
Then, determine the current distance between the center and the star, determine a new position that lies the same distance away from the center, but that has a corner of "corner speed * time-in-seconds" with the original line... That is your new position.
Okay, in this case, you will probably want each star to have the same speed huh?
You need to use "corner speed". Just determine the amount of degrees-per-second that a star should move.
Then, determine the current distance between the center and the star, determine a new position that lies the same distance away from the center, but that has a corner of "corner speed * time-in-seconds" with the original line... That is your new position.
quote:
Original post by Mulligan
I do appreciate the detailed (and correct) response, but I'm not using polar coordinates. Is there another using plain x,y,z coords?
Yes. Use the simple tranformation from Cartesian to polar coordinates, then substitute these into the equations I gave you.
theta = arctan(y/x)
r = sqrt(x2 + y2)
Hence
V = sqrt(x2 + y2)*w*v
where
v = +/-(sin(arctan(y/x))i -cos(arctan(y/x))j )
...depending on rotation direction, as discussed earlier.
Timkin
[edited by - Timkin on May 25, 2002 12:03:17 AM]
I hate to keep asking questions when someone spends so much time writing a detailed response, but I''m still a bit confused.
I''ll begin by explaining in greater detail what I''m after. Every star is not rotating in a permanant fixed orbit. Every star is acted upon by gravity formulas etc. All I need is an initial vector specifying a direction for each star to begin in. The end result. If it was all in one function it would look like this
VECTOR vStartingPosition( 3.0f, 2.5f );
VECTOR vDirection = GetInitialDirection( vStartingPosition );
So simply put, I need to know how to write the GetInitialDirection function.
I''ll begin by explaining in greater detail what I''m after. Every star is not rotating in a permanant fixed orbit. Every star is acted upon by gravity formulas etc. All I need is an initial vector specifying a direction for each star to begin in. The end result. If it was all in one function it would look like this
VECTOR vStartingPosition( 3.0f, 2.5f );
VECTOR vDirection = GetInitialDirection( vStartingPosition );
So simply put, I need to know how to write the GetInitialDirection function.
quote:
Original post by Mulligan
I''ll begin by explaining in greater detail what I''m after. Every star is not rotating in a permanant fixed orbit. Every star is acted upon by gravity formulas etc. All I need is an initial vector specifying a direction for each star to begin in.
It''s still not clear what you''re after. What do you mean by gravity formula? Is each star''s gravity affecting every other star (if so, you''re in for some interesting maths)? Or is each star under the gravitational influence of some central body like a black hole? What do you mean by "etc?"
In either case, to specify the initial setup you''re likely to need to initial position, initial velocity, and mass of each star.
Once you''re clear on what it is you''re doing it might be easier to help

Don''t worry about anything but the directional vector, that''s all I wan''t, nothing more. Don''t worry about the gravity stuff, I can do all that. I only said that to point out that the stars won''t be on a fixed axis, but nevermind that, it doesn''t concern my question at all.
quote:
Original post by Mulligan
Don''t worry about anything but the directional vector,
In WHAT direction??? You can start the star moving in any direction you like. You simply haven''t given enough information for us to go on!
As for using gravity to move all of your stars, you have one of two situations:
a) all stars attract each other; or,
b) all stars are attracted to a central gravitational source.
If it''s the former, give up now. Since the 3-body problem is not analytically solvable, then you''re not going to get very far with 1011 stars (the average number of stars in a galaxy)!!! You could simulate it numerically, but it won''t be stable without some serious damping of the orbits... which is just a fudge.
If b) is the case, then the stars will all share a common axis of rotation, even if they are in a decaying orbit! In which case, the above mathematics describes their motion. You can add a decay or growth rate in the orbital distance by setting dr/dt to be non-zero.
You should write out clearly the problem that you are trying to solve... or the scenario that you are trying to simulate. Put every conceivable piece of information about the system on paper. Then if you have problems working out how to do bits of the computation, ask us and please provide the details from your system outline!
Regards,
Timkin
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement