OK, during the last day or so I've been asking all sorts of crazy questions on the forum and geting back into my vector maths and trig from a long time ago. Anyway, I found out some useful stuff that some of you might not know, so I thought I'd post it in case someone else found it useful, and perhaps people may even come up with other useful points.

--------------------------------------------------
1) The first thing is that vector maths in all the textbooks assumes that the Y coordinate goes UP and X goes to the RIGHT. Makes sense if you think of it like a normal graph (see fig 1)
Also when measuring angles in degrees, they go ANTI-CLOCKWISE round from the Positive X axis. Thus at:
1,0 the angle is 0
0,1 the angle is 90
-1,0 the angle is -180
-1,-1 then angle is -270
This seems a bit weird if you are used to thinking of rotation as CLOCKWISE and starting from the TOP, just like how BlitzMax Rotation works (see fig 3).
--------------------------------------------------
2) On computer screens the Y coordinate points DOWN the screen as it gets bigger (See fig 2). This is the exact opposite to how the maths books depict it and thus it has a big effect on your vector maths and trigonemtry. For a start rotation is now measured CLOCKWISE, although it still starts at 0 on the Positive X axis.
--------------------------------------------------
3) Here's an example. Say I want to fire a ball in any direction based on a rotating arrow and a fixed speed, and then I want to slow it down with friction.
Well I might be rotating my arrow using BMax, so it'll range from 0 to 360 degrees CLOCKWISE measured from the TOP (the negative Y axis). So when the user clicks "Fire" we know the angle of launch. We also know the fixed speed.
Using the angle and the fixed speed we should be able to work out the X and Y components of the speed as follows:
XSpeed = BallSpeed * Cos(angle)
YSpeed = BallSpeed * Sin(angle)
BUT this won't work because that is the "normal" maths way to work out the X and Y speed which assumes the rotation starts at Positive X axis and goes ANTI-CLOCKWISE, but BlitzMax goes CLOCKWISE from the Negative Y axis if you recall.
So I now do this:
XSpeed = BallSpeed * Sin(angle)
YSpeed = BallSpeed * (0-Cos(angle))
Which takes the BMax rotation angle and gives X and Y speeds in the correct direction. I could have adjusted the angle by 90 degrees first and used a different calculation.
--------------------------------------------------
4) Here's another example. So I want to slow my ball down with friction. We I could simply multiply the X and Y speeds by an amount <1 each frame (you must not subtract friction from the X and Y as they are only components of a true Ball Speed which is at an angle!). However, I going to do it properly and reduce Ball Speed by friction and the recalculate the X and Y speeds using ArcTan.
So I get my BallSpeed and do: BallSpeed=BallSpeed - Friction
ArcTan will tell me the angle between the positive X axis and the tangent line (t) that my ball is travelling along (see fig 4).
I want to get the angle, because we know the new BallSpeed and we can use the calculations point 3 to give us the new X and Y speed components.
To make ArcTan return a valid angle you have to pass in the SLOPE of a line. This is easy, it's simply the ratio of Y/X. So I call:
Angle = ArcTan(BallYSpeed/BallXSpeed)
Woo, we've got an angle, but there's a problem, in fact there are several.
ArcTan doesn't give nice angles from 0 to 360, it gives them from -90 through 0 to 90 depending on which QUADRANT the line was in (See fig 4). I've marked the quadrants from 1-4 in roman numerals. I is the first quadrant and IV is the last.
You can see that the positive angles are opposite each other and the negative angles are opposite each other. (Note that fig 4 shows the y axis as on a Computer Screen.)
So here's some nice jiggery pokery. Lines in quadrants II and III can be considered 180 degrees away from their "proper" opposites. So if you check your line's X component and discover that it's negative, you can simply add on 180 degrees to the result. This gives you results in the range 0 to 270 from the positive X axis up to the negative Y axis (quandrants I, II, and III). Great!
But we still have -90 to 0 in quadrant IV *and* the angle starts from the positive X axis unlike BlitzMax which starts from the top. However, this can be easily fixed by adding on 90 degrees to the result. Then quadrant IV changes from negative into 0 to 90, quadrant II goes up and is now 90 to 180, quadrant III is now 180 to 270 and quadrant IV is now 270 to 360. Tada!
Now it's safe to use the resulting angle as a BlitzMax rotation if you wanted and to work out the X and Y Speeds based on the formulas in point 3.
By the way, you can also get the angle by using the Dot Product of two vectors, but that's a topic for another day.
--------------------------------------------------
I hope you enjoyed reading this. Please help me add to this if you know more cool stuff. Thanks.

