Voxellancer  0.3
A game about voxels in space
 All Classes Functions Pages
geometryhelper.h
1 #pragma once
2 
3 #include <unordered_set>
4 
5 #include <glm/glm.hpp>
6 #include <glm/gtc/quaternion.hpp>
7 #include <glm/gtx/intersect.hpp>
8 
9 
10 class WorldObject;
11 class Ray;
12 
14 public:
15  // checks for intersection of Ray and rectangle defined by clockwise points p,q,r,s.
16  static bool intersectRectangle(const Ray* ray, const glm::vec3& p, const glm::vec3& q, const glm::vec3& r, const glm::vec3& s);
17  static bool intersectRectangle(const Ray* ray, const glm::vec3& p, const glm::vec3& q, const glm::vec3& r, const glm::vec3& s, glm::vec3& intersection);
18 
19  // Returns the plane, set up by points p, q and r
20  static glm::vec3 plane(const glm::vec3& p, const glm::vec3& q, const glm::vec3& r);
21  // Returns the angle between u and v
22  static float angleBetween(const glm::vec3& u, const glm::vec3& v);
23  // Returns the angle between vector u and plane with normal v
24  static float angleBetweenVectorPlane(const glm::vec3& u, const glm::vec3& v);
25  // Returns the quaternion that rotates from u to v
26  static glm::quat quatFromTo(const glm::vec3& u, const glm::vec3& v);
27 
28  // Returns the quaternion from (0,0,-1) to dir
29  static glm::quat quatFromViewDirection(const glm::vec3& dir);
30 
31  // Return the WorldObject from objects that is closest to self, measured position to position
32  static WorldObject* closestObject(WorldObject& self, std::unordered_set<WorldObject*>* objects);
33 
34  // Normalize, and return value again if glm::length(value) is 0
35  template<typename T>
36  static T safeNormalize(const T& value);
37 };
38 
39 #include "geometryhelper.inl"
Definition: worldobject.h:43
Definition: geometryhelper.h:13
Definition: ray.h:12