Advertisement

Spinning

Started by May 23, 2002 08:03 PM
12 comments, last by Mulligan 22 years, 8 months ago
Clearly, trying to re-explain myself is only digging my hole deeper and deeper. Thus.....I shall begin again.

I have a series of randomly distributed points within a circular area. Each point is a class containing a vector for position and a vector for direction. Before anything has moved, it should look similar to this:

width="424" height="314">

Each circle, excluding the center is a point, and the line represents the directional vector added to the current position. You can see how the direction of each point is perpenducular to the center, and they all point in a counter-clockwise direction.

What I can''t figure out, it how to determine the directional vector only knowing the current position. If a point was at (5,0) the directional vector would be (1,0). (It doesn''t have to be 1, but the idea is that it would be pointing strait up). If the point is at (0,4) the directional vector should be (-1,0). (Again the -1 may vary).

Remember, forget EVERYTHING i posted before, all it did was confuse everyone.(sorry)
Ah, you want the direction vectors to be at right angles to the position vectors.

If the position vector is (x,y) take the direction vector as (-y,x)
Advertisement
quote:
Original post by Mulligan

Remember, forget EVERYTHING i posted before, all it did was confuse everyone.(sorry)



Actually Mulligan, I think it was you who got confused. The answer to your question is the first thing I posted in my original response.

v   = - sin(theta)i   + cos(theta)j        

for anti-clockwise rotation...

and
v   = sin(theta)i   - cos(theta)j        

for clockwise rotation.

Since you don't wish to work in polar coordinates, I then gave the answer in Cartesian coordinates:

v   = - sin(arctan(y/x))i   + cos(arctan(y/x))j        

for anti-clockwise rotation...

and
v   = sin(arctan(y/x))i   - cos(arctan(y/x))j        

for clockwise rotation.

Of course I should have simplified this for you (sQuid did in his post, although without explaining himself)... since y=r*sin(theta) and x=r*cos(theta), we get

v   = (-yi   + xj  )/sqrt(x2 + y2) 


for anti-clockwise rotation and
v   = (yi   - xj  )/sqrt(x2 + y2) 

for clockwise rotation.

If you didn't understand why this was the answer you sought, then you should have said so, rather than suggest that I was confused. If you still don't understand I will be more than happy to explain.

Good luck with your simulation,

Timkin

[edited by - Timkin on May 27, 2002 4:28:35 AM]
quote:
Original post by sQuid
Ah, you want the direction vectors to be at right angles to the position vectors.

If the position vector is (x,y) take the direction vector as (-y,x)


Yes. You can get there by multiplying each point by the 2D rotation matrix

(0 -1)
(1 0)

To get rotations going the other way use

(0 1)
(-1 0)

instead (which gives (y, -x) follwing sQuid''s convention)
John BlackburneProgrammer, The Pitbull Syndicate

This topic is closed to new replies.

Advertisement