rotating a vector?

BlitzMax Forums/BlitzMax Programming/rotating a vector?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I looked up matrix multiplication since I didn't remember how to do it and Dreamora's post is useless unless you know how, and this is what I think he's telling you to do:


[ cos(angle) -sin(angle) ]
[ sin(angle) cos(angle) ]




He tells you to multiply the vector by that.

Since I can only assume that you can only multiply one matrix by another, then I'll assume that the vector would be matrix [Vx, Vy].

Now, when you multiply two matrices, you end up with a new matrix which has the same number of rows as the first one, and the same number of columns as the second.

In this case, after multiplication you would end up with a matrix with 1 row, and 2 columns. Which is the same as the vector matrix there.

You can read up on matrix multiplication here. I'm not going to try to explain it because it would take too long to try to word it in a manner which is easy to understand:

http://en.wikipedia.org/wiki/Matrix_(mathematics)

But basically, Dreamora's telling you to do this:

[vx, vy]
*
[ cos(angle) -sin(angle) ]
[ sin(angle) cos(angle) ]
=
[vx*cos(angle)+vy*sin(angle), vx*-sin(angle)+vy*cos(angle)]

So:

NewVx = vx*cos(angle) + vy*sin(angle)
NewVy = vx*-sin(angle) + vy*cos(angle)

Where angle is the change in angle you want for the vector, not the angle at which you want the vector to be. Ie, if it is at 90 degrees and you want it at 100 degrees, then angle would be 10.


I think!