[SOLVED] How to get coordinates of point to the right of vehicle? -
gangsta15 - 28.04.2012
It is hard to explain, I've prepared some screenshotes. So, it is a geometric question. Help me please with solution of this problem. How can I get coordinates of the point to the right of vehicle, based on vehicle coordinates and other information?
P.S. Vehicle ID - 588.
Re: How to get coordinates of point to the right of vehicle? -
ViniBorn - 28.04.2012
GetVehicleZAngle
Re: How to get coordinates of point to the right of vehicle? -
gangsta15 - 28.04.2012
Quote:
Originally Posted by Viniborn
|
It returns vehicle Z rotation angle, but how can I get right point coordinates?
Re: How to get coordinates of point to the right of vehicle? -
Niko_boy - 28.04.2012
may be unsure though
u can use combination of these functions IsPlayerInVehicle GetPlayerPos then Get x y coordinate and use IsPlayerinrangeofpoint
Re: How to get coordinates of point to the right of vehicle? -
ViniBorn - 28.04.2012
The first step is to obtain the rotation.
The second is the position (X, Y, Z).
So trigonometry. Pythagoras, etc.
Re: How to get coordinates of point to the right of vehicle? -
gangsta15 - 28.04.2012
Quote:
Originally Posted by Niko_boy
may be unsure though
u can use combination of these functions IsPlayerInVehicle GetPlayerPos then Get x y coordinate and use IsPlayerinrangeofpoint
|
There is no solution in your answer) I need coordinates to create a pickup. So, if it is 0, 90, 180, 270 z angle, it is easy to get point coordinates, but I will deal with other angles.
Quote:
Originally Posted by Viniborn
So trigonometry. Pythagoras, etc.
|
This is what I'm talking about, there must be geometric solution, but I have no idea how to do this, therefore I posted this question.
AW: How to get coordinates of point to the right of vehicle? -
Nero_3D - 28.04.2012
Here an easy stock
pawn Код:
stock GetXYInDirection(& Float: X, & Float: Y, Float: Angle, Float: distance = 1.0) {
X -= (floatsin(Angle, degrees) * distance);
Y += (floatcos(Angle, degrees) * distance);
}
And how to use it in your example
pawn Код:
new
Float: X,
Float: Y,
Float: Z,
Float: A
;
GetVehiclePos(vehicleid, X, Y, Z);
GetVehicleZAngle(vehicleid, A);
GetXYInDirection(X, Y, (A - 90.0), 5.0); // (angle - 90) is the angle to the right
Re: AW: How to get coordinates of point to the right of vehicle? -
gangsta15 - 28.04.2012
Quote:
Originally Posted by Nero_3D
Here an easy stock
...
|
Thank you! Will test it.
Re: How to get coordinates of point to the right of vehicle? -
gangsta15 - 28.04.2012
Thanks again, it works fine! But can you give me theorems on which this solution is based on?
AW: How to get coordinates of point to the right of vehicle? -
Nero_3D - 28.04.2012
On the unit circle
To get to the correct x we need cos and for y we need sin
Код:
x = cos(angle)
y = sin(angle)
The only thing we need to consider in sa-mp is that 0 degrees is 90 degrees in the unit circle, also we use
Код:
x = cos(angle + 90)
y = sin(angle + 90)
Another notation for that would be
Код:
x = -sin(angle)
y = cos(angle)
In the end we just add these cordinates to our original position
Код:
x = x - sin(angle)
y = y + cos(angle)