12#ifndef _CS237_PLANE_HPP_
13#define _CS237_PLANE_HPP_
16#error "cs237-plane.hpp should not be included directly"
26 using vec3 = glm::vec<3, T, glm::defaultp>;
27 using vec4 = glm::vec<4, T, glm::defaultp>;
45 double d = -glm::dot(
norm,
p);
53 T dist ()
const {
return this->_nd.w; }
60 return glm::dot(this->_nd,
vec4(
p, 1.0));
74 return "Plane(" + glm::to_string(this->
norm()) +
", "
85 return (
s <<
plane.toString());
std::ostream & operator<<(std::ostream &s, __detail::AABB< T > const &bb)
print the axis-aligned bounding box to the output stream
Definition cs237-aabb.hpp:22
std::string to_string(Channels ch)
convert a Channels value to a printable string
Axis-Aligned Bounding Box parameterized over the scalar type.
Definition cs237-aabb.hpp:28
representation of a oriented 3D plane
Definition cs237-plane.hpp:25
glm::vec< 3, T, glm::defaultp > vec3
Definition cs237-plane.hpp:26
std::string toString() const
the string representation of a plane
Definition cs237-plane.hpp:72
glm::vec< 4, T, glm::defaultp > vec4
Definition cs237-plane.hpp:27
Plane()
unit normal and signed distance from origin
Definition cs237-plane.hpp:31
vec4 _nd
Definition cs237-plane.hpp:29
Plane(vec3 n, T d)
specify a plane as a unit-length normal vector and signed distance from origin
Definition cs237-plane.hpp:37
T dist() const
signed distance from origin to plane
Definition cs237-plane.hpp:53
T distanceToPt(vec3 const &p) const
signed distance from a point to plane
Definition cs237-plane.hpp:58
vec3 norm() const
get the plane normal vector
Definition cs237-plane.hpp:50
vec3 project(vec3 const &p) const
Definition cs237-plane.hpp:66
Plane(vec3 n, vec3 p)
specify a plane as a normal vector and point on the plane
Definition cs237-plane.hpp:42