Author Topic: Angles to Vectors helpp!  (Read 1145 times)

Ok
so I have a simple mod that uses angles and vectors and stupid trig
but
i have the angle, now how do i convert it to a vector so I use it to send people in that direction :c?

You could look up polar to cartesian coordinate conversion.
If no one helps you by the time I get home from class, I'll give you what I have when I did this

just for the sake of explanation
im checking if anyones within a radius of someone, then shoving them outside the circle. in a perfect line of the person in the middle.
the legs are easy, then apply pythag and then get the angle. though how do you push someone in that direction D:

If it's in radians, you can just use mSin and mCos on the angle to get the X and Y coordinates of the vector.

Blasfdjaksdfjda this looks complex. time to dive in! After I do my stuff ton of homework of course :)
If it's in radians, you can just use mSin and mCos on the angle to get the X and Y coordinates of the vector.
or if it's in degrees... mDegToRad

Ok I looked up the conversion myself and this looks familiar

Code: [Select]
x = r × cos( θ )
y = r × sin( θ )
r is the scale of the vector you want, θ is the angle (you'll need to convert it to radians)
So basically what Xalos said, just in psuedocode form
« Last Edit: October 16, 2012, 08:39:13 PM by Headcrab Zombie »

Ok I looked up the conversion myself and this looks familiar

Code: [Select]
x = r × cos( θ )
y = r × sin( θ )
r is the scale of the vector you want, θ is the angle (you'll need to convert it to radians)
So basically what Xalos said, just in psuedocode form
So for what Im doing, increasing R would increase the speed of the person when you launch him?

So for what Im doing, increasing R would increase the speed of the person when you launch him?
Yes.

Yes.
True, but increasing the scale of the vector would effectively increase the speed at which the player is launched
Ok you editted that between when I read and when I quoted

My first response was "no it's the scale" because I horribly misread.

But, if he did set r to the radius, and threw in the distance to the player, he could make it push an exact distance away from the player, which would be very cool if you ask me.

function getLaunchVector(%pos1,%pos2)
{
   %x1 = getWord(%pos1,0);
   %y1 = getWord(%pos1,1);

   %x2 = getWord(%pos2,0);
   %y2 = getWord(%pos2,1);

   %x = %x1 - %x2;
   %y = %y1 - %y2;
   %r = 10;

   %angle = mAtan(%x / %y);

   return %r * mCos(%angle) SPC %r * mSin(%angle);
}


Does that look right ;-;?
« Last Edit: October 16, 2012, 09:38:05 PM by Brian Smithers »



Remove the %h line, replace the other part with mATan(%x/%y)

Remove the %h line, replace the other part with mATan(%x/%y)
can you elaborate on that :(