SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 31/05/2015, 05:41 AM   #1
codectile
Huge Clucker
 
codectile's Avatar
 
Join Date: Jul 2014
Posts: 248
Reputation: 116
Default linearMath

linearMath




Introduction

Linear mathematics plugin for sa-mp. This plugin is based upon Bullet's LinearMath library, to provide fast and efficient vector as well as quaternion math calculations. It completely utilizes, Single Instruction, Multiple Data (SIMD) method of parallel computing which makes it fast as well as efficient.


Functions

Code:
//vectors
native  AddVectors(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, &Float:x, &Float:y, &Float:z);
native  Float:DotProduct(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2);
native  CrossProduct(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, &Float:x, &Float:y, &Float:z);
native  Float:GetVectorAngle(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2);
native  Float:GetDistance(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2);
native  Float:GetMagnitude(Float:x, Float:y, Float:z);
native  GetNormalized(Float:x, Float:y, Float:z , &Float:nx, &Float:ny, &Float:nz);
native  GetClosestAxis(Float:x, Float:y, Float:z);
native  GetFurthestAxis(Float:x, Float:y, Float:z);
native  RotateVector(Float:x, Float:y, Float:z, Float:ax, Float:ay, Float:az, Float:angle, &Float:rx, &Float:ry, &Float:rz);
native  GetReflectedVector(Float:x, Float:y, Float:z, Float:nx, Float:ny, Float:nz, &Float:rx, &Float:ry, &Float:rz);

//quaternions
native  Float:GetQuaternionAngle(Float:x, Float:y, Float:z, Float:w);
native  GetAxisOfRotation(Float:x, Float:y, Float:z, Float:w, &Float:x1, &Float:y1, &Float:z1);
native  Float:DotProductQuaternion(Float:x1, Float:y1, Float:z1, Float:w1, Float:x2, Float:y2, Float:z2, Float:w2);
native  Float:GetQuaternionMagnitude(Float:x, Float:y, Float:z, Float:w);
native  Float:GetInverseQuaternion(Float:x, Float:y, Float:z, Float:w, &Float:ix, &Float:iy, &Float:iz, &Float:iw);

Documentation and Download

https://github.com/codectile/linearMath

Note: Now there is a support for Linux systems. But the .so library won't be updated, to use the updated library, compile it your favorable OS.

Last edited by codectile; 04/06/2015 at 03:24 PM. Reason: colours
codectile is offline   Reply With Quote
Old 31/05/2015, 05:44 AM   #2
iWhite
Big Clucker
 
Join Date: May 2012
Posts: 176
Reputation: 18
Default Re: linearMath

Could you give me an example, where I could use this? Because I think you don't need these kind of math plugins to create a good server.
iWhite is offline   Reply With Quote
Old 31/05/2015, 05:55 AM   #3
codectile
Huge Clucker
 
codectile's Avatar
 
Join Date: Jul 2014
Posts: 248
Reputation: 116
Default Re: linearMath

@iWhite: If you cannot find any use of this, that's good but that does not means that other community members will not find it useful .
codectile is offline   Reply With Quote
Old 31/05/2015, 08:14 AM   #4
BigETI
Banned
 
Join Date: Mar 2010
Location: Germany
Posts: 1,046
Reputation: 359
Default AW: linearMath

The code in "core.cpp" could have been written inside "linear.cpp", because you do not need to declare functions to use them just once.
Also some functions and declarations/definitions from "core.h" can be then written inside "linear.cpp", so you would only have left "#include <header file>"s there. By the way there is no "./LinearMath/" path in your repository.
BigETI is offline   Reply With Quote
Old 31/05/2015, 08:28 AM   #5
codectile
Huge Clucker
 
codectile's Avatar
 
Join Date: Jul 2014
Posts: 248
Reputation: 116
Default Re: linearMath

@BigETI: I forgot to mention that I am quite new to c/c++ as well as plugin development. I'll look into this.

EDIT: Cleaned up.

Last edited by codectile; 31/05/2015 at 10:11 AM.
codectile is offline   Reply With Quote
Old 31/05/2015, 01:37 PM   #6
Ritzy2K
High-roller
 
Ritzy2K's Avatar
 
Join Date: Jun 2014
Location: India
Posts: 1,547
Reputation: 170
Default Re: linearMath

well, it can be used to script speed boost? tho there's already ways...but this can be with direction?

ill check this out at night...
m studying, sneaked out here :3
__________________
Ritzy2K is offline   Reply With Quote
Old 03/06/2015, 09:12 AM   #7
codectile
Huge Clucker
 
codectile's Avatar
 
Join Date: Jul 2014
Posts: 248
Reputation: 116
Default Re: linearMath

@[ND]xXZeusXx.: If you want to script a speed boost feature then you are good to go. The main purpose of this plugin is to provide fast and efficient mathematical calculations by making use of parallel computing.
codectile is offline   Reply With Quote
Old 04/06/2015, 02:02 AM   #8
Crayder
Banned
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,324
Reputation: 652
Default Re: linearMath

Nice use of the bullet library, I think you should continue porting bullet functions in this plugin. Bullet physics has so many uses that could be VERY helpful in SA-MP development. This 'linearMath' plugin alone is plentiful for many things yes, and I am not complaining. I'd like to see some physics calculations added to this such as trajectory path function, reflections, and more. Bullet physics is meant for these type of uses!
Crayder is offline   Reply With Quote
Old 04/06/2015, 05:18 AM   #9
codectile
Huge Clucker
 
codectile's Avatar
 
Join Date: Jul 2014
Posts: 248
Reputation: 116
Default Re: linearMath

I already thought of it. But, it will not be implemented into this plugin.
codectile is offline   Reply With Quote
Old 04/06/2015, 03:09 PM   #10
Rancho
Big Clucker
 
Join Date: Jun 2012
Posts: 83
Reputation: 60
Default Re: linearMath

Linux version; look attachment.
Also requested merge pull.
Attached Files
File Type: zip linear.so.zip (9.2 KB, 1 views)
Rancho is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 05:47 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.