MathFu
An open source project by FPL.
 All Classes Namespaces Files Functions Variables Typedefs Friends Groups Pages
constants.h
Go to the documentation of this file.
1 /*
2 * Copyright 2014 Google Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #ifndef MATHFU_CONSTANTS_H
17 #define MATHFU_CONSTANTS_H
18 
19 #include "mathfu/matrix.h"
20 #include "mathfu/quaternion.h"
21 #include "mathfu/vector.h"
22 
23 namespace mathfu {
24 
25 /// @file mathfu/constants.h
26 /// @brief Vector constants for specific dimensions.
27 /// @addtogroup mathfu_constants
28 ///
29 /// It is preferable to use these constants rather than constructing them
30 /// when they're required. Construction most-likely slower than loading them
31 /// from memory.
32 /// <p>
33 /// For example, the following:<br>
34 /// <code>
35 /// lookat = mat4::LookAt(target, position, mathfu::kAxisY3f);
36 /// </code>
37 /// <br>is preferable to:<br>
38 /// <code>
39 /// lookat = mat4::LookAt(target, position,
40 /// mathfu::Vector<float, 3>(0.0f, 1.0f, 0.0f));
41 /// </code>
42 /// <br> in terms of efficiency and in addition to resulting in more concise
43 /// code.
44 /// </p>
45 ///
46 /// Depending on your linker's sophistication and settings, these constants may
47 /// be duplicated in every compilation unit in which they're used. However,
48 /// most linkers should be able to detect and eliminate this duplication.
49 
50 /// @addtogroup mathfu_constants
51 /// @{
52 
53 /// 2-dimensional <code>float</code> Vector of zeros.
54 static const Vector<float, 2> kZeros2f(0.0f, 0.0f);
55 /// 2-dimensional <code>float</code> Vector of ones.
56 static const Vector<float, 2> kOnes2f(1.0f, 1.0f);
57 /// 2-dimensional <code>float</code> unit Vector pointing along the X axis.
58 static const Vector<float, 2> kAxisX2f(1.0f, 0.0f);
59 /// 2-dimensional <code>float</code> unit Vector pointing along the Y axis.
60 static const Vector<float, 2> kAxisY2f(0.0f, 1.0f);
61 
62 /// 3-dimensional <code>float</code> Vector of zeros.
63 static const Vector<float, 3> kZeros3f(0.0f, 0.0f, 0.0f);
64 /// 3-dimensional <code>float</code> Vector of ones.
65 static const Vector<float, 3> kOnes3f(1.0f, 1.0f, 1.0f);
66 /// 3-dimensional <code>float</code> unit Vector pointing along the X axis.
67 static const Vector<float, 3> kAxisX3f(1.0f, 0.0f, 0.0f);
68 /// 3-dimensional <code>float</code> unit Vector pointing along the Y axis.
69 static const Vector<float, 3> kAxisY3f(0.0f, 1.0f, 0.0f);
70 /// 3-dimensional <code>float</code> unit Vector pointing along the Z axis.
71 static const Vector<float, 3> kAxisZ3f(0.0f, 0.0f, 1.0f);
72 
73 /// 4-dimensional <code>float</code> Vector of zeros.
74 static const Vector<float, 4> kZeros4f(0.0f, 0.0f, 0.0f, 0.0f);
75 /// 4-dimensional <code>float</code> Vector of ones.
76 static const Vector<float, 4> kOnes4f(1.0f, 1.0f, 1.0f, 1.0f);
77 /// 4-dimensional <code>float</code> unit Vector pointing along the X axis.
78 static const Vector<float, 4> kAxisX4f(1.0f, 0.0f, 0.0f, 0.0f);
79 /// 4-dimensional <code>float</code> unit Vector pointing along the Y axis.
80 static const Vector<float, 4> kAxisY4f(0.0f, 1.0f, 0.0f, 0.0f);
81 /// 4-dimensional <code>float</code> unit Vector pointing along the Z axis.
82 static const Vector<float, 4> kAxisZ4f(0.0f, 0.0f, 1.0f, 0.0f);
83 /// 4-dimensional <code>float</code> unit Vector pointing along the W axis.
84 static const Vector<float, 4> kAxisW4f(0.0f, 0.0f, 0.0f, 1.0f);
85 
86 /// 2-dimensional <code>double</code> Vector of zeros.
87 static const Vector<double, 2> kZeros2d(0.0, 0.0);
88 /// 2-dimensional <code>double</code> Vector of ones.
89 static const Vector<double, 2> kOnes2d(1.0, 1.0);
90 /// 2-dimensional <code>double</code> unit Vector pointing along the X axis.
91 static const Vector<double, 2> kAxisX2d(1.0, 0.0);
92 /// 2-dimensional <code>double</code> unit Vector pointing along the Y axis.
93 static const Vector<double, 2> kAxisY2d(0.0, 1.0);
94 
95 /// 3-dimensional <code>double</code> Vector of zeros.
96 static const Vector<double, 3> kZeros3d(0.0, 0.0, 0.0);
97 /// 3-dimensional <code>double</code> Vector of ones.
98 static const Vector<double, 3> kOnes3d(1.0, 1.0, 1.0);
99 /// 3-dimensional <code>double</code> unit Vector pointing along the X axis.
100 static const Vector<double, 3> kAxisX3d(1.0, 0.0, 0.0);
101 /// 3-dimensional <code>double</code> unit Vector pointing along the Y axis.
102 static const Vector<double, 3> kAxisY3d(0.0, 1.0, 0.0);
103 /// 3-dimensional <code>double</code> unit Vector pointing along the Z axis.
104 static const Vector<double, 3> kAxisZ3d(0.0, 0.0, 1.0);
105 
106 /// 4-dimensional <code>double</code> Vector of zeros.
107 static const Vector<double, 4> kZeros4d(0.0, 0.0, 0.0, 0.0);
108 /// 4-dimensional <code>double</code> Vector of ones.
109 static const Vector<double, 4> kOnes4d(1.0, 1.0, 1.0, 1.0);
110 /// 4-dimensional <code>double</code> unit Vector pointing along the X axis.
111 static const Vector<double, 4> kAxisX4d(1.0, 0.0, 0.0, 0.0);
112 /// 4-dimensional <code>double</code> unit Vector pointing along the Y axis.
113 static const Vector<double, 4> kAxisY4d(0.0, 1.0, 0.0, 0.0);
114 /// 4-dimensional <code>double</code> unit Vector pointing along the Z axis.
115 static const Vector<double, 4> kAxisZ4d(0.0, 0.0, 1.0, 0.0);
116 /// 4-dimensional <code>double</code> unit Vector pointing along the W axis.
117 static const Vector<double, 4> kAxisW4d(0.0, 0.0, 0.0, 1.0);
118 
119 /// 2-dimensional <code>int</code> Vector of zeros.
120 static const Vector<int, 2> kOnes2i(1, 1);
121 /// 2-dimensional <code>int</code> Vector of ones.
122 static const Vector<int, 2> kZeros2i(0, 0);
123 /// 2-dimensional <code>int</code> unit Vector pointing along the X axis.
124 static const Vector<int, 2> kAxisX2i(1, 0);
125 /// 2-dimensional <code>int</code> unit Vector pointing along the Y axis.
126 static const Vector<int, 2> kAxisY2i(0, 1);
127 
128 /// 3-dimensional <code>int</code> Vector of zeros.
129 static const Vector<int, 3> kZeros3i(0, 0, 0);
130 /// 3-dimensional <code>int</code> Vector of ones.
131 static const Vector<int, 3> kOnes3i(1, 1, 1);
132 /// 3-dimensional <code>int</code> unit Vector pointing along the X axis.
133 static const Vector<int, 3> kAxisX3i(1, 0, 0);
134 /// 3-dimensional <code>int</code> unit Vector pointing along the Y axis.
135 static const Vector<int, 3> kAxisY3i(0, 1, 0);
136 /// 3-dimensional <code>int</code> unit Vector pointing along the Z axis.
137 static const Vector<int, 3> kAxisZ3i(0, 0, 1);
138 
139 /// 4-dimensional <code>int</code> Vector of zeros.
140 static const Vector<int, 4> kZeros4i(0, 0, 0, 0);
141 /// 4-dimensional <code>int</code> Vector of ones.
142 static const Vector<int, 4> kOnes4i(1, 1, 1 ,1);
143 /// 4-dimensional <code>int</code> unit Vector pointing along the X axis.
144 static const Vector<int, 4> kAxisX4i(1, 0, 0, 0);
145 /// 4-dimensional <code>int</code> unit Vector pointing along the Z axis.
146 static const Vector<int, 4> kAxisY4i(0, 1, 0, 0);
147 /// 4-dimensional <code>int</code> unit Vector pointing along the Y axis.
148 static const Vector<int, 4> kAxisZ4i(0, 0, 1, 0);
149 /// 4-dimensional <code>int</code> unit Vector pointing along the W axis.
150 static const Vector<int, 4> kAxisW4i(0, 0, 0, 1);
151 
152 /// Quaternion Identity
153 static const Quaternion<float> kQuatIdentityf(1.0f, 0.0f, 0.0f, 0.0f);
154 /// Quaternion Identity
155 static const Quaternion<double> kQuatIdentityd(1.0, 0.0, 0.0, 0.0);
156 
157 // An AffineTransform versoin of the mat4 Identity matrix.
158 static const AffineTransform kAffineIdentity(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
159  0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
160  0.0f);
161 /// @}
162 
163 } // namespace mathfu
164 
165 #endif // MATHFU_CONSTANTS_H
static const Vector< int, 3 > kZeros3i(0, 0, 0)
3-dimensional int Vector of zeros.
static const Vector< int, 4 > kAxisZ4i(0, 0, 1, 0)
4-dimensional int unit Vector pointing along the Y axis.
static const Vector< double, 2 > kOnes2d(1.0, 1.0)
2-dimensional double Vector of ones.
static const Vector< int, 2 > kOnes2i(1, 1)
2-dimensional int Vector of zeros.
static const Vector< float, 3 > kAxisZ3f(0.0f, 0.0f, 1.0f)
3-dimensional float unit Vector pointing along the Z axis.
static const Vector< double, 3 > kAxisZ3d(0.0, 0.0, 1.0)
3-dimensional double unit Vector pointing along the Z axis.
Vector of d elements with type T.
Definition: vector.h:63
static const Vector< double, 2 > kAxisX2d(1.0, 0.0)
2-dimensional double unit Vector pointing along the X axis.
static const Vector< double, 3 > kOnes3d(1.0, 1.0, 1.0)
3-dimensional double Vector of ones.
static const Vector< int, 2 > kAxisY2i(0, 1)
2-dimensional int unit Vector pointing along the Y axis.
static const Quaternion< double > kQuatIdentityd(1.0, 0.0, 0.0, 0.0)
Quaternion Identity.
static const Vector< float, 2 > kAxisX2f(1.0f, 0.0f)
2-dimensional float unit Vector pointing along the X axis.
static const Vector< float, 4 > kZeros4f(0.0f, 0.0f, 0.0f, 0.0f)
4-dimensional float Vector of zeros.
static const Vector< int, 3 > kOnes3i(1, 1, 1)
3-dimensional int Vector of ones.
static const Vector< float, 4 > kAxisW4f(0.0f, 0.0f, 0.0f, 1.0f)
4-dimensional float unit Vector pointing along the W axis.
Matrix stores a set of "rows" by "columns" elements of type T and provides functions that operate on ...
Definition: matrix.h:147
static const Vector< double, 3 > kAxisY3d(0.0, 1.0, 0.0)
3-dimensional double unit Vector pointing along the Y axis.
static const Vector< double, 4 > kAxisZ4d(0.0, 0.0, 1.0, 0.0)
4-dimensional double unit Vector pointing along the Z axis.
static const Vector< float, 3 > kZeros3f(0.0f, 0.0f, 0.0f)
3-dimensional float Vector of zeros.
static const Vector< int, 3 > kAxisZ3i(0, 0, 1)
3-dimensional int unit Vector pointing along the Z axis.
static const Vector< float, 4 > kAxisZ4f(0.0f, 0.0f, 1.0f, 0.0f)
4-dimensional float unit Vector pointing along the Z axis.
static const Vector< double, 2 > kAxisY2d(0.0, 1.0)
2-dimensional double unit Vector pointing along the Y axis.
static const Vector< int, 4 > kZeros4i(0, 0, 0, 0)
4-dimensional int Vector of zeros.
static const Vector< float, 2 > kAxisY2f(0.0f, 1.0f)
2-dimensional float unit Vector pointing along the Y axis.
static const Vector< int, 4 > kAxisW4i(0, 0, 0, 1)
4-dimensional int unit Vector pointing along the W axis.
Matrix class and functions.
static const Vector< int, 2 > kAxisX2i(1, 0)
2-dimensional int unit Vector pointing along the X axis.
static const Vector< float, 3 > kAxisY3f(0.0f, 1.0f, 0.0f)
3-dimensional float unit Vector pointing along the Y axis.
static const Vector< int, 3 > kAxisX3i(1, 0, 0)
3-dimensional int unit Vector pointing along the X axis.
static const Vector< double, 3 > kZeros3d(0.0, 0.0, 0.0)
3-dimensional double Vector of zeros.
static const Vector< double, 2 > kZeros2d(0.0, 0.0)
2-dimensional double Vector of zeros.
static const Vector< double, 3 > kAxisX3d(1.0, 0.0, 0.0)
3-dimensional double unit Vector pointing along the X axis.
static const Vector< float, 4 > kOnes4f(1.0f, 1.0f, 1.0f, 1.0f)
4-dimensional float Vector of ones.
static const Vector< float, 3 > kOnes3f(1.0f, 1.0f, 1.0f)
3-dimensional float Vector of ones.
static const Vector< int, 2 > kZeros2i(0, 0)
2-dimensional int Vector of ones.
static const Vector< double, 4 > kAxisX4d(1.0, 0.0, 0.0, 0.0)
4-dimensional double unit Vector pointing along the X axis.
static const Vector< float, 4 > kAxisX4f(1.0f, 0.0f, 0.0f, 0.0f)
4-dimensional float unit Vector pointing along the X axis.
static const Vector< float, 3 > kAxisX3f(1.0f, 0.0f, 0.0f)
3-dimensional float unit Vector pointing along the X axis.
Definition: vector_4_simd.h:38
static const Vector< int, 4 > kAxisX4i(1, 0, 0, 0)
4-dimensional int unit Vector pointing along the X axis.
Quaternion class and functions.
static const Vector< float, 2 > kZeros2f(0.0f, 0.0f)
2-dimensional float Vector of zeros.
static const Vector< float, 2 > kOnes2f(1.0f, 1.0f)
2-dimensional float Vector of ones.
static const Vector< double, 4 > kZeros4d(0.0, 0.0, 0.0, 0.0)
4-dimensional double Vector of zeros.
Vector class and functions.
Stores a Quaternion of type T and provides a set of utility operations on each Quaternion.
Definition: quaternion.h:47
static const Vector< double, 4 > kOnes4d(1.0, 1.0, 1.0, 1.0)
4-dimensional double Vector of ones.
static const Vector< float, 4 > kAxisY4f(0.0f, 1.0f, 0.0f, 0.0f)
4-dimensional float unit Vector pointing along the Y axis.
static const Vector< int, 4 > kAxisY4i(0, 1, 0, 0)
4-dimensional int unit Vector pointing along the Z axis.
static const Vector< double, 4 > kAxisY4d(0.0, 1.0, 0.0, 0.0)
4-dimensional double unit Vector pointing along the Y axis.
static const Vector< double, 4 > kAxisW4d(0.0, 0.0, 0.0, 1.0)
4-dimensional double unit Vector pointing along the W axis.
static const Vector< int, 3 > kAxisY3i(0, 1, 0)
3-dimensional int unit Vector pointing along the Y axis.
static const Vector< int, 4 > kOnes4i(1, 1, 1, 1)
4-dimensional int Vector of ones.
static const Quaternion< float > kQuatIdentityf(1.0f, 0.0f, 0.0f, 0.0f)
Quaternion Identity.