void planeFromPoints(const vec3* a, const vec3* b, const vec3* c, plane3* p) { vec3 d1, d2; sub(a,b,&d1); sub (b,c,&d2); crossProduct(&d1,&d2,&(p->n)); normalize(&(p->n)); p->d = 0.0; p->d = -signedDistance(a,p); }
Scalar Plane<Scalar>::distance(const Vector<Scalar,3> &point) const { Scalar signed_dist = signedDistance(point); Scalar dist = signed_dist>=0?signed_dist:-signed_dist; return dist; }
/** Reflect a point in the hyperplane. */ VectorT reflect(VectorT const & p) const { return p - 2 * signedDistance(p) * normal; }
/** * Check if the negative half space (the side of the hyperplane <b>not</b> containing the normal) contains a given point. * Returns true if the point lies on the hyperplane. */ bool negativeHalfSpaceContains(VectorT const & p) const { return signedDistance(p) <= 0; }
/** * Check if the positive half space (the side of the hyperplane containing the normal) contains a given point. Returns true * if the point lies on the hyperplane. */ bool positiveHalfSpaceContains(VectorT const & p) const { return signedDistance(p) >= 0; }
/** Get the point on the hyperplane closest to a given point. */ VectorT closestPoint(VectorT const & p) const { return p - signedDistance(p) * normal; }
/** Get the square of the distance of the hyperplane from a given point. */ T squaredDistance(VectorT const & p) const { return Math::square(signedDistance(p)); }
/** Get the (unsigned) distance of a given point from the hyperplane. */ T distance(VectorT const & p) const { return std::abs(signedDistance(p)); }