X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FPlane.hh;h=4739bb825406d5599d853ea0e39671d387e8041e;hp=248a3128161afe0cadbdde10fa781d6b3e89c405;hb=fe9614821670d9affcb68fb3e45723b9d40d0b7e;hpb=72d4af22710317acffab861421c4364b1780b6fe diff --git a/src/Moof/Plane.hh b/src/Moof/Plane.hh index 248a312..4739bb8 100644 --- a/src/Moof/Plane.hh +++ b/src/Moof/Plane.hh @@ -39,6 +39,11 @@ class Aabb; class Sphere; +/* + * A plane in 3-space defined by the equation Ax + By + Cz = D, where [A, B, C] + * is normal to the plane. + */ + struct Plane { Vector3 normal; @@ -60,6 +65,8 @@ struct Plane d(scalar) {} + /* Causes the normal of the plane to become normalized. The scalar may also + * be changed to keep the equation true. */ void normalize() { Scalar mag = normal.length(); @@ -68,12 +75,15 @@ struct Plane d /= mag; } + /** + * Determine the shortest distance between a point and the plane. */ + inline Scalar getDistanceToPoint(const Vector3& point) const { return cml::dot(point, normal) + d; } - inline Halfspace intersectsPoint(const Vector3& point) const + inline Halfspace intersects(const Vector3& point) const { Scalar distance = getDistanceToPoint(point); @@ -82,8 +92,8 @@ struct Plane else return POSITIVE; } - Halfspace intersectsAabb(const Aabb& aabb) const; - Halfspace intersectsSphere(const Sphere& sphere) const; + Halfspace intersects(const Aabb& aabb) const; + Halfspace intersects(const Sphere& sphere) const; };