1 #ifndef INCLUDE_AL_PLANE_HPP
2 #define INCLUDE_AL_PLANE_HPP
45 #include "al/math/al_Vec.hpp"
57 Plane() : mNormal(1, 0, 0), mD(0) {}
64 T
d()
const {
return mD; }
93 Plane<T>::Plane(
const Vec3& v1,
const Vec3& v2,
const Vec3& v3) {
94 from3Points(v1, v2, v3);
102 return fromNormalAndPoint(
cross(v3 - v2, v1 - v2).normalize(),
109 mD = -(mNormal.dot(point));
117 mNormal(a / l, b / l, c / l);
T distance(const Vec3 &p) const
Returns distance from plane to point (measured relative to plane normal)
const Vec3 & normal() const
Get normal perpendicular to plane (a, b, and c components)
Plane & fromCoefficients(T a, T b, T c, T d)
Set plane from coefficients.
Plane & from3Points(const Vec3 &v1, const Vec3 &v2, const Vec3 &v3)
Set from three points lying on the plane.
T d() const
Get scalar component of plane equation.
bool inPositiveSpace(const Vec3 &p) const
Returns whether a point is in the positive half-space of the plane.
Plane & fromNormalAndPoint(const Vec3 &normal, const Vec3 &point)
Set plane from a unit length normal and point lying on the plane.
bool inNegativeSpace(const Vec3 &p) const
Returns whether a point is in the negative half-space of the plane.
T dot(const Vec< N, U > &v) const
Returns dot (inner) product between vectors.
void cross(Vec< 3, T > &r, const Vec< 3, T > &a, const Vec< 3, T > &b)
Sets r to cross product, a x b.