This repository has been archived by the owner on May 11, 2021. It is now read-only.
/
constructions_3.html
550 lines (483 loc) · 24.3 KB
/
constructions_3.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
<!DOCTYPE html>
<html data-require="math graphie graphie-geometry interactive constructions kmatrix">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Compass Constructions 3</title>
<script data-main="../local-only/main.js" src="../local-only/require.js"></script>
</head>
<body>
<div class="exercise">
<div class="problems">
<div id="on-circle">
<div class="vars">
<var id="SIZE">2</var>
<var id="ANGLE">randRange(1, 360)</var>
<var id="RAD">ANGLE * Math.PI / 180</var>
<var id="P">[SIZE * cos(ANGLE * Math.PI / 180), SIZE * sin(ANGLE * Math.PI / 180)]</var>
<var id="Q">[P[0] * 2, P[1] * 2]</var>
<var id="POSITION">["right", "above", "left", "below", "right"][round(ANGLE / 90)]</var>
<var id="POSITION2">["left", "below", "right", "above", "left"][round(ANGLE / 90)]</var>
</div>
<div class="problem">
<form>
<input onclick="javascript: KhanUtil.construction.addCompass();" type="button" value="Add Compass">
<input onclick="javascript: KhanUtil.construction.addStraightedge(false);" type="button" value="Add Straightedge">
<input onclick="javascript: KhanUtil.construction.removeAllTools();" type="button" value="Clear">
</form>
<p class="question">
Construct a line going through <code>P</code>, tangent to the circle.
</p>
<div class="graphie" id="construction">
init({
range: [[-5, 5], [-5, 5]],
scale: 50
});
addMouseLayer();
addConstruction("construction");
addDummyCircle([0, 0], SIZE);
addDummyPoint([0, 0]);
addDummyPoint(P);
label(P, "P", POSITION);
</div>
</div>
<div class="solution" data-type="custom">
<div class="instruction"></div>
<div class="guess">getToolProperties(construction)</div>
<div class="validator-function">
if (guess.length === 0) {
return "";
}
// Get lines going through P
var lines = _.filter(guess, function(tool) {
if (tool.first != null) {
return isPointOnLineSegment([tool.first.coord, tool.second.coord], P, 0.2);
}
});
// Of the lines going through P, does one have the correct angle?
var tangentLine = _.filter(lines, function(tool) {
return angleEqual(tool, (ANGLE + 90) % 180, 5);
});
if (tangentLine.length === 0) {
return false;
}
// Of the lines going through P, does one go through C too?
var connectingLine = _.filter(lines, function(tool) {
return isPointOnLineSegment([tool.first.coord, tool.second.coord], [0, 0], 0.2);
});
if (connectingLine.length === 0) {
return "Make sure you keep the straightedges you used in place.";
}
// Are there two compasses on the line segment CQ but not on P?
var compasses = _.filter(guess, function(tool) {
if (tool.center != null) {
return !distEqual(P, tool.center.coord, 0, 0.15) &&
isPointOnLineSegment([connectingLine[0].first.coord, connectingLine[0].second.coord], tool.center.coord, 0.2);
}
});
// Do two of these compasses have and have the same length radii?
for (var i = 0; i < compasses.length; i++) {
for (var j = i + 1; j < compasses.length; j++) {
if (abs(compasses[i].radius - compasses[j].radius) < 0.15) {
return true;
}
}
}
return "Make sure you keep the compasses you used in place.";
</div>
<div class="show-guess">
showConstructionGuess(guess);
</div>
</div>
<div class="hints">
<div>
<div class="graphie" data-update="construction">
var angle = (ANGLE + 90) * Math.PI / 180;
var dx = 10 * cos(angle);
var dy = 10 * sin(angle);
graph.hintLines = raphael.set();
graph.hintLines.push(line([P[0] - dx, P[1] - dy], [P[0] + dx, P[1] + dy],{
strokeWidth: 1,
stroke: BLUE
})).toBack();
</div>
<p>
We could just draw a line through <code>P</code> and <em>try</em> to get it right,
but then <strong>we have no guarantee</strong> that it's actually perfectly perpendicular.
</p>
<p>How can you guarantee that a line is really perpendicular?</p>
</div>
<div>
<div class="graphie" data-update="construction">
var dAngle = 30 * Math.PI / 180;
var d = SIZE / cos(dAngle);
graph.hintLines.push(drawHintLine([0, 0], [d * cos(RAD - dAngle), d * sin(RAD - dAngle)], 2)).toBack();
graph.hintLines.push(drawHintLine([0, 0], [d * cos(RAD + dAngle), d * sin(RAD + dAngle)], 2)).toBack();
graph.hintLines.push(drawHintLine([0, 0], P)).toBack();
</div>
<p>
If we pick <span class="hint_blue">two points</span> on the tangent line that are an equal
distance from <code>P</code>, they will also be the same distance from the center of the circle.
</p>
</div>
<div>
<div class="graphie" data-update="construction">
graph.hintLines.remove();
line([0, 0], [SIZE * 2.5 * cos(RAD), SIZE * 2.5 * sin(RAD)], {
strokeWidth: 2,
stroke: GRAY
}).toBack();
label([0, 0], "C", POSITION2);
</div>
<p>
Draw a line that passes through the center of the circle, <code>C</code>, and <code>P</code>.
</p>
</div>
<div>
<div class="graphie" data-update="construction">
circle(P, SIZE, {
fill: "none",
strokeDasharray: "- ",
strokeWidth: 1,
stroke: GRAY
});
circle(Q, 0.08, {
fill: GRAY,
stroke: null
});
label(Q, "Q", POSITION);
</div>
<p>
Use a compass with the same radius as the original circle to find a point on the line,
<code>Q</code>, such <code>\overline{PQ} = \overline{PC}</code>.
</p>
</div>
<p>
Point <code>P</code> bisects the line <code>\overline{QC}</code>, so if we construct a
perpendicular bisector of the line it will pass through point <code>P</code> and be tangent to the circle.
</p>
<div>
<div class="graphie" data-update="construction">
graph.d = SIZE * 1.6;
circle([0, 0], graph.d, {
fill: "none",
strokeDasharray: "- ",
strokeWidth: 1,
stroke: GRAY
});
circle(Q, graph.d, {
fill: "none",
strokeDasharray: "- ",
strokeWidth: 1,
stroke: GRAY
});
</div>
<p>
Create two compasses of the same size, one centered at <code>C</code> and one centered at <code>Q</code>.
</p>
</div>
<div>
<div class="graphie" data-update="construction">
var dAngle = acos(SIZE / graph.d);
var p1 = [graph.d * cos(RAD - dAngle), graph.d * sin(RAD - dAngle)];
var p2 = [graph.d * cos(RAD + dAngle), graph.d * sin(RAD + dAngle)];
line(p1, p2, {
strokeWidth: 2,
stroke: GRAY
});
circle(p1, 0.08, {
fill: GRAY,
stroke: null
});
circle(p2, 0.08, {
fill: GRAY,
stroke: null
});
</div>
<p>Join the points where these two compasses intersect.</p>
</div>
</div>
</div>
<div id="off-circle">
<div class="vars">
<var id="SIZE">2</var>
<var id="ANGLE">randRange(1, 360)</var>
<var id="RAD">ANGLE * Math.PI / 180</var>
<var id="D">2 * SIZE + randRange(-1, 2)</var>
<var id="D1">D * randRange(3, 7) / 10</var>
<var id="D2">D1 - D</var>
<var id="DP">(D1 + D2) / 2</var>
<var id="TANGENT_ANGLES">[
((RAD - asin(SIZE / D)) * 180 / Math.PI) % 180,
((RAD + asin(SIZE / D)) * 180 / Math.PI) % 180]
</var>
<var id="C">[D1 * cos(ANGLE * Math.PI / 180), D1 * sin(ANGLE * Math.PI / 180)]</var>
<var id="P">[D2 * cos(ANGLE * Math.PI / 180), D2 * sin(ANGLE * Math.PI / 180)]</var>
<var id="X">[DP * cos(ANGLE * Math.PI / 180), DP * sin(ANGLE * Math.PI / 180)]</var>
<var id="POSITION">["right", "above", "left", "below", "right"][round(ANGLE / 90)]</var>
<var id="POSITION2">["left", "below", "right", "above", "left"][round(ANGLE / 90)]</var>
</div>
<div class="problem">
<form>
<input onclick="javascript: KhanUtil.construction.addCompass();" type="button" value="Add Compass">
<input onclick="javascript: KhanUtil.construction.addStraightedge(false);" type="button" value="Add Straightedge">
<input onclick="javascript: KhanUtil.construction.removeAllTools();" type="button" value="Clear">
</form>
<p class="question">
Construct a line going through <code>P</code>, tangent to the circle.
</p>
<div class="graphie" id="construction">
init({
range: [[-5, 5], [-5, 5]],
scale: 50
});
addMouseLayer();
addConstruction("construction");
addDummyCircle(C, SIZE);
addDummyPoint(C);
addDummyPoint(P);
label(P, "P", POSITION);
label(C, "C", POSITION2);
</div>
</div>
<div class="solution" data-type="custom">
<div class="instruction"></div>
<div class="guess">getToolProperties(construction)</div>
<div class="validator-function">
if (guess.length === 0) {
return "";
}
// Find tangent line
var tangent = _.filter(guess, function(tool) {
if (tool.first != null) {
if (isPointOnLineSegment([tool.first.coord, tool.second.coord], P, 0.2)) {
return angleEqual(tool, TANGENT_ANGLES[0], 4) || angleEqual(tool, TANGENT_ANGLES[1], 5);
}
}
});
if (tangent.length < 1) {
return false;
}
// Get lines going through X
var lines = _.filter(guess, function(tool) {
if (tool.first != null) {
return isPointOnLineSegment([tool.first.coord, tool.second.coord], X, 0.2);
}
});
if (lines.length < 2) {
return "Make sure you keep the straightedges you used in place.";
}
// Check there is a line going through P and C
var connectingLine = _.filter(lines, function(tool) {
return isPointOnLineSegment([tool.first.coord, tool.second.coord], P, 0.2) &&
isPointOnLineSegment([tool.first.coord, tool.second.coord], C, 0.2);
});
// Check there is a perpendicular bisector of the line PC
var bisectingLine = _.filter(lines, function(tool) {
return angleEqual(tool, (ANGLE + 90) % 180, 5);
});
if (connectingLine.length * bisectingLine.length === 0) {
return "Make sure you keep the straightedges you used in place.";;
}
// Test whether there is a compass centered on X with the correct radius
var compass = findCompass(guess, {center: X, radius: D / 2});
if (compass.length === 0) {
return "Make sure you keep the compasses you used in place.";
} else {
return true;
}
</div>
<div class="show-guess">
showConstructionGuess(guess);
</div>
</div>
<div class="hints">
<div>
<div class="graphie" data-update="construction">
var angle = TANGENT_ANGLES[0] * Math.PI / 180;
graph.dx = 10 * cos(angle);
graph.dy = 10 * sin(angle);
graph.hintLines = raphael.set();
graph.hintLines.push(line([P[0] - graph.dx, P[1] - graph.dy], [P[0] + graph.dx, P[1] + graph.dy],{
strokeWidth: 1,
stroke: BLUE
})).toBack();
</div>
<p>
We could just draw a line through <code>P</code> and <em>try</em> to get it right,
but then <strong>we have no guarantee</strong> that it's actually perfectly tangent.
</p>
<p>How can you guarantee that a line is really tangent? </p>
</div>
<div>
<div class="graphie" data-update="construction">
var angle1 = RAD - asin(SIZE / D);
var angle2 = RAD + asin(SIZE / D);
var d = Math.sqrt(D * D - SIZE * SIZE)
graph.tangent1 = [P[0] + d * cos(angle1), P[1] + d * sin(angle1)];
graph.tangent2 = [P[0] + d * cos(angle2), P[1] + d * sin(angle2)];
graph.hintLines.push(drawHintLine(C, P)).toBack();
style({
strokeWidth: 1,
stroke: BLUE
}, function() {
graph.hintLines.push(line(C, graph.tangent1));
graph.hintLines.push(line(C, graph.tangent2));
graph.hintLines.push(line(P, graph.tangent2));
});
graph.hintLines.push(circle(X, D / 2, {
stroke: BLUE,
strokeWidth: 1,
fill: "none",
strokeDasharray: "- "
}));
graph.hintLines.push(circle(X, 0.08, {
fill: BLUE,
stroke: null
}));
</div>
<p>
If we can draw a quadrilateral inscribed in a circle, its opposite angles must sum to <code>180^\circ</code>.
If the two angles are equal, then both must be <code>90^\circ</code>.
</p>
<p>Therefore we need to find a circle for which <code>P</code> and <code>C</code> are on opposite sides.</p>
</div>
<div>
<div class="graphie" data-update="construction">
graph.hintLines.remove();
line(C, P, {
strokeWidth: 2,
stroke: GRAY
}).toBack();
</div>
<p>
First draw a line connecting the center of the circle, <code>C</code>, to <code>P</code>.
</p>
</div>
<div>
<div class="graphie" data-update="construction">
graph.d = D * 0.65;
circle(C, graph.d, {
fill: "none",
strokeDasharray: "- ",
strokeWidth: 1,
stroke: GRAY
});
circle(P, graph.d, {
fill: "none",
strokeDasharray: "- ",
strokeWidth: 1,
stroke: GRAY
});
</div>
<p> Now we want to bisect the line <code>CP</code>.
So create two compasses with the same radius, one centered at <code>C</code> and one centered at <code>P</code>.
</p>
</div>
<div>
<div class="graphie" data-update="construction">
var dAngle = acos(D / graph.d / 2);
var p1 = [C[0] - graph.d * cos(RAD - dAngle), C[1] - graph.d * sin(RAD - dAngle)];
var p2 = [C[0] - graph.d * cos(RAD + dAngle), C[1] - graph.d * sin(RAD + dAngle)];
line(p1, p2, {
strokeWidth: 2,
stroke: GRAY
});
circle(p1, 0.08, {
fill: GRAY,
stroke: null
});
circle(p2, 0.08, {
fill: GRAY,
stroke: null
});
</div>
<p>Join the points where these two compasses intersect to the bisect line <code>CP</code>.</p>
</div>
<div>
<div class="graphie" data-update="construction">
circle(X, 0.08, {
fill: GRAY,
stroke: null
});
circle(X, D / 2, {
fill: "none",
strokeDasharray: "- ",
strokeWidth: 1,
stroke: GRAY
});
</div>
<p>Now we can draw a circle halfway between <code>C</code> and <code>P</code> with a radius that goes through both.</p>
</div>
<div>
<div class="graphie" data-update="construction">
circle(graph.tangent1, 0.08, {
fill: GRAY,
stroke: null
});
circle(graph.tangent2, 0.08, {
fill: GRAY,
stroke: null
});
if (graph.tangent1[1] > C[1]) {
label(graph.tangent1, "A", "above");
} else {
label(graph.tangent1, "A", "below");
}
if (graph.tangent2[1] > C[1]) {
label(graph.tangent2, "B", "above");
} else {
label(graph.tangent2, "B", "below");
}
path([C, graph.tangent1, P, graph.tangent2, C], {
fill: GREEN,
'fill-opacity': 0.4,
stroke: GREEN,
strokeWidth: 2
}).toBack();
var drawRightAngleMarker = function(p, flip) {
var x = p[0];
var y = p[1];
var dx = x - P[0];
var dy = y - P[1];
var norm = sqrt(dx * dx + dy * dy);
dx /= norm * 5;
dy /= norm * 5;
//circle([x - dx, y - dy], 0.1);
path([[x, y], [x - dx, y - dy], [x - dx - dy * flip, y + dx * flip - dy], [x - dy * flip, y + dx * flip]], {
fill: null,
stroke: BLACK,
strokeWidth: 1
})
}
drawRightAngleMarker(graph.tangent1, 1);
drawRightAngleMarker(graph.tangent2, -1);
</div>
<p>
This circle intersects the original circle at points <code>A</code> and <code>B</code>.
<code>\green{PACB}</code> forms a quadrilateral inscribed inside this circle so its opposite angles sum to <code>180^\circ</code>.
<code>\triangle PAC</code> and <code>\triangle PBC</code> are congruent triangles,
so <code>\angle PAC = \angle PBC</code>. Therefore both angles are <code>90^\circ</code>.
</p>
</div>
<div>
<div class="graphie" data-update="construction">
var angle = TANGENT_ANGLES[1] * Math.PI / 180;
var dx = 10 * cos(angle);
var dy = 10 * sin(angle);
graph.hintLines.push(line([P[0] - graph.dx, P[1] - graph.dy], [P[0] + graph.dx, P[1] + graph.dy],{
strokeWidth: 2,
stroke: GRAY
}))
graph.hintLines.push(line([P[0] - dx, P[1] - dy], [P[0] + dx, P[1] + dy],{
strokeWidth: 2,
stroke: GRAY
}))
</div>
<p>Therefore a line from <code>P</code> to either <code>A</code> or <code>B</code> will be tangent to the original circle.</p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>