--------------------------------------------------
1) The first thing is that vector maths in all the textbooks assumes that the Y coordinate goes UP and X goes to the RIGHT. Makes sense if you think of it like a normal graph (see fig 1)
Also when measuring angles in degrees, they go ANTI-CLOCKWISE round from the Positive X axis. Thus at:
1,0 the angle is 0
0,1 the angle is 90
-1,0 the angle is -180
-1,-1 then angle is -270
This seems a bit weird if you are used to thinking of rotation as CLOCKWISE and starting from the TOP, just like how BlitzMax Rotation works (see fig 3).
--------------------------------------------------
2) On computer screens the Y coordinate points DOWN the screen as it gets bigger (See fig 2). This is the exact opposite to how the maths books depict it and thus it has a big effect on your vector maths and trigonemtry. For a start rotation is now measured CLOCKWISE, although it still starts at 0 on the Positive X axis.
--------------------------------------------------
3) Here's an example. Say I want to fire a ball in any direction based on a rotating arrow and a fixed speed, and then I want to slow it down with friction.
Well I might be rotating my arrow using BMax, so it'll range from 0 to 360 degrees CLOCKWISE measured from the TOP (the negative Y axis). So when the user clicks "Fire" we know the angle of launch. We also know the fixed speed.
Using the angle and the fixed speed we should be able to work out the X and Y components of the speed as follows:
XSpeed = BallSpeed * Cos(angle)
YSpeed = BallSpeed * Sin(angle)
BUT this won't work because that is the "normal" maths way to work out the X and Y speed which assumes the rotation starts at Positive X axis and goes ANTI-CLOCKWISE, but BlitzMax goes CLOCKWISE from the Negative Y axis if you recall.
So I now do this:
XSpeed = BallSpeed * Sin(angle)
YSpeed = BallSpeed * (0-Cos(angle))
Which takes the BMax rotation angle and gives X and Y speeds in the correct direction. I could have adjusted the angle by 90 degrees first and used a different calculation.
--------------------------------------------------
4) Here's another example. So I want to slow my ball down with friction. We I could simply multiply the X and Y speeds by an amount <1 each frame (you must not subtract friction from the X and Y as they are only components of a true Ball Speed which is at an angle!). However, I going to do it properly and reduce Ball Speed by friction and the recalculate the X and Y speeds using ArcTan.
So I get my BallSpeed and do: BallSpeed=BallSpeed - Friction
ArcTan will tell me the angle between the positive X axis and the tangent line (t) that my ball is travelling along (see fig 4).
I want to get the angle, because we know the new BallSpeed and we can use the calculations point 3 to give us the new X and Y speed components.
To make ArcTan return a valid angle you have to pass in the SLOPE of a line. This is easy, it's simply the ratio of Y/X. So I call:
Angle = ArcTan(BallYSpeed/BallXSpeed)
Woo, we've got an angle, but there's a problem, in fact there are several.
ArcTan doesn't give nice angles from 0 to 360, it gives them from -90 through 0 to 90 depending on which QUADRANT the line was in (See fig 4). I've marked the quadrants from 1-4 in roman numerals. I is the first quadrant and IV is the last.
You can see that the positive angles are opposite each other and the negative angles are opposite each other. (Note that fig 4 shows the y axis as on a Computer Screen.)
So here's some nice jiggery pokery. Lines in quadrants II and III can be considered 180 degrees away from their "proper" opposites. So if you check your line's X component and discover that it's negative, you can simply add on 180 degrees to the result. This gives you results in the range 0 to 270 from the positive X axis up to the negative Y axis (quandrants I, II, and III). Great!
But we still have -90 to 0 in quadrant IV *and* the angle starts from the positive X axis unlike BlitzMax which starts from the top. However, this can be easily fixed by adding on 90 degrees to the result. Then quadrant IV changes from negative into 0 to 90, quadrant II goes up and is now 90 to 180, quadrant III is now 180 to 270 and quadrant IV is now 270 to 360. Tada!
Now it's safe to use the resulting angle as a BlitzMax rotation if you wanted and to work out the X and Y Speeds based on the formulas in point 3.
By the way, you can also get the angle by using the Dot Product of two vectors, but that's a topic for another day.
--------------------------------------------------
I hope you enjoyed reading this. Please help me add to this if you know more cool stuff. Thanks.