Browse Source

Math: fix Intersection::lineSegmentLineSegment() math docs.

I spent 30 minutes looking at the equations totally lost, not realizing
that the bold s and the non-bold s are the same thing. Ugh.
pull/289/head
Vladimír Vondruš 8 years ago
parent
commit
18f9118995
  1. 12
      src/Magnum/Math/Intersection.h

12
src/Magnum/Math/Intersection.h

@ -59,16 +59,16 @@ Returns intersection point positions @f$ t @f$, @f$ u @f$ on both lines:
2D lines are parallel)
The two lines intersect if @f$ t @f$ and @f$ u @f$ exist such that: @f[
\boldsymbol p + t \boldsymbol r = \boldsymbol q + u \boldsymbol s
\boldsymbol{p} + t \boldsymbol{r} = \boldsymbol{q} + u \boldsymbol{s}
@f]
Crossing both sides with @f$ \boldsymbol{s} @f$, distributing the cross product
and eliminating @f$ \boldsymbol s \times \boldsymbol s = 0 @f$, then solving
and eliminating @f$ \boldsymbol{s} \times \boldsymbol{s} = 0 @f$, then solving
for @f$ t @f$ and similarly for @f$ u @f$: @f[
\begin{array}{rcl}
(\boldsymbol p + t \boldsymbol r) \times s & = & (\boldsymbol q + u \boldsymbol s) \times s \\
t (\boldsymbol r \times s) & = & (\boldsymbol q - \boldsymbol p) \times s \\
t & = & \cfrac{(\boldsymbol q - \boldsymbol p) \times s}{\boldsymbol r \times \boldsymbol s} \\
u & = & \cfrac{(\boldsymbol q - \boldsymbol p) \times r}{\boldsymbol r \times \boldsymbol s}
(\boldsymbol{p} + t \boldsymbol{r}) \times \boldsymbol{s} & = & (\boldsymbol{q} + u \boldsymbol{s}) \times \boldsymbol{s} \\
t (\boldsymbol{r} \times \boldsymbol{s}) & = & (\boldsymbol{q} - \boldsymbol{p}) \times \boldsymbol{s} \\
t & = & \cfrac{(\boldsymbol{q} - \boldsymbol{p}) \times \boldsymbol{s}}{\boldsymbol{r} \times \boldsymbol{s}} \\
u & = & \cfrac{(\boldsymbol{q} - \boldsymbol{p}) \times \boldsymbol{r}}{\boldsymbol{r} \times \boldsymbol{s}}
\end{array}
@f]

Loading…
Cancel
Save