1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-08-29 19:20:39 +02:00

improved lazy loading

This commit is contained in:
Pomax
2020-09-13 13:18:15 -07:00
parent a626c2c8cb
commit c0a1207d67
27 changed files with 163 additions and 208 deletions

View File

@@ -1,11 +1,11 @@
let curve, r;
let curve, r, kappa = 0.5519768352769461;
setup() {
r = 100;
curve = new Bezier(this, [
{ x: r, y: 0 },
{ x: r, y: 0.55228 * r },
{ x: 0.55228 * r, y: r},
{ x: r, y: kappa * r },
{ x: kappa * r, y: r},
{ x: 0, y: r }
]);
}
@@ -38,12 +38,12 @@ draw() {
curve.drawCurve(`#CC00CC40`);
setColor(`#CC00CC`);
line(r, 0, r, -0.55228 * r);
circle(r, -0.55228 * r, 2);
text(`reflected`, r + 7, -0.55228 * r + 3, LEFT);
line(r, 0, r, -kappa * r);
circle(r, -kappa * r, 2);
text(`reflected`, r + 7, -kappa * r + 3, LEFT);
setColor(`#CC00CC40`);
line(0, -r, 0.55228 * r, -r);
line(0, -r, kappa * r, -r);
curve.points.forEach(p => {
p.x = -p.x;
@@ -52,12 +52,12 @@ draw() {
curve.drawCurve(`#0000CC40`);
setColor(`#0000CC`);
line(0, r, -0.55228 * r, r);
circle(-0.55228 * r, r, 2);
text(`reflected`, -0.55228 * r - 5, r + 3, RIGHT);
line(0, r, -kappa * r, r);
circle(-kappa * r, r, 2);
text(`reflected`, -kappa * r - 5, r + 3, RIGHT);
setColor(`#0000CC40`);
line(-r, 0, -r, 0.55228 * r);
line(-r, 0, -r, kappa * r);
curve.points.forEach(p => p.y = -p.y);
curve.drawCurve(`#00000040`);

View File

@@ -47,13 +47,13 @@ But we now need to find two control points, rather than one. If we want the deri
C_1 = S + a \cdot \begin{pmatrix} 0 \\ 1 \end{pmatrix}
\]
where "a" is some scaling factor, and:
where "a" is some scaling factor we'll need to find the expression for, and:
\[
C_2 = E + b \cdot \begin{pmatrix} -sin(φ) \\ cos(φ) \end{pmatrix}
C_2 = E + a \cdot \begin{pmatrix} sin(φ) \\ cos(φ) \end{pmatrix}
\]
where "b" is also some scaling factor.
using the same scaling factor, because circular arcs are symmetrical, so our approximation will need to be symmetrical, too.
Starting with this information, we slowly maths our way to success, but I won't lie: the maths for this is pretty trig-heavy, and it's easy to get lost if you remember (or know!) some of the core trigonometric identities, so if you just want to see the final result just skip past the next section!
@@ -121,7 +121,10 @@ And after this tedious detour to find the coordinate for C<sub>1</sub>, we can f
\[
\begin{array}{l}
E'_x = -sin(φ) \ , \ E'_y = cos(φ) \ , \ ||E'|| = \sqrt{ (-sin(φ))^2 + cos^2(φ)} = 1 \ , \\
E'_x = -sin(φ) \ ,\\
E'_y = cos(φ) \ , \\
||E'|| = \sqrt{ (-sin(φ))^2 + cos^2(φ)} = 1 \ , \\
\\
\left\{\begin{array}{l}
C_2x = E_x - C_{1y} \cdot \frac{E_x'}{||E'||}
= cos(φ) + C_{1y} \cdot sin(φ)