File: spiro.html

package info (click to toggle)
jsxgraph 1.10.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 24,804 kB
  • sloc: javascript: 82,299; xml: 5,869; java: 1,072; php: 281; makefile: 184; python: 174; cpp: 76; sh: 12
file content (183 lines) | stat: -rw-r--r-- 6,202 bytes parent folder | download | duplicates (3)
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
<html>
<head>
   <title>Spirograph | JSXGraph Example</title>
   <link rel="stylesheet" type="text/css" href="../../distrib/jsxgraph.css" />
   <script type="text/javascript" src="../../distrib/jsxgraphcore.js"></script>
</head>
<body>
<div id="debug" style="display: none"></div>
<center>
<div style="width: 1000px;">
    <div style="width:500px; height: 510px;">
  <div id="jxgbox" class="jxgbox" style="width:500px; height:500px; text-align: left; float: left;"></div>
  <div id="polynomials" style="display: none; width: 500px; height: 500px; margin-left: 10px; text-align: left; padding-left: -200px;"></div>
  </div>

    <div style="width: 800px; margin-top: 10px;">
  <form>
      <input type="button" onclick="chooseCoordinateSystem();" value="Choose coordinate system" />
      <input type="button" onclick="generatePolynomials();" value="Generate system of polynomial equations" />
      <br />
      <input type="button" onclick="calculateLocus();" value="Calculate locus" />
      <input type="button" onclick="showLocusEquation();" value="Show locus equation" />
      <input type="button" onclick="showBoard();" value="Show board" />
      <!--br />
      <input type="button" onclick="extend();" value="Extend the construction" />
      <input type="button" onclick="extendedLocus();" value="Calculate extended locus" /-->
      <br />
      <input type="text" value="0.2" id="dim" size="3" />
      <input type="button" onclick="dimConstruction();" value="Dim construction" />
      <input type="button" onclick="dimLocus();" value="Dim locus" />
      <!--input type="button" onclick="dimExtension();" value="Dim extension" />
      <input type="button" onclick="dimLocus2();" value="Dim extended locus" /-->
  </form>
  </div>
</div>
</center>
   <script type="text/javascript">
    /* <![CDATA[ */

var brd = JXG.JSXGraph.initBoard('jxgbox',{boundingbox:[-5,5,5,-5], keepaspectratio:true});
var board = brd;

var O = brd.create('point',[0,0],{name:'O',fixed:true, fillColor:'blue', strokeColor:'blue'});
var A = brd.create('point',[2,0],{name:'A'});
var k = brd.create('circle',[O,A],{name:'k'});

var B = brd.create('glider',[0.7,1,k],{name:'B drag me'});

var g1 = brd.create('line',[O,B], {strokeColor:'lightgray'});
//var C = brd.create('reflection',[g1,A],{name:'C', fillColor:'blue', strokeColor:'blue'});

var k2 = brd.create('circle',[O,O.Dist(A)+1], {strokeColor: 'lightgray'});

var M = brd.create('intersection',[k2,g1,0], {name:'M', fillColor:'blue', strokeColor:'blue'});
var k3 = brd.create('circle',[M,B],{name:'k'});

var gpar = brd.create('parallel',[O,A,M], {name:"g", strokeColor:'lightgray'});
var Cprime = brd.create('intersection',[gpar,k3,0], {name:"C'", trace: false, fillColor:'green', strokeColor:'green'});

var p14_1 = Cprime;

var loc = null;


    function chooseCoordinateSystem() {
        var k, o;
        document.getElementById('polynomials').style.display = 'none';
        document.getElementById('jxgbox').style.display = 'block';
        JXG.Math.Symbolic.generateSymbolicCoordinatesPartial(board, p14_1, 'u', 'brace');

        for(k in board.objects) {
            o = board.objects[k];
            if(o.elementClass == JXG.OBJECT_CLASS_POINT) {
                o.label.content.setText(o.name + ' (' + o.symbolic.x + ', ' + o.symbolic.y + ')');
            }
        }

        board.update();
        JXG.Math.Symbolic.clearSymbolicCoordinates(board);
    }

    function generatePolynomials() {
        var res = JXG.Math.Symbolic.generatePolynomials(board, p14_1, true),
            i, out = document.getElementById('polynomials');

        out.innerHTML = '<ul>';
        for(i=0; i<res.length; i++)
            out.innerHTML += '<li>' + res[i] + ' = 0</li>';
        out.innerHTML += '</ul>';
        out.style.display = 'block';
        document.getElementById('jxgbox').style.display = 'none';
    }

    function calculateLocus() {
        loc = board.create('locus', [p14_1], {strokeColor: 'black', strokeWidth: '2px'});
    }

    function showLocusEquation() {
        var out = document.getElementById('polynomials');

        out.innerHTML = '<ul>';
        for(i=0; i<loc.eq.length; i++)
            out.innerHTML += '<li>' + loc.eq[i] + ' = 0</li>';
        out.innerHTML += '</ul>';
        out.style.display = 'block';
        document.getElementById('jxgbox').style.display = 'none';
    }

    function showBoard() {
        document.getElementById('polynomials').style.display = 'none';
        document.getElementById('jxgbox').style.display = 'block';
    }

    function dimConstruction() {
        var c = [O, A, k, B, g1, k2, M, k3, gpar, Cprime/*, C*/], i, o = getDim();

        if(O.visProp['strokeOpacity'] == o)
            o = 1.0;

        for(i=0; i<c.length; i++) {
            c[i].setProperty({strokeOpacity: o, fillOpacity: o});
        }
    }

    function dimLocus() {
        var o = getDim();

        if(loc != null) {
            if(loc.visProp['strokeOpacity'] == o)
                o = 1.0;
            loc.setProperty({strokeOpacity: o});
        }
    }

    function dimLocus2() {
        var o = getDim();

        if(loc2 != null) {
            if(loc2.visProp['strokeOpacity'] == o)
                o = 1.0;
            loc2.setProperty({strokeOpacity: o});
        }
    }

    function extend() {
        if(loc==null)
            return;

        board.suspendUpdate();
        tg = board.create('glider', [loc]);

        tc = board.create('circle', [tg, 3]);
        ti = board.create('intersection', [tc, c1, 0]);
        tm = board.create('midpoint', [tg, ti]);
        board.unsuspendUpdate();
    }

    function dimExtension() {
        if(tg == null)
            return;

        var c = [tg, tc, ti, tm], i, o = getDim();

        if(tg.visProp['strokeOpacity'] == o)
            o = 1.0;

        for(i=0; i<c.length; i++) {
            c[i].setProperty({strokeOpacity: o, fillOpacity: o});
        }
    }

    function getDim() {
        return parseFloat(document.getElementById('dim').value);
    }

    function extendedLocus() {
        loc2 = board.create('locus', [tm], {strokeColor: 'black', strokeWidth: '2px'});
    }
  /* ]]> */
  </script>
<br/>
</body>
</html>