~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to extern/solid/include/MT/Quaternion.h

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#ifndef QUATERNION_H
25
25
#define QUATERNION_H
26
26
 
 
27
#if defined (__sgi)
 
28
#include <assert.h>
 
29
#else
27
30
#include <cassert>
 
31
#endif
28
32
 
29
33
#include "Tuple4.h"
30
34
#include "Vector3.h"
84
88
  
85
89
                Quaternion<Scalar>& operator+=(const Quaternion<Scalar>& q)
86
90
                {
87
 
                        m_co[0] += q[0]; m_co[1] += q[1]; m_co[2] += q[2]; m_co[3] += q[3];
 
91
                        this->m_co[0] += q[0]; this->m_co[1] += q[1]; this->m_co[2] += q[2]; this->m_co[3] += q[3];
88
92
                        return *this;
89
93
                }
90
94
                
91
95
                Quaternion<Scalar>& operator-=(const Quaternion<Scalar>& q) 
92
96
                {
93
 
                        m_co[0] -= q[0]; m_co[1] -= q[1]; m_co[2] -= q[2]; m_co[3] -= q[3];
 
97
                        this->m_co[0] -= q[0]; this->m_co[1] -= q[1]; this->m_co[2] -= q[2]; this->m_co[3] -= q[3];
94
98
                        return *this;
95
99
                }
96
100
 
97
101
                Quaternion<Scalar>& operator*=(const Scalar& s)
98
102
                {
99
 
                        m_co[0] *= s; m_co[1] *= s; m_co[2] *= s; m_co[3] *= s;
 
103
                        this->m_co[0] *= s; this->m_co[1] *= s; this->m_co[2] *= s; this->m_co[3] *= s;
100
104
                        return *this;
101
105
                }
102
106
                
108
112
  
109
113
                Quaternion<Scalar>& operator*=(const Quaternion<Scalar>& q)
110
114
                {
111
 
                        setValue(m_co[3] * q[0] + m_co[0] * q[3] + m_co[1] * q[2] - m_co[2] * q[1],
112
 
                                         m_co[3] * q[1] + m_co[1] * q[3] + m_co[2] * q[0] - m_co[0] * q[2],
113
 
                                         m_co[3] * q[2] + m_co[2] * q[3] + m_co[0] * q[1] - m_co[1] * q[0],
114
 
                                         m_co[3] * q[3] - m_co[0] * q[0] - m_co[1] * q[1] - m_co[2] * q[2]);
 
115
                        setValue(this->m_co[3] * q[0] + this->m_co[0] * q[3] + this->m_co[1] * q[2] - this->m_co[2] * q[1],
 
116
                                         this->m_co[3] * q[1] + this->m_co[1] * q[3] + this->m_co[2] * q[0] - this->m_co[0] * q[2],
 
117
                                         this->m_co[3] * q[2] + this->m_co[2] * q[3] + this->m_co[0] * q[1] - this->m_co[1] * q[0],
 
118
                                         this->m_co[3] * q[3] - this->m_co[0] * q[0] - this->m_co[1] * q[1] - this->m_co[2] * q[2]);
115
119
                        return *this;
116
120
                }
117
121
        
118
122
                Scalar dot(const Quaternion<Scalar>& q) const
119
123
                {
120
 
                        return m_co[0] * q[0] + m_co[1] * q[1] + m_co[2] * q[2] + m_co[3] * q[3];
 
124
                        return this->m_co[0] * q[0] + this->m_co[1] * q[1] + this->m_co[2] * q[2] + this->m_co[3] * q[3];
121
125
                }
122
126
 
123
127
                Scalar length2() const
149
153
   
150
154
                Quaternion<Scalar> conjugate() const 
151
155
                {
152
 
                        return Quaternion<Scalar>(-m_co[0], -m_co[1], -m_co[2], m_co[3]);
 
156
                        return Quaternion<Scalar>(-this->m_co[0], -this->m_co[1], -this->m_co[2], this->m_co[3]);
153
157
                }
154
158
 
155
159
                Quaternion<Scalar> inverse() const
165
169
                                Scalar d = Scalar(1.0) / Scalar_traits<Scalar>::sin(theta);
166
170
                                Scalar s0 = Scalar_traits<Scalar>::sin((Scalar(1.0) - t) * theta);
167
171
                                Scalar s1 = Scalar_traits<Scalar>::sin(t * theta);   
168
 
                                return Quaternion<Scalar>((m_co[0] * s0 + q[0] * s1) * d,
169
 
                                                                                  (m_co[1] * s0 + q[1] * s1) * d,
170
 
                                                                                  (m_co[2] * s0 + q[2] * s1) * d,
171
 
                                                                                  (m_co[3] * s0 + q[3] * s1) * d);
 
172
                                return Quaternion<Scalar>((this->m_co[0] * s0 + q[0] * s1) * d,
 
173
                                                                                  (this->m_co[1] * s0 + q[1] * s1) * d,
 
174
                                                                                  (this->m_co[2] * s0 + q[2] * s1) * d,
 
175
                                                                                  (this->m_co[3] * s0 + q[3] * s1) * d);
172
176
                        }
173
177
                        else
174
178
                        {