Question about trignometry
#1

Hello,
I would like to have some script like GetXYInFrontOfPlayer, but i'm a dumb in mathematics...

So, how can I do to put an Object in front of Player but shifted from one unit?

Here the image to understand:



I'll try something with GetXYInFrontOfPlayer, but I get a weird resultat


Sorry for english :/
Thanks anyway
Reply
#2

UP, need your help, thanks
Reply
#3

Would also be interested in knowing this. I should really learn trig - it's fucking baffling to me though.
Reply
#4

Quote:
Originally Posted by MP2
Посмотреть сообщение
Would also be interested in knowing this. I should really learn trig - it's fucking baffling to me though.
baffling? I thought it was taught in secondary education. I <3 Maths.

pawn Код:
new Float:x, Float:y, Float:z, Float:angle;
GetPlayerPos(playerid, x, y, z);
#pragma unused z
GetPlayerFacingAngle(playerid, angle);
GetXYInFrontOfPoint( x, y, angle, 1.0 );
GetXYInRightOfPoint( x, y, angle, 1.0 );

stock GetXYInFrontOfPoint( &Float: x, &Float: y, Float: angle, Float: distance ) {

   x += ( distance * floatsin( -angle, degrees ) );
   y += ( distance * floatcos( -angle, degrees ) );
}
stock GetXYInRightOfPoint( &Float: x, &Float: y, Float: angle, Float: distance ) {

    Angle -= 90.0;
    x += floatmul(floatsin(-angle, degrees), distance);
    y += floatmul(floatcos(-angle, degrees), distance);
}
Note: I didn't used 'Player' functions because it would get the angle twice which means less performance.. (lol.. I know it's not much)
Reply
#5

Exactly, it really isn't that hard if you learn with it.
The only thing I don't understand, is what does -= and += stand for/do?
Reply
#6

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
Exactly, it really isn't that hard if you learn with it.
The only thing I don't understand, is what does -= and += stand for/do?
minus / plus equal operators

e.g

new var = 0;
var = 1 + 2; // var = 3 + 0;

var equals 1 plus 2

var = 0;
var += 3;

var plus 3 and is now equals to 3;

var = 3;
var += 3;

var plus 3 and is now equals to 6;
Reply
#7

Quote:
Originally Posted by Kar
Посмотреть сообщение
baffling? I thought it was taught in secondary education. I <3 Maths.
We're not all nerds like you.







jk

I hate maths.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)