source: NonGTP/FCollada/FMath/FMQuaternion.h @ 964

Revision 964, 2.8 KB checked in by igarcia, 18 years ago (diff)
Line 
1/*
2        Copyright (C) 2005-2006 Feeling Software Inc.
3        MIT License: http://www.opensource.org/licenses/mit-license.php
4*/
5
6/**
7        @file FMQuaternion.h
8        The file containing the class for quaternions.
9*/
10
11#ifndef _FM_QUATERNION_H_
12#define _FM_QUATERNION_H_
13
14/**
15        A quaternion.
16        Not used within FCollada
17       
18        [Glaforte 03-08-2006] VERY EXPERIMENTAL CODE: DON'T USE.
19
20        @ingroup FMath
21*/
22class FCOLLADA_EXPORT FMQuaternion
23{
24public:
25        float x;        /**< The i component. */
26        float y;        /**< The j component. */
27        float z;        /**< The k component. */
28        float w;        /**< The scalar component. */
29
30        #ifndef _DEBUG
31        /**
32         * Creates an empty FMQuaternion.
33         *
34         * The default values are non deterministic.
35         */
36        FMQuaternion() {}
37        #else
38        FMQuaternion() { x = 123456789.0f; y = 123456789.0f; z = 123456789.0f; w = 123456789.0f; }
39        #endif
40
41        /**
42         * Creates the FMQuaternion with the given component values.
43         *
44         * @param _x The i component.
45         * @param _y The j component.
46         * @param _z The k component.
47         * @param _w The scalar component.
48         */
49        FMQuaternion(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; }
50
51        /**
52         * Creates the FMQuaternion from a given axis and angle of rotation.
53         *
54         * @param axis The axis of rotation.
55         * @param angle The angle of rotation in radians.
56         */
57        FMQuaternion(const FMVector3& axis, float angle);
58
59        /**
60         * Get this FMQuaternion as an array of \c floats.
61         *
62         * @return The \c float array.
63         */
64        inline operator float*() { return &x; }
65
66        /**
67         * Get this FMQuaternion as an array of \c floats.
68         *
69         * @return The \c float array.
70         */
71        inline operator const float*() const { return &x; }
72
73        /**
74         * Assign this FMQuaternion to the given \c float array.
75         *
76         * Assigns each coordinate of this FMQuaternion to the elements in the
77         * \c float array. The first element to the i component, the second to the
78         * j, the third to the k, and the forth to the scalar. It returns this
79         * FMQuaternion.
80         *
81         * @param v The \c float array to assign with.
82         * @return This FMQuaternion.
83         */
84        inline FMQuaternion& operator =(const float* v) { x = *v; y = *(v + 1); z = *(v + 2); w = *(v + 3); return *this; }
85
86        /**
87         * Applys quaternion multiplication of the given FMQuaternion with this
88         * FMQuaternion and returns the value.
89         *
90         * @param q The FMQuaternion multiply with.
91         * @return The resulting FMQuaternion.
92         */
93        FMQuaternion operator*(const FMQuaternion& q) const;
94
95        /**
96         * Get the FMQuaternion representation of the Euler rotation angles.
97         *
98         * @param _x The rotation about the x-axis (roll), in radians.
99         * @param _y The rotation about the y-axis (pitch), in radians.
100         * @param _z The rotation about the z-axis (yaw), in radians.
101         */
102        static FMQuaternion EulerRotationQuaternion(float _x, float _y, float _z);
103};
104
105#endif // _FM_QUATERNION_H_
Note: See TracBrowser for help on using the repository browser.