/
trigonometry.php
297 lines (250 loc) · 14.6 KB
/
trigonometry.php
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
<?php
$title = 'Trigonometry - Mathematics Playground';
require_once('header.php');
?>
<div class="container-fluid">
<?php require_once('menu.html'); ?>
<div class="span9">
<div class="hero-unit">
<h1>Trigonometry</h1>
</div>
<div class="dropdown clearfix" style='float: right; margin-left: 1em;'>
<ul class="dropdown-menu" style="display: block; position: static; margin-bottom: 5px; *width: 180px;">
<li><a href="#radians">Radians</a></li>
<li><a href="#pythagoras">Pythagoras</a></li>
<li><a href="#sincostan">Unit Circle — Sine, Cosine and Tangent</a></li>
<li><a href="#equationcircle">Equation of a Circle</a></li>
</ul>
</div>
<div>
<h2 id='radians'>Radians</h2>
<br />
<p>Drag the black and white point around the circle to see its angle in both radians and degrees.</p>
<br /><br />
<center><div id='radgraph' class='jxgbox medgraph'></div></center>
<div class='graphcontrols'><button onclick="JXG.JSXGraph.freeBoard(radjsx); initRad();">Reset positions</button> <span class='mousepos' id='radmousepos'></span></div>
<br />
<center>
<span id='rad'>θ</span>$ * \frac{180}{\pi} = $<span id='deg'>0</span>°
</center>
<br /><br />
<script type='text/javascript'>
function initRad() {
radjsx = JXG.JSXGraph.initBoard('radgraph', {boundingbox: [-1.5, 1.5, 1.5, -1.5], grid: true, pan: true, zoom: true, showcopyright: false, axis: true, pan: {needShift: false}});
var radcirc = radjsx.create('circle', [[0, 0], 1], {fillColor: '#ccf', highlightFillColor: '#ccf', fillOpacity: 0.5, highlightFillOpacity: 0.5, strokeColor: 'black', highlightStrokeColor: 'black'});
var radcentre = radjsx.create('point', [0, 0], {strokeColor: 'black', fillColor: 'black', size: 1, name: '', fixed: true, borderColor: 'black'});
var radstart = radjsx.create('point', [1, 0], {strokeColor: 'black', fillColor: 'black', size: 1, name: '', fixed: true, borderColor: 'black'});
var radend = radjsx.create('point', [0, 0], {strokeColor: 'black', fillColor: 'black', size: 1, name: '', fixed: false, borderColor: 'black'});
var radangle = radjsx.create('glider', [0.45, 0.45, radcirc], {strokeColor: 'black', fillColor: 'white', name: ''});
radend.setPosition(JXG.COORDS_BY_USER, [radangle.X(), radangle.Y()]);
var radsector = radjsx.create('angle', [radstart, radcentre, radend], {type:'sector', orthoType:'sector', radius: 1.0, name: ' '});
radjsx.create('text', [0.77, 0.77, "π/4"], {fixed: true});
radjsx.create('text', [-0.05, 1.1, "π/2"], {fixed: true});
radjsx.create('text', [-0.9, 0.78, "3π/4"], {fixed: true});
radjsx.create('text', [-1.1, 0.0, "π"], {fixed: true});
radjsx.create('text', [-0.9, -0.78, "5π/4"], {fixed: true});
radjsx.create('text', [-0.07, -1.15, "3π/2"], {fixed: true});
radjsx.create('text', [0.77, -0.78, "7π/4"], {fixed: true});
radjsx.create('text', [1.1, 0.0, "0 or 2π"], {fixed: true});
radjsx.on('update', function() {
radend.setPosition(JXG.COORDS_BY_USER, [radangle.X(), radangle.Y()]);
rad = Math.acos(radangle.X());
if(radangle.Y() < 0) {
rad = (Math.PI + (Math.PI - rad))
}
deg = (rad * 180/Math.PI);
radangle.setLabelText(rad.toFixed(2) + " rad or " + deg.toFixed(0) + "°");
$("#rad").html(rad.toFixed(2) + ' ');
$("#deg").html(' ' + deg.toFixed(2));
});
radjsx.on('mousemove', function(e) {
var mPos = radjsx.getUsrCoordsOfMouse(e);
$('#radmousepos').text(mPos[0].toFixed(2) + ', ' + mPos[1].toFixed(2));
});
radjsx.update();
}
initRad();
</script>
<h2 id='pythagoras'>Pythagoras</h2>
<br />
$a^2 + b^2 = c^2$
<br /><br />
<p>Move the sliders on the following graph to change the length of the sides in a right angled triangle. Click the <em>"Show squares"</em> option to display squares attached to each side of the triangle. The value of the hypotenuse is calculated based on Pythagoras' theorem and displayed below the graph.</p>
<br /><br />
<center><div id='pythgraph' class='jxgbox medgraph'></div></center>
<div class='graphcontrols'><button onclick="JXG.JSXGraph.freeBoard(pythjsx); initPyth();">Reset positions</button> <span class='mousepos' id='pythmousepos'></span><br /><br /><input type='checkbox' id='showsquares' onclick='showSquares();' /><label for='showsquares'>Show squares</label></div>
<center>
<span id='pya'>a</span>$^2 + $<span id='pyb'>b</span>$^2 = $<span id='pyc'> c</span>$^2$<br />
<small><span id='pyasq'>a</span>$ + $<span id='pybsq'>b</span>$ = $<span id='pycsq'> c</span></small>
</center>
<script type='text/javascript'>
function initPyth() {
pythjsx = JXG.JSXGraph.initBoard('pythgraph', {boundingbox: [-18, 32, 32, -18], grid: true, pan: true, zoom: true, showcopyright: false, axis: true, pan: {needShift: false}});
var pa = pythjsx.createElement('slider', [[1,1], [1,15], [0,8,14]], {name:'a', snapWidth:0.1});
var pb = pythjsx.createElement('slider', [[1,1], [15,1], [0,6,14]], {name:'b', snapWidth:0.1});
var corner = pythjsx.create('point', [1,1], {strokeColor: 'black', fillColor: 'black', size: 1, name: '', fixed: true, borderColor: 'black'});
var poly = pythjsx.create('polygon', [pa, pb, corner]);
sqa = pythjsx.create('regularpolygon', [corner, pa, 4], {fillColor: '#88f', highlight: false, withLabel: true, visible: false, label: {offset: [-15, 10]}});
sqa.vertices[2].hideElement();
sqa.vertices[3].hideElement();
sqb = pythjsx.create('regularpolygon', [pb, corner, 4], {fillColor: '#f88', highlight: false, withLabel: true, visible: false, label: {offset: [-15, 10]}});
sqb.vertices[2].hideElement();
sqb.vertices[3].hideElement();
sqc = pythjsx.create('regularpolygon', [pa, pb, 4], {fillColor: '#f18', highlight: false, withLabel: true, visible: false, label: {offset: [-15, 10]}});
sqc.vertices[2].hideElement();
sqc.vertices[3].hideElement();
pythjsx.attr.pan.needShift = true;
pythjsx.on('update', function() {
sqa.setLabelText(sqa.Area().toFixed(2));
sqb.setLabelText(sqb.Area().toFixed(2));
sqc.setLabelText(sqc.Area().toFixed(2));
$('#pyasq').text(' ' + sqa.Area().toFixed(2));
$('#pybsq').text(' ' + sqb.Area().toFixed(2));
$('#pycsq').text(' ' + sqc.Area().toFixed(2));
$('#pya').text(' ' + Math.sqrt(sqa.Area()).toFixed(2));
$('#pyb').text(' ' + Math.sqrt(sqb.Area()).toFixed(2));
$('#pyc').text(' ' + Math.sqrt(sqc.Area()).toFixed(2));
});
pythjsx.on('mousemove', function(e) {
var mPos = pythjsx.getUsrCoordsOfMouse(e);
$('#pythmousepos').text(mPos[0].toFixed(2) + ', ' + mPos[1].toFixed(2));
});
$("#showsquares").attr("checked", false);
pythjsx.update();
}
function showSquares() {
if($("#showsquares").is(':checked')) {
sqa.showElement();
sqb.showElement();
sqc.showElement();
sqa.label.content.showElement();
sqb.label.content.showElement();
sqc.label.content.showElement();
pythjsx.update();
} else {
sqa.hideElement();
sqb.hideElement();
sqc.hideElement();
}
}
initPyth();
</script>
<br /><br />
<h2 id='sincostan'>Unit Circle — Sine, Cosine and Tangent</h2>
<br />
<p>Drag the black and white point around the circle and watch the sine, cosine and tangent change.</p>
<br /><br />
<center><div id='unitgraph' class='jxgbox' style='width: 325px; height: 325px; float: left; margin-left: 10px;'></div> <div id='singraph' class='jxgbox' style='width: 325px; height: 325px;'></div></center><br /><br />
<center>
$sin($<span id='sinrad'>θ</span>$) = $<span id='sin'>0</span><br />
$cos($<span id='cosrad'>θ</span>$) = $<span id='cos'>0</span><br />
$tan($<span id='tanrad'>θ</span>$) = $<span id='tan'>0</span><br />
</center>
<script type='text/javascript'>
var unitjsx = JXG.JSXGraph.initBoard('unitgraph', {boundingbox: [-1.5, 1.5, 1.5, -1.5], grid: true, pan: true, zoom: true, showcopyright: false, axis: true, pan: {needShift: false}});
var sinjsx = JXG.JSXGraph.initBoard('singraph', {boundingbox: [0, 1.5, 6.31, -1.5], grid: true, pan: true, zoom: true, showcopyright: false, axis: false, pan: {needShift: false}});
sinjsx.create('axis', [[0, 0], [1, 0]], {ticks: {scale: Math.PI, scaleSymbol: 'π'}});
sinjsx.create('axis', [[0, 0], [0, 1]]);
var singraph = sinjsx.create('functiongraph', [ function(t) { return Math.sin(t); }, -100, 100],{strokeColor: "#00f"});
var sinpos = sinjsx.create('point', [0, 0, singraph], {strokeColor: '#00f', fixed: true, fillColor: '#00f', name: ''});
var cospos = sinjsx.create('point', [0, 1, singraph], {strokeColor: '#f00', fixed: true, fillColor: '#f00', name: ''});
sinpos.setPosition(JXG.COORDS_BY_USER, [rad, Math.sin(rad)]);
var tanpos = sinjsx.create('point', [0, 0, singraph], {strokeColor: '#0f0', fixed: true, fillColor: '#0f0', name: ''});
sinjsx.create('functiongraph', [ function(t) { return Math.cos(t); }, -100, 100],{strokeColor: "#f00"});
sinjsx.create('functiongraph', [ function(t) { return Math.tan(t); }, -100, 100],{strokeColor: "#0f0"});
var circ = unitjsx.create('circle', [[0, 0], 1], {fillColor: '#ccf', highlightFillColor: '#ccf', fillOpacity: 0.5, highlightFillOpacity: 0.5, strokeColor: 'black', highlightStrokeColor: 'black'});
var sp = unitjsx.create('point', [1, 0], {visible: false, fixed: true, name: ''});
var scp = unitjsx.create('point', [0, 0], {visible: false, fixed: true, name: ''});
var sinline = unitjsx.create('line', [sp, scp], {strokeColor: '#00f', name: ''});
unitjsx.create('text',[
function(){return (sp.X() + scp.X()) * 0.5 + 0.1;},
function(){return (sp.Y() + scp.Y()) * 0.5;},
'sin']);
sinline.setLabelRelativeCoords([3, -35]);
sinline.setStraight(false, false);
var cosline = unitjsx.create('line', [[0, 0], scp], {strokeColor: '#f00', name: ''});
unitjsx.create('text',[
function(){return scp.X() * 0.5;},
function(){return 0.1;},
'cos']);
cosline.setStraight(false, false);
var unitangle = unitjsx.create('glider', [0.45, 0.45, circ], {strokeColor: 'black', fillColor: 'white', name: ''});
var unittan = unitjsx.create('tangent', [unitangle], {visible: false});
var ax = unitjsx.create('line', [[0, 0], [1, 0]], {visible: false});
var tanint = unitjsx.create('intersection', [unittan, ax, 0], {visible: false});
var tanline = unitjsx.create('line', [sp, tanint], {strokeColor: '#0f0', name: ''});
tanline.setStraight(false, false);
unitjsx.create('text',[
function(){return (sp.X() + tanint.X()) * 0.5 + 0.1;},
function(){return (sp.Y() + tanint.Y()) * 0.5;},
'tan']);
sp.setPosition(JXG.COORDS_BY_USER, [unitangle.X(), unitangle.Y()]);
scp.setPosition(JXG.COORDS_BY_USER, [unitangle.X(), 0]);
unitjsx.create('text', [0.77, 0.77, "π/4"], {fixed: true});
unitjsx.create('text', [-0.05, 1.1, "π/2"], {fixed: true});
unitjsx.create('text', [-0.9, 0.78, "3π/4"], {fixed: true});
unitjsx.create('text', [-1.1, 0.0, "π"], {fixed: true});
unitjsx.create('text', [-0.9, -0.78, "5π/4"], {fixed: true});
unitjsx.create('text', [-0.07, -1.15, "3π/2"], {fixed: true});
unitjsx.create('text', [0.77, -0.78, "7π/4"], {fixed: true});
unitjsx.create('text', [1.1, 0.0, "0 or 2π"], {fixed: true});
unitjsx.on('update', function(){
rad = Math.acos(unitangle.X());
if(unitangle.Y() < 0) {
rad = (Math.PI + (Math.PI - rad));
}
unitangle.setLabelText(rad.toFixed(2) + " rad");
sinpos.setPosition(JXG.COORDS_BY_USER, [rad, Math.sin(rad)]);
cospos.setPosition(JXG.COORDS_BY_USER, [rad, Math.cos(rad)]);
tanpos.setPosition(JXG.COORDS_BY_USER, [rad, Math.tan(rad)]);
sp.setPosition(JXG.COORDS_BY_USER, [unitangle.X(), unitangle.Y()]);
scp.setPosition(JXG.COORDS_BY_USER, [unitangle.X(), 0]);
$('#sinrad').text(rad.toFixed(2));
$('#cosrad').text(rad.toFixed(2));
$('#tanrad').text(rad.toFixed(2));
$('#sin').text(' ' + Math.sin(rad).toFixed(2));
$('#cos').text(' ' + Math.cos(rad).toFixed(2));
$('#tan').text(' ' + Math.tan(rad).toFixed(2));
sinjsx.update();
});
unitjsx.update();
sinjsx.update();
</script>
<br /><br />
<h2 id='equationcircle'>Equation of a Circle</h2>
<br />
$(X - a)^2 + (Y - b)^2 = r^2$
<br /><br />
<p>The graph below displays a circle which can have its radius modified via the slider at the top, and its position changed by dragging the central point. The equation for this specific circle is displayed underneath the graph.</p>
<br />
<center><div id='circgraph' class='jxgbox medgraph'></div></center>
<div class='graphcontrols'><button onclick="JXG.JSXGraph.freeBoard(jsx); initCirc();">Reset positions</button> <span class='mousepos' id='mousepos'></span></div>
<br />
<center>$(X - $<span id='a'>a</span>$)^2 + (Y - $<span id='b'>b</span>$)^2 = $<span id='r'>r</span>$^2$</center>
<script type='text/javascript'>
function initCirc() {
jsx = JXG.JSXGraph.initBoard('circgraph', {boundingbox: [-6, 6, 6, -6], grid: true, pan: true, zoom: true, showcopyright: false, axis: true, pan: {needShift: false}});
jsx.attr.pan.needShift = true;
var r = jsx.createElement('slider', [[-5,5], [4.5,5], [0,1,5]], {name:'r', snapWidth:0.1});
var centre = jsx.create('point', [0,0], {strokeColor: 'black', fillColor: 'white', name:''});
var circ = jsx.create('circle', [centre, 1], {fillColor: '#ccf', highlightFillColor: '#ccf', fillOpacity: 0.5, highlightFillOpacity: 0.5, strokeColor: 'black', highlightStrokeColor: 'black'});
jsx.on('update', function() {
circ.setRadius(r.Value());
$('#a').text(' ' + circ.center.X().toFixed(2));
$('#b').text(' ' + circ.center.Y().toFixed(2));
$('#r').text(' ' + circ.getRadius().toFixed(2));
});
jsx.on('mousemove', function(e) {
var mPos = jsx.getUsrCoordsOfMouse(e);
$('#mousepos').text(mPos[0].toFixed(2) + ', ' + mPos[1].toFixed(2));
});
jsx.update();
}
initCirc();
</script>
<br /><br />
</div>
</div>
</div>
</body>
</html>