Krig Game Engine
Loading...
Searching...
No Matches
Vector.h
Go to the documentation of this file.
1
7#ifndef _VECTOR_H_
8#define _VECTOR_H_
9
10#include <cmath>
11#include <cstdio>
12
13#include "Matrix.h"
14
15struct Vector {
16 Vector();
17 Vector(const float &, const float &, const float &);
18 void setVector(const float &, const float &, const float &);
19
20 void normalize();
21 float dotProduct(const Vector &);
22 void crossProduct(const Vector &, const Vector &);
23 float getDistance(const Vector &);
24 float getLength();
25 float getScaler(const Vector &);
26 float getSum();
27 void scale(const float&);
28 void average(const Vector &, const Vector &);
29 void calcNorm(const Vector &, const Vector &, const Vector &);
30
31 Vector operator *(float);
32 Vector operator +(const Vector &);
33 void operator =(const Vector &);
34 void operator +=(const Vector &);
35 void operator -=(const Vector &);
36
37 void rotateVector(const Matrix &, const Vector &);
38 void transformVector(const Matrix &, const Vector &);
39
40 // `this` is the ray direction. Returns true if the ray from rayOrigin
41 // hits the AABB defined by box[0] (min) and box[1] (max), expanded by
42 // margin on all sides. Sets hitPoint to the entry point, or to rayOrigin
43 // if the origin is inside the box. Returns false for a zero direction.
44 bool intersectBox(const Vector &rayOrigin, Vector box[], float margin, Vector &hitPoint);
45 bool intersectBox(const Vector &rayOrigin, Vector box[], float margin);
46
47 float x, y, z;
48};
49
50#endif
Representation of 4x4 matrix with common matrix operations.
Definition Matrix.h:16