|
|
|
@ -168,17 +168,16 @@ class Distance { |
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @brief Distance of point from plane |
|
|
|
* @brief Distance of point from plane |
|
|
|
* |
|
|
|
* |
|
|
|
* The distance **d** is computed from point **p** and plane with normal |
|
|
|
* The distance **d** is computed from point **p** and plane with |
|
|
|
* **n** and **w** using: @f[ |
|
|
|
* normal **n** and **w** using: @f[ |
|
|
|
* d = \frac{\sum_i^3 (p \cdot n) + w}{\left| n \right|} |
|
|
|
* d = \frac{\sum_i^3 (p \cdot n) + w}{\left| n \right|} |
|
|
|
* @f] |
|
|
|
* @f] |
|
|
|
* The distance is negative if the point lies behind the plane. |
|
|
|
* The distance is negative if the point lies behind the plane. |
|
|
|
* |
|
|
|
* |
|
|
|
* In cases where the planes normal is a unit vector, @ref pointPlaneUnnormalized() |
|
|
|
* In cases where the planes normal is a unit vector, |
|
|
|
* is more efficient. |
|
|
|
* @ref pointPlaneUnnormalized() is more efficient. If merely the sign |
|
|
|
* |
|
|
|
* of the distance is of interest, @ref pointPlaneScaled() is more |
|
|
|
* If merely the sign of the distance is of interest, @ref pointPlaneScaled() |
|
|
|
* efficient. |
|
|
|
* is more efficient. |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
template<class T> static T pointPlane(const Vector3<T>& point, const Vector4<T>& plane) { |
|
|
|
template<class T> static T pointPlane(const Vector3<T>& point, const Vector4<T>& plane) { |
|
|
|
return pointPlaneScaled<T>(point, plane)/plane.xyz().length(); |
|
|
|
return pointPlaneScaled<T>(point, plane)/plane.xyz().length(); |
|
|
|
@ -187,15 +186,16 @@ class Distance { |
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @brief Distance of point from plane, scaled by the length of the planes normal |
|
|
|
* @brief Distance of point from plane, scaled by the length of the planes normal |
|
|
|
* |
|
|
|
* |
|
|
|
* The distance **d** is computed from point **p** and plane with normal |
|
|
|
* The distance **d** is computed from point **p** and plane with |
|
|
|
* **n** and **w** using: @f[ |
|
|
|
* normal **n** and **w** using: @f[ |
|
|
|
* d = \sum_i^3 (p \cdot n) + w |
|
|
|
* d = \sum_i^3 (p \cdot n) + w |
|
|
|
* @f] |
|
|
|
* @f] |
|
|
|
* The distance is negative if the point lies behind the plane. |
|
|
|
* The distance is negative if the point lies behind the plane. |
|
|
|
* |
|
|
|
* |
|
|
|
* More efficient than @ref pointPlane() when merely the sign of the distance is |
|
|
|
* More efficient than @ref pointPlane() when merely the sign of the |
|
|
|
* of interest, for example when testing on which half space of the plane the |
|
|
|
* distance is of interest, for example when testing on which half |
|
|
|
* point lies. |
|
|
|
* space of the plane the point lies. |
|
|
|
|
|
|
|
* @see @ref pointPlaneNormalized() |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
template<class T> static T pointPlaneScaled(const Vector3<T>& point, const Vector4<T>& plane) { |
|
|
|
template<class T> static T pointPlaneScaled(const Vector3<T>& point, const Vector4<T>& plane) { |
|
|
|
return (plane.xyz()*point).sum() + plane.w(); |
|
|
|
return (plane.xyz()*point).sum() + plane.w(); |
|
|
|
@ -204,21 +204,22 @@ class Distance { |
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @brief Distance of point from plane with normalized normal |
|
|
|
* @brief Distance of point from plane with normalized normal |
|
|
|
* |
|
|
|
* |
|
|
|
* The distance **d** is computed from point **p** and plane with normal |
|
|
|
* The distance **d** is computed from point **p** and plane with |
|
|
|
* **n** and **w** using: @f[ |
|
|
|
* normal **n** and **w** using: @f[ |
|
|
|
* d = \sum_i^3 (p \cdot n) + w |
|
|
|
* d = \sum_i^3 (p \cdot n) + w |
|
|
|
* @f] |
|
|
|
* @f] |
|
|
|
* The distance is negative if the point lies behind the plane. |
|
|
|
* The distance is negative if the point lies behind the plane. Expects |
|
|
|
|
|
|
|
* that @p plane normal is normalized. |
|
|
|
* |
|
|
|
* |
|
|
|
* More efficient than @ref pointPlane() in cases where the planes normal is |
|
|
|
* More efficient than @ref pointPlane() in cases where the planes |
|
|
|
* normalized. |
|
|
|
* normal is normalized. Equivalent to @ref pointPlaneScaled() but with |
|
|
|
|
|
|
|
* assertion added on top. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
template<class T> static T pointPlaneNormalized(const Vector3<T>& point, const Vector4<T>& plane) { |
|
|
|
template<class T> static T pointPlaneNormalized(const Vector3<T>& point, const Vector4<T>& plane) { |
|
|
|
CORRADE_ASSERT(plane.xyz().isNormalized(), |
|
|
|
CORRADE_ASSERT(plane.xyz().isNormalized(), |
|
|
|
"Math::Geometry::Distance::pointPlaneNormalized(): the planes normal is not a unit vector", {}); |
|
|
|
"Math::Geometry::Distance::pointPlaneNormalized(): plane normal is not an unit vector", {}); |
|
|
|
return pointPlaneScaled<T>(point, plane); |
|
|
|
return pointPlaneScaled<T>(point, plane); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
template<class T> T Distance::lineSegmentPoint(const Vector2<T>& a, const Vector2<T>& b, const Vector2<T>& point) { |
|
|
|
template<class T> T Distance::lineSegmentPoint(const Vector2<T>& a, const Vector2<T>& b, const Vector2<T>& point) { |
|
|
|
|