This repository has been archived by the owner on May 11, 2021. It is now read-only.
/
translations_of_points_and_polygons.html
226 lines (208 loc) · 11 KB
/
translations_of_points_and_polygons.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
<!DOCTYPE html>
<html data-require="math graphie geom interactive">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Translating Polygons</title>
<script src="../khan-exercise.js"></script>
<style type="text/css">
#answer_area input[type=text] {
width: 30px;
}
</style>
</head>
<body>
<div class="exercise">
<div class="problems">
<div id="drag">
<div class="vars">
<var id="SX,SY,EX,EY" data-ensure="SX !== EX || SY !== EY">randRange(-4, 4, 4)</var>
<var id="DX,DY">[EX - SX, EY - SY]</var>
<var id="POINTS">_.map(_.range(6), function() {
return {x: randRange(-4, 4), y: randRange(-4, 4)};
})</var>
<var id="HULL">_.map(Geom.convexhull(POINTS), function(p) {
return [p.x + SX, p.y + SY];
})</var>
<var id="TARGET"> _.map(HULL, function(p) {
return [p[0] + DX, p[1] + DY];
})</var>
</div>
<p class="question">
What is the image of the polygon below after the translation <code>T_{(<var>DX</var>, <var>DY</var>)}</code>?
</p>
<div class="problem">
<div class="graphie" id="grid">
graphInit({
range: 11,
scale: 20,
axisArrows: "<->",
tickStep: 1,
labelStep: 1,
gridOpacity: 0.05,
axisOpacity: 0.2,
tickOpacity: 0.4,
labelOpacity: 0.5
});
for (var i=0; i < HULL.length; i++) {
line(HULL[i], HULL[(i+1) % HULL.length], { stroke: GRAY, strokeDasharray: "- " });
}
addMouseLayer();
graph.points = _.map(HULL, function(point) { return addMovablePoint({ coord: point, visible: false }); });
graph.lines = [];
for (var i=0; i < graph.points.length; i++) {
graph.lines.push(addMovableLineSegment({ pointA: graph.points[i], pointZ: graph.points[(i+1) % graph.points.length], snapX: 1, snapY: 1}));
}
_.each(graph.lines, function(line) { line.onMove = function(dX, dY){ graph.updatePolygon(dX, dY); }});
graph.updatePolygon = function(dX, dY) {
_.each(graph.points, function(point){ point.setCoord([point.coord[0] + dX, point.coord[1] + dY]); point.updateLineEnds(); });
graph.curPoints = _.map(graph.points, function(point){ return point.coord; });
}
graph.showGuess = function() {
_.each(graph.points, function(point) { point.remove(); });
_.each(graph.lines, function(line) { line.remove(); });
graph.points = _.map(graph.curPoints, function(point) { return addMovablePoint({ coord: point, visible: false }); });
graph.lines = [];
for (var i=0; i < graph.points.length; i++) {
graph.lines.push(addMovableLineSegment({ pointA: graph.points[i], pointZ: graph.points[(i+1) % graph.points.length], snapX: 1, snapY: 1}));
}
}
graph.drawAnswer = function() {
for (var i=0; i < TARGET.length; i++) {
line(TARGET[i], TARGET[(i+1) % TARGET.length], { stroke: ORANGE });
}
}
</div>
</div>
<div class="solution" data-type="custom">
<div class="instruction">
Drag the blue polygon to its image under the given translation.
</div>
<div class="guess"> KhanUtil.currentGraph.graph.curPoints
</div>
<div class="validator-function">
coordList = _.map(KhanUtil.currentGraph.graph.points, function(point){ return point.coord; });
return _.all(coordList, function(point) {
return (point[0] === TARGET[_.indexOf(coordList, point)][0])
&& (point[1] === TARGET[_.indexOf(coordList, point)][1]);
});
</div>
<div class="show-guess">
KhanUtil.currentGraph.graph.curPoints = guess;
KhanUtil.currentGraph.graph.showGuess();
</div>
</div>
<div class="hints">
<p>
A translation <code>T_{(a, b)}</code> moves points <code>a</code> units in the <code>x</code> direction (right if
<code>a</code> is positive,left if <code>a</code> is negative) and
<code>b</code> units in the <code>y</code> direction (up if <code>b</code> is positive, down if <code>b</code> is negative).
</p>
<div>
To see where a translation moved this polygon, pick one point and translate it. For example, what happens to
<code>(<var> HULL[0][0] </var>,<var> HULL[0][1] </var>)</code> under this translation?
<div class="graphie" data-update="grid">
circle(HULL[0], { r: 0.2, fill: "black", stroke: "none" });
</div>
</br></br>
</div>
<div>
Under the translation <code>T_{(<var>DX</var>, <var>DY</var>)}</code>, <code>(<var> HULL[0][0] </var>,<var> HULL[0][1] </var>)</code> is translated to <code>(<var> TARGET[0][0] </var>,<var> TARGET[0][1] </var>)</code>. Where is the rest of the polygon translated?
<div class="graphie" data-update="grid">
circle(TARGET[0], { r: 0.2, fill: "black", stroke: "none" });
line(HULL[0], TARGET[0], { stroke: "black", arrows: "->"});
</div>
</br></br>
</div>
<div>
To get from <code>(<var> HULL[0][0] </var>,<var> HULL[0][1] </var>)</code> to <code>(<var> TARGET[0][0] </var>,<var> TARGET[0][1] </var>)</code>, we changed the x-coordinate by <var>DX</var> and the y-coordinate by <var>DY</var>. To translate the whole polygon, we need
to do the same thing to all of its points.
</br></br>
</div>
<div>
The orange outline shows where the polygon ends up after the translation.
<div class="graphie" data-update="grid">
for (var i=0; i < TARGET.length; i++) {
line(TARGET[i], TARGET[(i+1) % TARGET.length], { stroke: ORANGE });
}
</div>
</div>
</div>
</div>
<div id="reverse">
<div class="vars">
<var id="SX,SY,EX,EY" data-ensure="SX !== EX || SY !== EY">randRange(-4, 4, 4)</var>
<var id="DX,DY">[EX - SX, EY - SY]</var>
<var id="POINTS">_.map(_.range(6), function() {
return {x: randRange(-4, 4), y: randRange(-4, 4)};
})</var>
<var id="HULL">_.map(Geom.convexhull(POINTS), function(p) {
return [p.x + SX, p.y + SY];
})</var>
<var id="TARGET"> _.map(HULL, function(p) {
return [p[0] + DX, p[1] + DY];
})</var>
</div>
<p class="question">
What was the translation applied to move the blue solid shape to the orange dashed shape?
</p>
<div class="problem">
<div class="graphie" id="grid">
graphInit({
range: 11,
scale: 20,
axisArrows: "<->",
tickStep: 1,
labelStep: 1,
gridOpacity: 0.05,
axisOpacity: 0.2,
tickOpacity: 0.4,
labelOpacity: 0.5
});
for (var i=0; i < HULL.length; i++) {
line(HULL[i], HULL[(i+1) % HULL.length], { stroke: BLUE });
}
for (var i=0; i < TARGET.length; i++) {
line(TARGET[i], TARGET[(i+1) % TARGET.length], { stroke: ORANGE, strokeDasharray: "- " });
}
</div>
</div>
<div class="solution" data-type="multiple"><code>{\LARGE T } \;(</code>
<span class="sol" style="width:15px" data-fallback="1"><var>DX</var></span>
<code>,</code>
<span class="sol" style="width:15px" data-fallback="1"><var>DY</var></span>
<code>)</code>
</div>
<div class="hints">
<p>
A translation <code>T_{(a, b)}</code> moves points a units in the x direction (right if a is positive, left if a is negative) and
b units in the y direction (up if b is positive, down if b is negative).
</p>
<div>
To see what translation moved the blue polygon, pick one point and translate it. For example, what happened to
<code>(<var> HULL[0][0] </var>,<var> HULL[0][1] </var>)</code> under this translation?
<div class="graphie" data-update="grid">
circle(HULL[0], { r: 0.2, fill: "black", stroke: "none" });
</div>
</br></br>
</div>
<div>
Under this translation, <code>(<var> HULL[0][0] </var>,<var> HULL[0][1] </var>)</code> was translated to <code>(<var> TARGET[0][0] </var>,<var> TARGET[0][1] </var>)</code>. What does this tell you about the translation used?
<div class="graphie" data-update="grid">
circle(TARGET[0], { r: 0.2, fill: "black", stroke: "none" });
line(HULL[0], TARGET[0], { stroke: "black", arrows: "->"});
</div>
</br></br>
</div>
<div>
To get from <code>(<var> HULL[0][0] </var>,<var> HULL[0][1] </var>)</code> to <code>(<var> TARGET[0][0] </var>,<var> TARGET[0][1] </var>)</code>, we changed the x-coordinate by <var>DX</var> and the y-coordinate by <var>DY</var>.
</br></br>
</div>
<div>
The translation used was <code>T_{(<var>DX</var>, <var>DY</var>)}</code>.
</div>
</div>
</div>
</div>
</div>
</body>
</html>