OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 | 2 |
3 <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> | 3 <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> |
4 <head> | 4 <head> |
5 <meta charset="utf-8" /> | 5 <meta charset="utf-8" /> |
6 <title></title> | 6 <title></title> |
7 <div style="height:0"> | 7 <div style="height:0"> |
8 | 8 |
9 <div id="sect0"> | 9 <div id="angle"> |
10 {{{{306.588013,-227.983994}, {212.464996,-262.242004}, {95.5512009,58.9763985}}}
, 0.707107008f}, | 10 {{{2, 6, 1, 2, 7.16666698f, 6.66666698f, -4.66666651f, 7.66666651f}}} |
11 {{{{377.218994,-141.981003}, {40.578701,-201.339996}, {23.1854992,-102.697998}}}
, 0.707107008f}, | 11 {{{1, 2, 7.16666698f, 6.66666698f, -4.66666651f, 7.66666651f, 2, 6}}} |
| 12 {{{1.995156049728393555, 5.980457782745361328}, {2.08147298604749853, 5.91769261
5073925744}, {2.164281118403629023, 5.850987095630077128}, {2.242042064666748047
, 5.780299663543701172}}} |
| 13 {{{1.995156049728393555, 5.980457782745361328}, {1.82665117196054072, 6.18573561
9599722845}, {1.80264212281170999, 5.19703332512428684}, {1.994958639144897461,
5.979661464691162109}}} |
| 14 {{{1.995156049728393555, 5.980457782745361328}, {1.825196881732315868, 6.1875072
80789372288}, {1.801190554235020613, 5.204762216940081565}, {2, 6}}} |
12 </div> | 15 </div> |
13 | 16 |
14 <div id="sect1"> | 17 <div id="ref"> |
15 {{{{377.218994,-141.981003}, {40.578701,-201.339996}, {23.1854992,-102.697998}}}
, 0.707107008f}, | 18 {{{0.7153972983360290527, 4.712343692779541016}, {0.2472269223126296878, 4.55502
436068874772}, {-0.1220090791716240131, 4.244018092892478222}, {0, 4}}}, |
16 {{{{306.58801299999999, -227.983994}, {212.46499600000001, -262.24200400000001},
{95.551200899999998, 58.976398500000002}}}, 0.707107008f} id=1 | 19 {{{0.7153972983360290527, 4.712343692779541016}, {0.1339736781445877156, 4.13397
5051508096854}, {0.7320473976783675729, 3.63397630116081638}, {2, 3}}}, |
17 {{{{377.21899400000001, -141.98100299999999}, {237.77799285476553, -166.56830755
921084}, {134.08399674208422, -155.06258330544892}}}, 0.788580656f} id=2 | 20 {{fX=-0.0012699038296868359 fY=-0.0012605104293301750 } {fX=-0.00253375750859108
35 fY=-0.0025229424048465177 } |
18 {{{{134.08399674208422, -155.06258330544892}, {30.390000629402859, -143.55685905
168704}, {23.185499199999999, -102.697998}}}, 0.923879623f} id=4 | |
19 </div> | |
20 | |
21 <div id="sect2"> | |
22 {{{{306.588013,-227.983994}, {212.464996,-262.242004}, {95.5512009,58.9763985}}}
, 0.707107008f}, | |
23 {{{{377.218994,-141.981003}, {40.578701,-201.339996}, {23.1854992,-102.697998}}}
, 0.707107008f}, | |
24 {{{{205.78973252799028, -158.12538713371103}, {143.97848953841861, -74.076645245
042371}, {95.551200899999998, 58.976398500000002}}}, 0.923879623f} id=3 | |
25 {{{{377.21899400000001, -141.98100299999999}, {237.77799285476553, -166.56830755
921084}, {134.08399674208422, -155.06258330544892}}}, 0.788580656f} id=2 | |
26 </div> | |
27 | |
28 <div id="sect3"> | |
29 {{{{306.588013,-227.983994}, {212.464996,-262.242004}, {95.5512009,58.9763985}}}
, 0.707107008f}, | |
30 {{{{377.218994,-141.981003}, {40.578701,-201.339996}, {23.1854992,-102.697998}}}
, 0.707107008f}, | |
31 {{{{205.78973252799028, -158.12538713371103}, {143.97848953841861, -74.076645245
042371}, {95.551200899999998, 58.976398500000002}}}, 0.923879623f} id=3 | |
32 {{{{252.08225670812539, -156.90491625851064}, {185.93099479842493, -160.81544543
232982}, {134.08399674208422, -155.06258330544892}}}, 0.835816324f} id=6 | |
33 </div> | |
34 | |
35 <div id="sect4"> | |
36 {{{{306.588013,-227.983994}, {212.464996,-262.242004}, {95.5512009,58.9763985}}}
, 0.707107008f}, | |
37 {{{{377.218994,-141.981003}, {40.578701,-201.339996}, {23.1854992,-102.697998}}}
, 0.707107008f}, | |
38 {{{{205.78973252799028, -158.12538713371103}, {174.88411103320448, -116.10101618
937664}, {145.19509369736275, -56.857102571363754}}}, 0.871667147f} id=3 | |
39 {{{{252.08225670812539, -156.90491625851064}, {185.93099479842493, -160.81544543
232982}, {134.08399674208422, -155.06258330544892}}}, 0.835816324f} id=6 | |
40 </div> | |
41 | |
42 <div id="sect5"> | |
43 {{{{306.588013,-227.983994}, {212.464996,-262.242004}, {95.5512009,58.9763985}}}
, 0.707107008f}, | |
44 {{{{377.218994,-141.981003}, {40.578701,-201.339996}, {23.1854992,-102.697998}}}
, 0.707107008f}, | |
45 {{{{205.78973252799028, -158.12538713371103}, {174.88411103320448, -116.10101618
937664}, {145.19509369736275, -56.857102571363754}}}, 0.871667147f} id=3 | |
46 {{{{252.08225670812539, -156.90491625851064}, {219.70109133058406, -158.81912754
088933}, {190.17095392508796, -158.38373974664466}}}, 0.858306944f} id=6 | |
47 </div> | |
48 | |
49 <div id="sect6"> | |
50 {{{{306.588013,-227.983994}, {212.464996,-262.242004}, {95.5512009,58.9763985}}}
, 0.707107008f}, | |
51 {{{{377.218994,-141.981003}, {40.578701,-201.339996}, {23.1854992,-102.697998}}}
, 0.707107008f}, | |
52 {{{{205.78973252799028, -158.12538713371103}, {190.33692178059735, -137.11320166
154385}, {174.87004877564593, -111.2132534799228}}}, 0.858117759f} id=3 | |
53 {{{{252.08225670812539, -156.90491625851064}, {219.70109133058406, -158.81912754
088933}, {190.17095392508796, -158.38373974664466}}}, 0.858306944f} id=6 | |
54 </div> | 21 </div> |
55 | 22 |
56 </div> | 23 </div> |
57 | 24 |
58 <script type="text/javascript"> | 25 <script type="text/javascript"> |
59 | 26 |
60 var testDivs = [ | 27 var testDivs = [ |
61 sect0, | 28 angle, |
62 sect1, | 29 ref, |
63 sect2, | |
64 sect3, | |
65 sect4, | |
66 sect5, | |
67 sect6, | |
68 ]; | 30 ]; |
69 | 31 |
70 var decimal_places = 3; | 32 var decimal_places = 3; |
71 | 33 |
72 var tests = []; | 34 var tests = []; |
73 var testTitles = []; | 35 var testTitles = []; |
74 var testIndex = 0; | 36 var testIndex = 0; |
75 var ctx; | 37 var ctx; |
76 | 38 |
77 var subscale = 1; | 39 var subscale = 1; |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 var a = one_t2 * one_t; | 454 var a = one_t2 * one_t; |
493 var b = 3 * one_t2 * t; | 455 var b = 3 * one_t2 * t; |
494 var c = 3 * one_t * t2; | 456 var c = 3 * one_t * t2; |
495 var d = t2 * t; | 457 var d = t2 * t; |
496 return a * curve[1] + b * curve[3] + c * curve[5] + d * curve[7]; | 458 return a * curve[1] + b * curve[3] + c * curve[5] + d * curve[7]; |
497 } | 459 } |
498 | 460 |
499 function drawPointAtT(curve) { | 461 function drawPointAtT(curve) { |
500 var x = x_at_t(curve, curveT); | 462 var x = x_at_t(curve, curveT); |
501 var y = y_at_t(curve, curveT); | 463 var y = y_at_t(curve, curveT); |
502 drawPoint(x, y); | 464 drawPoint(x, y, false); |
503 } | 465 } |
504 | 466 |
505 function drawLine(x1, y1, x2, y2) { | 467 function drawLine(x1, y1, x2, y2) { |
506 ctx.beginPath(); | 468 ctx.beginPath(); |
507 ctx.moveTo((x1 - srcLeft) * scale, | 469 ctx.moveTo((x1 - srcLeft) * scale, |
508 (y1 - srcTop) * scale); | 470 (y1 - srcTop) * scale); |
509 ctx.lineTo((x2 - srcLeft) * scale, | 471 ctx.lineTo((x2 - srcLeft) * scale, |
510 (y2 - srcTop) * scale); | 472 (y2 - srcTop) * scale); |
511 ctx.stroke(); | 473 ctx.stroke(); |
512 } | 474 } |
513 | 475 |
514 function drawPoint(px, py) { | 476 function drawPoint(px, py, xend) { |
515 for (var pts = 0; pts < drawnPts.length; pts += 2) { | 477 for (var pts = 0; pts < drawnPts.length; pts += 2) { |
516 var x = drawnPts[pts]; | 478 var x = drawnPts[pts]; |
517 var y = drawnPts[pts + 1]; | 479 var y = drawnPts[pts + 1]; |
518 if (px == x && py == y) { | 480 if (px == x && py == y) { |
519 return; | 481 return; |
520 } | 482 } |
521 } | 483 } |
522 drawnPts.push(px); | 484 drawnPts.push(px); |
523 drawnPts.push(py); | 485 drawnPts.push(py); |
524 var _px = (px - srcLeft) * scale; | 486 var _px = (px - srcLeft) * scale; |
525 var _py = (py - srcTop) * scale; | 487 var _py = (py - srcTop) * scale; |
526 ctx.beginPath(); | 488 ctx.beginPath(); |
527 ctx.arc(_px, _py, 3, 0, Math.PI * 2, true); | 489 if (xend) { |
528 ctx.closePath(); | 490 ctx.moveTo(_px - 3, _py - 3); |
| 491 ctx.lineTo(_px + 3, _py + 3); |
| 492 ctx.moveTo(_px - 3, _py + 3); |
| 493 ctx.lineTo(_px + 3, _py - 3); |
| 494 } else { |
| 495 ctx.arc(_px, _py, 3, 0, Math.PI * 2, true); |
| 496 ctx.closePath(); |
| 497 } |
529 ctx.stroke(); | 498 ctx.stroke(); |
530 if (draw_point_xy) { | 499 if (draw_point_xy) { |
531 var label = px.toFixed(decimal_places) + ", " + py.toFixed(decimal_p
laces); | 500 var label = px.toFixed(decimal_places) + ", " + py.toFixed(decimal_p
laces); |
532 ctx.font = "normal 10px Arial"; | 501 ctx.font = "normal 10px Arial"; |
533 ctx.textAlign = "left"; | 502 ctx.textAlign = "left"; |
534 ctx.fillStyle = "black"; | 503 ctx.fillStyle = "black"; |
535 ctx.fillText(label, _px + 5, _py); | 504 ctx.fillText(label, _px + 5, _py); |
536 } | 505 } |
537 } | 506 } |
538 | 507 |
539 function drawPointSolid(px, py) { | 508 function drawPointSolid(px, py) { |
540 drawPoint(px, py); | 509 drawPoint(px, py, false); |
541 ctx.fillStyle = "rgba(0,0,0, 0.4)"; | 510 ctx.fillStyle = "rgba(0,0,0, 0.4)"; |
542 ctx.fill(); | 511 ctx.fill(); |
543 } | 512 } |
544 | 513 |
545 function crossPt(origin, pt1, pt2) { | 514 function crossPt(origin, pt1, pt2) { |
546 return ((pt1[0] - origin[0]) * (pt2[1] - origin[1]) | 515 return ((pt1[0] - origin[0]) * (pt2[1] - origin[1]) |
547 - (pt1[1] - origin[1]) * (pt2[0] - origin[0])) > 0 ? 0 : 1; | 516 - (pt1[1] - origin[1]) * (pt2[0] - origin[0])) > 0 ? 0 : 1; |
548 } | 517 } |
549 | 518 |
550 // may not work well for cubics | 519 // may not work well for cubics |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 (curve[4] - srcLeft) * scale, (curve[5] - srcTop) * scale, | 776 (curve[4] - srcLeft) * scale, (curve[5] - srcTop) * scale, |
808 (curve[6] - srcLeft) * scale, (curve[7] - srcTop) * scale); | 777 (curve[6] - srcLeft) * scale, (curve[7] - srcTop) * scale); |
809 } | 778 } |
810 if (draw_cubic_red ? curve.length == 8 : firstInside == curves) { | 779 if (draw_cubic_red ? curve.length == 8 : firstInside == curves) { |
811 ctx.strokeStyle = "rgba(255,0,0, 1)"; | 780 ctx.strokeStyle = "rgba(255,0,0, 1)"; |
812 } else { | 781 } else { |
813 ctx.strokeStyle = "rgba(0,0,255, 1)"; | 782 ctx.strokeStyle = "rgba(0,0,255, 1)"; |
814 } | 783 } |
815 ctx.stroke(); | 784 ctx.stroke(); |
816 if (draw_endpoints > 0) { | 785 if (draw_endpoints > 0) { |
817 drawPoint(curve[0], curve[1]); | 786 drawPoint(curve[0], curve[1], false); |
818 if (draw_endpoints > 1 || curve.length == 4) { | 787 if (draw_endpoints > 1 || curve.length == 4) { |
819 drawPoint(curve[2], curve[3]); | 788 drawPoint(curve[2], curve[3], curve.length == 4 && draw_endp
oints == 3); |
820 } | 789 } |
821 if (curve.length == 6 || curve.length == 7 || | 790 if (curve.length == 6 || curve.length == 7 || |
822 (draw_endpoints > 1 && curve.length == 8)) { | 791 (draw_endpoints > 1 && curve.length == 8)) { |
823 drawPoint(curve[4], curve[5]); | 792 drawPoint(curve[4], curve[5], (curve.length == 6 || curve.le
ngth == 7) && draw_endpoints == 3); |
824 } | 793 } |
825 if (curve.length == 8) drawPoint(curve[6], curve[7]); | 794 if (curve.length == 8) { |
| 795 drawPoint(curve[6], curve[7], curve.length == 8 && draw_endp
oints == 3); |
| 796 } |
826 } | 797 } |
827 if (draw_midpoint != 0) { | 798 if (draw_midpoint != 0) { |
828 if ((curves == 0) == (midLeft == 0)) { | 799 if ((curves == 0) == (midLeft == 0)) { |
829 ctx.strokeStyle = "rgba(0,180,127, 0.6)"; | 800 ctx.strokeStyle = "rgba(0,180,127, 0.6)"; |
830 } else { | 801 } else { |
831 ctx.strokeStyle = "rgba(127,0,127, 0.6)"; | 802 ctx.strokeStyle = "rgba(127,0,127, 0.6)"; |
832 } | 803 } |
833 var midX = x_at_t(curve, 0.5); | 804 var midX = x_at_t(curve, 0.5); |
834 var midY = y_at_t(curve, 0.5); | 805 var midY = y_at_t(curve, 0.5); |
835 drawPointSolid(midX, midY); | 806 drawPointSolid(midX, midY); |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 cClone.push(c[index]); | 1132 cClone.push(c[index]); |
1162 } | 1133 } |
1163 testClone.push(cClone); | 1134 testClone.push(cClone); |
1164 } | 1135 } |
1165 tests.push(testClone); | 1136 tests.push(testClone); |
1166 testTitles.push(testTitles[testIndex] + " copy"); | 1137 testTitles.push(testTitles[testIndex] + " copy"); |
1167 testIndex = tests.length - 1; | 1138 testIndex = tests.length - 1; |
1168 redraw(); | 1139 redraw(); |
1169 break; | 1140 break; |
1170 case 'e': | 1141 case 'e': |
1171 draw_endpoints = (draw_endpoints + 1) % 3; | 1142 draw_endpoints = (draw_endpoints + 1) % 4; |
1172 redraw(); | 1143 redraw(); |
1173 break; | 1144 break; |
1174 case 'f': | 1145 case 'f': |
1175 draw_derivative ^= true; | 1146 draw_derivative ^= true; |
1176 redraw(); | 1147 redraw(); |
1177 break; | 1148 break; |
1178 case 'i': | 1149 case 'i': |
1179 draw_ray_intersect = (draw_ray_intersect + 1) % 3; | 1150 draw_ray_intersect = (draw_ray_intersect + 1) % 3; |
1180 redraw(); | 1151 redraw(); |
1181 break; | 1152 break; |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1448 <body onLoad="start();"> | 1419 <body onLoad="start();"> |
1449 | 1420 |
1450 <canvas id="canvas" width="750" height="500" | 1421 <canvas id="canvas" width="750" height="500" |
1451 onmousedown="mouseDown = true" | 1422 onmousedown="mouseDown = true" |
1452 onmouseup="mouseDown = false" | 1423 onmouseup="mouseDown = false" |
1453 onmousemove="handleMouseOver()" | 1424 onmousemove="handleMouseOver()" |
1454 onclick="handleMouseClick()" | 1425 onclick="handleMouseClick()" |
1455 ></canvas > | 1426 ></canvas > |
1456 </body> | 1427 </body> |
1457 </html> | 1428 </html> |
OLD | NEW |