SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 14/08/2016, 01:19 AM   #1
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,827
Reputation: 666
Default Rotations.inc

Rotations

This include gives you the possibility to convert rotations

Installationand reference

GitHub

Download

Master
Version 2.0
Version 1.2

Last edited by Nero_3D; 22/04/2019 at 02:35 AM.
Nero_3D is offline   Reply With Quote
Old 14/08/2016, 11:11 AM   #2
PT
Godfather
 
PT's Avatar
 
Join Date: Nov 2012
Location: Portugal
Posts: 7,180
Reputation: 780
Default Re: Rotations.inc

You and the maths.. My god xd

Good work
PT is offline   Reply With Quote
Old 15/08/2016, 01:37 AM   #3
Sanady
High-roller
 
Sanady's Avatar
 
Join Date: May 2012
Location: Los Santos
Posts: 1,170
Reputation: 132
Default Re: Rotations.inc

My god, nice maths. You can really help me with exams joking but really nice maths.
__________________

Sanady is offline   Reply With Quote
Old 06/01/2017, 11:59 PM   #4
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,827
Reputation: 666
Default Re: Rotations.inc

Translation and Rotation function for RotationMatrix added

New functions
PHP Code:
// AroundRelPoint
RotMatrixMatrixAroundRelPoint(Floatmatrix1[4][4], FloatoXFloatoYFloatoZFloatmatrix2[4][4])
RotMatrixQuatAroundRelPoint(Floatmatrix[4][4], FloatoXFloatoYFloatoZFloatwFloatxFloatyFloatz)
RotMatrixEulerAroundRelPoint(Floatmatrix[4][4], FloatoXFloatoYFloatoZFloatrXFloatrYFloatrZeulermodemode euler_samp)
RotMatrixAxisAroundRelPoint(Floatmatrix1[4][4], FloatoXFloatoYFloatoZFloatangleFloataXFloataYFloataZ)
// AroundPoint
RotMatrixMatrixAroundPoint(Floatmatrix1[4][4], FloatxFloatyFloatzFloatmatrix2[4][4])
RotMatrixQuatAroundPoint(Floatmatrix[4][4], FloatxFloatyFloatzFloatwFloatqXFloatqYFloatqZ)
RotMatrixEulerAroundPoint(Floatmatrix[4][4], FloatxFloatyFloatzFloatrXFloatrYFloatrZeulermodemode euler_samp)
RotMatrixAxisAroundPoint(Floatmatrix1[4][4], FloatxFloatyFloatzFloatangleFloataXFloataYFloataZ)
// TranslateMatrix
TranslateMatrix(Floatmatrix[4][4], FloatxFloatyFloatz)
// RotateMatrix
RotateMatrixWithMatrix(Floatmatrix1[4][4], Floatmatrix2[4][4])
RotateMatrixWithQuat(Floatmatrix[4][4], FloatwFloatxFloatyFloatz)
RotateMatrixWithEuler(Floatmatrix[4][4], FloatrXFloatrYFloatrZeulermodemode euler_samp)
RotateMatrixWithAxisAngle(Floatmatrix[4][4], FloatangleFloataXFloataYFloataZ)
// GetTranslationMatrix
GetTranslationMatrix(Floatmatrix[4][4], FloatxFloatyFloatz
Nero_3D is offline   Reply With Quote
Old 06/02/2017, 06:25 PM   #5
Crayder
Banned
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,367
Reputation: 652
Default Re: Rotations.inc

Hmm... Wasn't there a lot more comments on this thread? I know I had a discussion about this include here and said how badass it was...
Crayder is offline   Reply With Quote
Old 10/02/2017, 01:37 PM   #6
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,827
Reputation: 666
Default Re: Rotations.inc

Quote:
Originally Posted by Crayder View Post
Hmm... Wasn't there a lot more comments on this thread? I know I had a discussion about this include here and said how badass it was...
Never was but thanks anyways, maybe another thread, 3DTryg from AbyssMorgan ?

I still get this feeling that this include isn't very user friendly but I am not sure how to accomplish a more compact structure within pawn
Nero_3D is offline   Reply With Quote
Old 10/02/2017, 05:09 PM   #7
Crayder
Banned
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,367
Reputation: 652
Default Re: Rotations.inc

Quote:
Originally Posted by Nero_3D View Post
Never was but thanks anyways, maybe another thread, 3DTryg from AbyssMorgan ?
YES! Lol...

Quote:
Originally Posted by Nero_3D View Post
I still get this feeling that this include isn't very user friendly but I am not sure how to accomplish a more compact structure within pawn
I think it is user friendly, but it's just not something the majority of the people here are going to use. It's extremely useful for those who know what it is though. I've already used it quite a bit.
Crayder is offline   Reply With Quote
Old 10/02/2017, 05:13 PM   #8
AbyssMorgan
High-roller
 
AbyssMorgan's Avatar
 
Join Date: Apr 2015
Location: Poland
Posts: 1,246
Reputation: 347
Default Re: Rotations.inc

3DTryg.inc partly uses rotations.inc (Internal) I suspect that this include useful for more advanced developers.
Typically create a function that is easy to use by anyone (Not including programmers from my country XD).
AbyssMorgan is offline   Reply With Quote
Old 16/06/2017, 04:44 PM   #9
ball
Huge Clucker
 
ball's Avatar
 
Join Date: Jul 2012
Location: Poznan, Poland
Posts: 281
Reputation: 33
Default Re: Rotations.inc

I am trying to create graffiti object in front of another graffiti object (graffiti tagged), but I don't know how to get position in front of object relative to object's rotation (rx, ry, rz). My actual code

Code:
new Float:lGraffitiX, Float:lGraffitiY, Float:lGraffitiZ, Float:lGraffitiRX, Float:lGraffitiRY, Float:lGraffitiRZ;
GetDynamicObjectPos(Graffiti[tagid][graffiti_object], lGraffitiX, lGraffitiY, lGraffitiZ);
GetDynamicObjectRot(Graffiti[tagid][graffiti_object], lGraffitiRX, lGraffitiRY, lGraffitiRZ);
Use(lGraffitiX, lGraffitiY, lGraffitiZ, lGraffitiRX, lGraffitiRY, lGraffitiRZ, lGraffitiX, lGraffitiY, lGraffitiZ);
Graffiti[tagid][graffiti_object_made] = CreateDynamicObject(18659, lGraffitiX, lGraffitiY, lGraffitiZ, lGraffitiRX, lGraffitiRY, lGraffitiRZ, .interiorid = 0);

Use(Float:oX, Float:oY, Float:oZ, Float:rX, Float:rY, Float:rZ, &Float:x, &Float:y, &Float:z)
{
	new 
    Float: matrix[4][4] 
; 
// Get rotation Matrix from Euler 
GetRotationMatrixFromEuler(matrix, rX, rY, rZ); 
// Rotate matrix around relative point of object 
// 0.0, 0.0, 1.0 = relative point = 1.0 above object center 
// 5.0, 0.0, 0.0 = euler rotation = 5.0 degress in rX direction 
RotMatrixEulerAroundRelPoint(matrix, 0.0, 0.0, 1.0, 5.0, 0.0, 0.0); 
// Getting relative point, 0.0, 0.0, 0.0, 1.0 = offsets x, y, z and translation 
// because we only need the translation we set, x, y, z offsets to 0.0 
MatrixRotate(matrix, 0.0, 0.0, 0.0, 1.0, oX, oY, oZ); 
x = oX;
y = oY;
z = oZ;
}
It works only with one angle, see image below. Grove tag should cover another tag. On the wall it works, but on the ground it does not. Any ideas?

https://i.imgur.com/3DXKHt7.jpg

//EDIT

Done it, I used wrong function. Working code

Code:
GetQuatFromEuler(rx, ry, rz, qw, qx, qy, qz);
QuatRotate(qw, qx, qy, qz, -0.05, 0.0, 0.0, x, y, z);
//use x, y, z
ball is offline   Reply With Quote
Old 16/06/2017, 09:43 PM   #10
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,827
Reputation: 666
Default Re: Rotations.inc

Quote:
Originally Posted by ball View Post
Done it, I used wrong function. Working code

Code:
GetQuatFromEuler(rx, ry, rz, qw, qx, qy, qz);
QuatRotate(qw, qx, qy, qz, -0.05, 0.0, 0.0, x, y, z);
//use x, y, z
That is excatly what EulerRotate does

Also one thing to note, normally +oY would be in front of a vehicle (facing north)
But for objects it matters in which direction they look without rotation (If facing North, +oY is the front, East = +oX, South = -oY, West = -oX)
Nero_3D 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Object rotations thefatshizms Scripting Help 4 21/06/2013 11:27 PM
Rotations With Quaternion BlackAtom Scripting Help 1 23/07/2012 03:28 PM
Object Rotations Arrows73 Help Archive 0 18/07/2011 07:22 PM
Rotations Problems Dragonoir Help Archive 2 03/06/2009 07:38 PM


All times are GMT. The time now is 01:38 PM.


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