SA-MP Forums Archive
[Tutorial] Math Plugin - (some) functions explained and the awesome thing's it can do. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Math Plugin - (some) functions explained and the awesome thing's it can do. (/showthread.php?tid=276466)



Math Plugin - (some) functions explained and the awesome thing's it can do. - Kar - 13.08.2011

This tutorial is based upon JernejL's (Redshirt, The turtle lover) Math Plugin.
He basically asked me to explain the functions a little more.

https://sampforum.blast.hk/showthread.php?tid=270508
More function's explained to come.

Other functions

pawn Код:
// pure math
    native Float:FMPVecLength(Float:v1x, Float:v1y, Float:v1z); // calculates length of a simple XYZ 3d vector (FAST,less precision)
    native Float:MPDistancePointLine(Float:PointX, Float:PointY, Float:PointZ, Float:LineSx, Float:LineSy, Float:LineSz, Float:LineEx, Float:LineEy, Float:LineEz); // http://paulbourke.net/geometry/pointline/ returns super huge number 10000000 if outside of range of specified the lie segment.
    native Float:MPDotProduct(Float:v1x, Float:v1y, Float:v1z, Float:v2x, Float:v2y, Float:v2z);
    native Float:MPVecLength(Float:v1x, Float:v1y, Float:v1z); // calculates length of a simple XYZ 3d vector
    native MPCrossProduct(Float:v1x, Float:v1y, Float:v1z, Float:v2x, Float:v2y, Float:v2z, &Float:resx, &Float:resy, &Float:resz);
    native MPFNormalize(&Float:vx, &Float:vy, &Float:vz); // fast float normalization of a vector to unit-length (makes whatever vector 1.0 long, purely to preserve direction and be able to scale it controllably)
    native MPInterpolatePoint(Float:v1x, Float:v1y, Float:v1z, Float:v2x, Float:v2y, Float:v2z, &Float:resx, &Float:resy, &Float:resz, Float:distance);
Credits:

SA-MP Developers/Beta testers of course
JernejL

* To the "this is not a tutorial users", I don't care.


Re: Math Plugin - (some) functions explained and the awesome thing's it can do. - Darnell - 14.08.2011

Fucking awesome .


Re: Math Plugin - (some) functions explained and the awesome thing's it can do. - HyperZ - 14.08.2011

Great TUT.


Re: Math Plugin - (some) functions explained and the awesome thing's it can do. - dr.pepper - 14.08.2011

Turtles <3 Ok, Nice job on explaining the functions.


Re: Math Plugin - (some) functions explained and the awesome thing's it can do. - [03]Garsino - 14.08.2011

Nice tutorial.


Re: Math Plugin - (some) functions explained and the awesome thing's it can do. - cyber_punk - 18.08.2011

I am really curious to see an example of MPProjectPointOnVehicle in a comment of the code JernejL says it could be useful to find each tire proximity. Is there an easy way to find that or how about to know a player is at the trunk (boot) of a vehicle? I was looking at this earlier and it still seems like I need a massive array to store the vehicle offsets for this or am I missing something?


Re: Math Plugin - (some) functions explained and the awesome thing's it can do. - Davz*|*Criss - 18.08.2011

Awesome tutorial!


Re: Math Plugin - (some) functions explained and the awesome thing's it can do. - Kar - 20.08.2011

Quote:
Originally Posted by cyber_punk
Посмотреть сообщение
I am really curious to see an example of MPProjectPointOnVehicle in a comment of the code JernejL says it could be useful to find each tire proximity. Is there an easy way to find that or how about to know a player is at the trunk (boot) of a vehicle? I was looking at this earlier and it still seems like I need a massive array to store the vehicle offsets for this or am I missing something?
I don't exactly know how to use that function completely, but heres a good way

But as you can see it returns the x y z angles, you should experiment with it

http://forum.sa-mp.com/showthread.ph...00#post1321900

you can change this Pos[2] + 0.5 * Pos[5] to and the 0.4 to get it to the tires. simple you need getvehiclesize by RyDeR`

Might I suggest maybe -0.1 and 0.35. try those, it should work with all vehicles, just adjust it to your needs