39 template<
typename Type>
42 template<
typename Type>
45 template<
typename Type>
48 template<
typename Type>
51 template<
typename Type>
54 template<
typename Type>
57 template<
typename Type>
60 template<
typename Type>
68 template<
typename Type>
78 Vec3() : x(0), y(0), z(0) { }
79 explicit Vec3(
const Type &scalar) : x(scalar), y(scalar), z(scalar) { }
80 explicit Vec3(
const Vec2<Type> ©,
const Type &p3) { x = copy.
x; y = copy.
y; z = p3; }
87 explicit Vec3(
const Type &p1,
const Type &p2,
const Type &p3) : x(p1), y(p2), z(p3) { }
88 explicit Vec3(
const Type *array_xyz) : x(array_xyz[0]), y(array_xyz[1]), z(array_xyz[2]) { }
100 static Type
dot(
const Vec3<Type>& vector1,
const Vec3<Type>& vector2) {
return vector1.x*vector2.x + vector1.y*vector2.y + vector1.z*vector2.z; }
136 Type diff_x = second.x - first.x; Type diff_y = second.y - first.y; Type diff_z = second.z - first.z;
137 return (diff_x >= -epsilon && diff_x <= epsilon && diff_y >= -epsilon && diff_y <= epsilon && diff_z >= -epsilon && diff_z <= epsilon);
158 Type
dot(
const Vec3<Type>& vector)
const {
return x*vector.x + y*vector.y + z*vector.z; }
211 void operator += (Type value) { x += value; y += value; z += value; }
217 void operator -= (Type value) { x -= value; y -= value; z -= value; }
226 void operator *= (Type value) { x *= value; y *= value; z *= value; }
232 void operator /= (Type value) { x /= value; y /= value; z /= value; }
238 bool operator == (
const Vec3<Type>& vector)
const {
return ((x == vector.x) && (y == vector.y) && (z == vector.z)); }
241 bool operator != (
const Vec3<Type>& vector)
const {
return ((x != vector.x) || (y != vector.y) || (z != vector.z)); }
244 bool operator < (const Vec3<Type>& vector)
const {
return z < vector.z || (z == vector.z && (y < vector.y || (y == vector.y && x < vector.x))); }
248 template<
typename Type>
252 template<
typename Type>
256 template<
typename Type>
260 template<
typename Type>
264 template<
typename Type>
268 template<
typename Type>
272 template<
typename Type>
276 template<
typename Type>
280 template<
typename Type>
284 template<
typename Type>
288 template<
typename Type>
292 template<
typename Type>
297 template<
typename Type>
301 matrix[0 * 3 + 0] * v.x + matrix[0 * 3 + 1] * v.y + matrix[0 * 3 + 2] * v.z,
302 matrix[1 * 3 + 0] * v.x + matrix[1 * 3 + 1] * v.y + matrix[1 * 3 + 2] * v.z,
303 matrix[2 * 3 + 0] * v.x + matrix[2 * 3 + 1] * v.y + matrix[2 * 3 + 2] * v.z);
308 template<
typename Type>
312 matrix[0 * 3 + 0] * v.x + matrix[1 * 3 + 0] * v.y + matrix[2 * 3 + 0] * v.z,
313 matrix[0 * 3 + 1] * v.x + matrix[1 * 3 + 1] * v.y + matrix[2 * 3 + 1] * v.z,
314 matrix[0 * 3 + 2] * v.x + matrix[1 * 3 + 2] * v.y + matrix[2 * 3 + 2] * v.z);
389 template<
typename Type>
398 template<
typename Type>
401 template<
typename Type>
Vec3< Type > & operator=(const Vec3< Type > &vector)
= operator.
Definition: vec3.h:235
Type dot(const Vec3< Type > &vector) const
Dot products this vector with an other vector.
Definition: vec3.h:158
Vec3()
Definition: vec3.h:78
Vec3(const Vec2< Type > ©, const Type &p3)
Definition: vec3.h:80
Type distance(const Vec3< Type > &vector) const
Calculate the distance between this vector and an other vector.
2D vector
Definition: line.h:43
Vec3(const Type &scalar)
Definition: vec3.h:79
Type x
Definition: vec3.h:74
Vec3< Type > & normalize()
Normalizes this vector.
Definition: vec3.h:399
Type angle_normed(const Vec3< Type > &vector) const
Calculate the angle between this vector and an other vector, where the vectors are unit vectors...
bool operator==(const Vec3< Type > &vector) const
== operator.
Definition: vec3.h:238
3D matrix
Definition: mat2.h:44
Vec3(const Vec4< Type > ©)
Definition: vec3.h:81
Type x
Definition: vec4.h:74
Type x
Definition: vec2.h:75
Type datatype
Definition: vec3.h:72
Vec2< Type > operator-(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition: vec2.h:272
static bool is_equal(const Vec3< Type > &first, const Vec3< Type > &second, Type epsilon)
Returns true if equal within the bounds of an epsilon.
Definition: vec3.h:134
Type length() const
Returns the length (magnitude) of this vector.
Definition: vec3.h:390
static Vec3< Type > rotate(const Vec3< Type > &vector, Type angle, const Vec3< Type > &axis)
Rotate a vector around an axis. Same as glRotate[f|d](angle, a);.
Vec2< Type > operator+(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition: vec2.h:260
Type z
Definition: vec3.h:76
static Type dot(const Vec3< Type > &vector1, const Vec3< Type > &vector2)
Dot products between two vectors.
Definition: vec3.h:100
Type y
Definition: vec2.h:76
bool operator!=(const Vec3< Type > &vector) const
!= operator.
Definition: vec3.h:241
Vec3< Type > operator-() const
operator.
Definition: vec3.h:220
Type y
Definition: vec4.h:75
bool is_equal(const Vec3< Type > &other, Type epsilon) const
Returns true if equal within the bounds of an epsilon.
Definition: vec3.h:205
Vec2< Type > operator/(const Vec2< Type > &v1, const Vec2< Type > &v2)
/ operator.
Definition: vec2.h:296
Vec3(const Type &p1, const Type &p2, const Type &p3)
Definition: vec3.h:87
static Vec3< Type > reflect(const Vec3< Type > &incident, const Vec3< Type > &normal)
Calculate the reflection direction for an incident vector.
static Vec3< Type > cross(const Vec3< Type > &vector1, const Vec3< Type > &vector2)
Calculate the cross product between two vectors.
Vec2< Type > operator*(const Vec2< Type > &v1, const Vec2< Type > &v2)
operator.
Definition: vec2.h:284
Type y
Definition: vec3.h:75
Vec3< Type > & round()
Rounds all components on this vector.
Type z
Definition: vec4.h:76
void operator-=(const Vec3< Type > &vector)
-= operator.
Definition: vec3.h:214
Vec3(const Type *array_xyz)
Definition: vec3.h:88
void operator/=(const Vec3< Type > &vector)
/= operator.
Definition: vec3.h:229
void operator+=(const Vec3< Type > &vector)
+= operator.
Definition: vec3.h:208
void operator*=(const Vec3< Type > &vector)
*= operator.
Definition: vec3.h:223
Definition: Application/application.h:35
4D vector
Definition: size.h:44
Type angle(const Vec3< Type > &vector) const
Calculate the angle between this vector and an other vector.