OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VectorTypes.h
Go to the documentation of this file.
1 /* Copyright (c) 2012-2017, ARM Limited and Contributors
2  *
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge,
6  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
9  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19  */
20 
21 #ifndef VECTORTYPES_H
22 #define VECTORTYPES_H
23 
24 #include <cmath>
25 
31 namespace MaliSDK
32 {
38  class Vec2
39  {
40  public:
41  int x, y;
42  };
43 
49  class Vec3
50  {
51  public:
52  int x, y, z;
53  };
54 
60  class Vec4
61  {
62  public:
63  int x, y, z, w;
64  };
65 
66 
72  class Vec2f
73  {
74  public:
75  float x, y;
76  };
77 
83  class Vec3f
84  {
85  public:
86  float x, y, z;
87 
91  void normalize(void)
92  {
93  float length = sqrt(x * x + y * y + z * z);
94 
95  x /= length;
96  y /= length;
97  z /= length;
98  }
99 
108  static Vec3f cross(const Vec3f& vector1, const Vec3f& vector2)
109  {
110  /* Floating point vector to be returned. */
111  Vec3f crossProduct;
112 
113  crossProduct.x = (vector1.y * vector2.z) - (vector1.z * vector2.y);
114  crossProduct.y = (vector1.z * vector2.x) - (vector1.x * vector2.z);
115  crossProduct.z = (vector1.x * vector2.y) - (vector1.y * vector2.x);
116 
117  return crossProduct;
118  }
119  };
120 
121 
127  class Vec4f
128  {
129  public:
130  float x, y, z, w;
131 
135  void normalize(void)
136  {
137  float length = sqrt(x * x + y * y + z * z + w * w);
138 
139  x /= length;
140  y /= length;
141  z /= length;
142  w /= length;
143  }
144  };
145 }
146 #endif /* VECTORTYPES_H */
147 
A 2D floating point vector.
Definition: VectorTypes.h:72
static Vec3f cross(const Vec3f &vector1, const Vec3f &vector2)
Calculate cross product between two 3D floating point vectors.
Definition: VectorTypes.h:108
A 2D integer vector.
Definition: VectorTypes.h:38
A 3D floating point vector.
Definition: VectorTypes.h:83
GLfloat GLfloat GLfloat w
Definition: gl2ext.h:2701
A 3D integer vector.
Definition: VectorTypes.h:49
void normalize(void)
Normalize 4D floating point vector.
Definition: VectorTypes.h:135
GLint GLint GLint GLint GLint x
Definition: gl2ext.h:574
GLenum GLuint GLenum GLsizei length
Definition: gl2ext.h:134
A 4D integer vector.
Definition: VectorTypes.h:60
A 4D floating point vector.
Definition: VectorTypes.h:127
GLint y
Definition: gl2ext.h:179
void normalize(void)
Normalize 3D floating point vector.
Definition: VectorTypes.h:91