kick
|
00001 // 00002 // Created by Morten Nobel-Jørgensen on 01/08/14. 00003 // 00004 00005 00006 #pragma once 00007 #include "glm/glm.hpp" 00008 #include "kick/math/ray.h" 00009 00010 namespace kick { 00011 // represent a plane using the equation ax + by + cz + d = 0, where (a,b,c) is the normal and d is negative distance 00012 // to plane from origin 00013 class Plane { 00014 public: 00015 Plane(); 00016 00017 Plane(float x, float y, float z, float offset); 00018 00019 Plane(glm::vec3 normal, glm::vec3 pointInPlane); 00020 00021 Plane(glm::vec3 normal, float offset); 00022 00023 glm::vec3 normal() const; 00024 00025 void setNormal(glm::vec3 p); 00026 00027 float offset() const; 00028 00029 void setOffset(float d); 00030 00031 glm::vec3 pointOnPlane() const; 00032 00033 float distanceToPlane(glm::vec3 point) const; 00034 00035 float intersection(const Ray& line) const; 00036 00037 glm::vec3 intersectionPoint(const Ray& line) const; 00038 private: 00039 glm::vec4 plane; 00040 }; 00041 } 00042 00043