mirror of
https://github.com/CTurt/dsgmLib.git
synced 2025-06-18 22:55:33 -04:00
66 lines
2.2 KiB
C
66 lines
2.2 KiB
C
/*
|
|
Copyright (C) 2008 Alex Diener
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
warranty. In no event will the authors be held liable for any damages
|
|
arising from the use of this software.
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
including commercial applications, and to alter it and redistribute it
|
|
freely, subject to the following restrictions:
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
claim that you wrote the original software. If you use this software
|
|
in a product, an acknowledgment in the product documentation would be
|
|
appreciated but is not required.
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
misrepresented as being the original software.
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
Alex Diener adiener@sacredsoftware.net
|
|
*/
|
|
|
|
/*
|
|
Modified for dsgmLib integration, 2014
|
|
|
|
Additional help from:
|
|
elhobbs
|
|
http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q60
|
|
http://content.gpwiki.org/index.php/OpenGL%3aTutorials%3aUsing_Quaternions_to_represent_rotation#Quaternion_from_Euler_angles
|
|
|
|
Not all quaternion functionality has been implemented, only what was needed
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
typedef struct Quaternion Quaternion;
|
|
|
|
struct Quaternion {
|
|
int32 x;
|
|
int32 y;
|
|
int32 z;
|
|
int32 w;
|
|
};
|
|
|
|
void Quaternion_loadIdentity(Quaternion *quaternion);
|
|
Quaternion Quaternion_identity();
|
|
Quaternion Quaternion_withValues(int32 x, int32 y, int32 z, int32 w);
|
|
|
|
Quaternion Quaternion_fromVector(vect3D vector);
|
|
vect3D Quaternion_toVector(Quaternion quaternion);
|
|
Quaternion Quaternion_fromAxisAngle(vect3D axis, int angle);
|
|
inline Quaternion Quaternion_fromEuler(int32 roll, int32 pitch, int32 yaw);
|
|
vect3D Quaternion_toEuler(Quaternion q);
|
|
m4x4 Quaternion_toMatrix(Quaternion quaternion);
|
|
|
|
void Quaternion_multiply(Quaternion * quaternion1, Quaternion quaternion2);
|
|
Quaternion Quaternion_multiplied(Quaternion quaternion1, Quaternion quaternion2);
|
|
|
|
void Quaternion_normalize(Quaternion *quaternion);
|
|
Quaternion Quaternion_normalized(Quaternion quaternion);
|
|
|
|
Quaternion Quaternion_inverted(Quaternion quaternion);
|
|
void Quaternion_invert(Quaternion *quaternion);
|
|
|
|
vect3D Quaternion_toUpVector(Quaternion *q);
|