PDA

View Full Version : angles



Archangel
04-29-2009, 09:05 PM
How do I use them, specifically with weapons.

Show me how to fire fireballs at link please.

pkmnfrk
04-29-2009, 11:41 PM
You need my advanced math (http://armageddongames.net/forums/showthread.php?t=104621) header.


//top of your file:
import "std.zh"
import "advmath.zh"


//somewhere in your script:

//assume x and y are the current position
eweapon fb = Screen->CreateEWeapon(EW_MAGIC);
fb->X = x;
fb->Y = y;
fb->Angle = findAngle(x, y, Link->X, Link->Y);
fb->Damage = 4;
fb->Angular = true;
fb->Step = 200;
fb->UseSprite(17);

Archangel
04-30-2009, 12:29 AM
Dude, you should seriously think about updating your site and adding this too it. You've been a great help to the community as a whole. Keep up the great work.

Now I must sleep... but first. Need to reply to some stuff.

pkmnfrk
04-30-2009, 01:13 AM
Site updating will happen... eventually. I'm working on something behind the scenes to facilitate this.

Archangel
04-30-2009, 07:05 PM
Alright then, problem is that I'll have to figure out the directions for reflection.

I think I figured this out, but how are the angles measured from the default up direction.

pkmnfrk
04-30-2009, 10:01 PM
Probably clockwise. And, probably in radians, but I'm not 100% certain on that. The default trig functions work in radians.

Joe123
05-01-2009, 03:16 AM
Angles are measured clockwise from i, which is right, not up.

The default trig functions work in degrees, but the 'RadianSin' etc. trig functions work in radians.
Arctan, however, returns a number in radians.

pkmnfrk
05-01-2009, 09:07 AM
Er, yes, what he said.

Joe, one thing though. I'm curious where you got "i" from. The only definition of i I am aware of (other than as a generic looping variable) is that of the square root of -1. I've never heard of it in Trig before. Or, am I just... er, out of the loop?

Joe123
05-01-2009, 11:08 AM
Oh.

When using vectors, i (which is underlined in handwriting to differentiate from the square root of -1) is usually defined as the unit length (or speed or whatever you're working in) in the x direction, while j is the unit in the y direction.

So you can express a vector as, for example, (5i - 6j)m rather than in the form with the big brackets.


When expressing vectors in magnitude/direction (polar) form rather than the i j form (cartesian), you usually give the angle with i (which is measured clockwise from i as opposed to anticlockwise here), so I was guessing that might have some bearing on why the angles start from east rather than from north.

Archangel
05-01-2009, 12:05 PM
So, are they measured in radians or angle?

Also, how come if right is default, the fireball can be deflected if link is facing down regardless of where it hits him?

pkmnfrk
05-01-2009, 12:53 PM
Oh.

When using vectors, i (which is underlined in handwriting to differentiate from the square root of -1) is usually defined as the unit length (or speed or whatever you're working in) in the x direction, while j is the unit in the y direction.

So you can express a vector as, for example, (5i - 6j)m rather than in the form with the big brackets.


When expressing vectors in magnitude/direction (polar) form rather than the i j form (cartesian), you usually give the angle with i (which is measured clockwise from i as opposed to anticlockwise here), so I was guessing that might have some bearing on why the angles start from east rather than from north.

Ah, that makes sense! The more you know!


So, are they measured in radians or angle?

Also, how come if right is default, the fireball can be deflected if link is facing down regardless of where it hits him?

In this instance, "right is default" only applies to the fact that angle 0 points right, a fact common in most game engines.

(Proof: Sin(x) and Cos(y) are used to plot a circle. Sin(0) == 0, and Cos(0) == 1. Therefore, for angle 0, the plotted point is (0, 1))

If a weapon's Angular property is set to true, Link doesn't use the Dir property for reflection, it uses the Angle. If you stand below the shooter, and face Down, you'll most definitely get hit ;)

However, as for what Angle is measured in... I don't know. It would make more sense for them to be measured in Degrees, since that's what the basic trig functions deal with. But, ArcTan (and, by extension my atan2) deal in Radians, and those are more useful for setting a weapon's direction.

My advice is to try it both ways. See if you need to filter it with rad2deg.

Joe123
05-01-2009, 01:04 PM
So, are they measured in radians or angle?

This sentence is illogical, as you don't measure in 'radians or angle', you measure an angle in radians or degrees.
Radians is a measure of angle, not something different.

Archangel
05-01-2009, 01:27 PM
:P Smacked to the back of the head.

I take it, I can use either?

Joe123
05-01-2009, 01:48 PM
You personally can (well, I'm assuming you can), but the functions are dependant on one or the other.

To convert from radians to degrees, multiply by (180/PI). To convert back, multiply by (PI/180).

Archangel
05-01-2009, 02:53 PM
Alright then, I'll measure in degrees, but convert to radians if I have to. Which value would I use for pie?

EDIT: Never Mind, std.zh define PI as 3.1416.

Joe123
05-01-2009, 02:57 PM
Pi, not pie.
Pie is what you eat, Pi is a mathematical constant (well, technically it's a greek letter).

And you should probably use the value in std.zh, which I believe to be 3.1416 - Pi to 4 decimal places.
There's only one value for Pi (that's why it's a constant).

Just type 'PI' in when you want to use it.

lucas92
05-01-2009, 03:49 PM
So you can express a vector as, for example, (5i - 6j)m rather than in the form with the big brackets.


Haha that's what I'm seeing right now in my math courses. =P

Archangel
05-01-2009, 04:10 PM
Pi, not pie.
Pie is what you eat, Pi is a mathematical constant (well, technically it's a greek letter).

And you should probably use the value in std.zh, which I believe to be 3.1416 - Pi to 4 decimal places.
There's only one value for Pi (that's why it's a constant).

Just type 'PI' in when you want to use it.

Yeah, I discovered that later on.