Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Using the notation given in <a href="http://pomax.github.io/bezierinfo/#extremities" rel="nofollow">http://pomax.github.io/bezierinfo/#extremities</a>, a quadratic Bezier curve is given by:</p> <pre><code>B(t) = P1*(1-t)**2 + 2*P2*(1-t)*t + P3*t**2 </code></pre> <p>Therefore, (by taking the <a href="http://en.wikipedia.org/wiki/Derivative" rel="nofollow">derivative</a> of <code>B</code> with respect to <code>t</code>) the tangent to the curve is given by</p> <pre><code>B'(t) = -2*P1*(1-t) + 2*P2*(1-2*t) + 2*P3*t = 2*(P1 - 2*P2 + P3)*t + 2*(-P1 + P2) </code></pre> <p>Given some tangent direction <code>V</code>, solve </p> <pre><code>B'(t) = V </code></pre> <p>for <code>t</code>. If there is a solution, <code>t = ts</code>, then the point on the Bezier curve which has tangent direction <code>V</code> is given by <code>B(ts)</code>.</p> <hr> <p>We essentially want to know if two vectors (<code>B'(t)</code> and <code>V</code>) are parallel or anti-parallel. There is a trick to doing that.</p> <p>Two vectors, <code>X</code> and <code>Y</code>, are perpendicular if their <a href="http://en.wikipedia.org/wiki/Dot_product#Geometric_definition" rel="nofollow">dot product</a> is zero. If <code>X = (a,b)</code> and <code>Y = (c,d)</code> then the dot product of <code>X</code> and <code>Y</code> is given by</p> <pre><code>a*c + b*d </code></pre> <p>So, <code>X</code> and <code>Y</code> are parallel if <code>X</code> and <code>Y_perp</code> are perpendicular, where <code>Y_perp</code> is a vector perpendicular to <code>Y</code>.</p> <p>In 2-dimensions, if in coordinates <code>Y = (a,b)</code> then <code>Y_perp = (-b, a)</code>. (There are two perpendicular vectors possible, but this one will do.) Notice that -- using the formula above -- the dot product of <code>Y</code> and <code>Y_perp</code> is</p> <pre><code>a*(-b) + b*(a) = 0 </code></pre> <p>So indeed, this jibes with the claim that perpendicular vectors have a dot product equal to 0.</p> <p>Now, to solve our problem: Let</p> <pre><code>B'(t) = (a*t+b, c*t+d) V = (e, f) </code></pre> <p>Then <code>B'(t)</code> is parallel (or anti-parallel) to <code>V</code> if or when <code>B'(t)</code> is perpendicular to <code>V_perp</code>, which occurs when</p> <pre><code>dot product((a*t+b, c*t+d), (-f, e)) = 0 -(a*t+b)*f + (c*t+d)*e = 0 </code></pre> <p>We know <code>a</code>, <code>b</code>, <code>c</code>, <code>d</code>, <code>e</code> and <code>f</code>. Solve for <code>t</code>. If <code>t</code> lies between 0 and 1, then <code>B(t)</code> is part of the Bezier curve segment between <code>P1</code> and <code>P3</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload