From 73c881f5aea3640d74cd7c8d12bf2ed0257bfb5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 12 Mar 2023 11:41:03 +0100 Subject: [PATCH] Math: mention that cross product can be used to calculate triangle area. --- src/Magnum/Math/Vector2.h | 13 ++++++++----- src/Magnum/Math/Vector3.h | 6 ++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Magnum/Math/Vector2.h b/src/Magnum/Math/Vector2.h index 2b44be4d1..bd34167d5 100644 --- a/src/Magnum/Math/Vector2.h +++ b/src/Magnum/Math/Vector2.h @@ -38,14 +38,17 @@ namespace Magnum { namespace Math { 2D version of a cross product, also called a [perp-dot product](https://en.wikipedia.org/wiki/Vector_projection#Scalar_rejection), equivalent to calling @ref cross(const Vector3&, const Vector3&) with Z -coordinate set to `0` and extracting only Z coordinate from the result (X and Y -coordinates are always zero). Returns `0` either when one of the vectors is -zero or they are parallel or antiparallel and `1` when two *normalized* vectors -are perpendicular. @f[ +coordinate set to @cpp 0 @ce and extracting only Z coordinate from the result +(X and Y coordinates are always zero). Returns @cpp 0 @ce either when one of +the vectors is zero or they are parallel or antiparallel and @cpp 1 @ce when +two *normalized* vectors are perpendicular. @f[ \boldsymbol a \times \boldsymbol b = \boldsymbol a_\bot \cdot \boldsymbol b = a_xb_y - a_yb_x @f] -Value of a 2D cross product is related to a distance of a point and a line, see +If @f$ \boldsymbol{a} @f$, @f$ \boldsymbol{b} @f$ and @f$ \boldsymbol{c} @f$ +are corners of a triangle, @f$ \frac{1}{2}|(\boldsymbol{c} - \boldsymbol{b}) \times (\boldsymbol{a} - \boldsymbol{b})| @f$ +is its area. Value of a 2D cross product is also related to a distance of a +point and a line, see @ref Distance::linePoint(const Vector2&, const Vector2&, const Vector2&) for more information. @see @ref Vector2::perpendicular(), diff --git a/src/Magnum/Math/Vector3.h b/src/Magnum/Math/Vector3.h index 25bab9263..4fd40db82 100644 --- a/src/Magnum/Math/Vector3.h +++ b/src/Magnum/Math/Vector3.h @@ -45,8 +45,10 @@ are perpendicular. @f[ If @f$ \boldsymbol{a} @f$, @f$ \boldsymbol{b} @f$ and @f$ \boldsymbol{c} @f$ are corners of a triangle in a counterclockwise order, @f$ (\boldsymbol{c} - \boldsymbol{b}) \times (\boldsymbol{a} - \boldsymbol{b}) @f$ -gives the direction of its normal. Length of a cross product is related to a -distance of a point and a line, see @ref Distance::linePoint(const Vector3&, const Vector3&, const Vector3&) +gives the direction of its normal, and +@f$ \frac{1}{2}|(\boldsymbol{c} - \boldsymbol{b}) \times (\boldsymbol{a} - \boldsymbol{b})| @f$ +is its area. Length of a cross product is also related to a distance of a point +and a line, see @ref Distance::linePoint(const Vector3&, const Vector3&, const Vector3&) for more information. @see @ref cross(const Vector2&, const Vector2&), @ref planeEquation() */