File: loci_midpoints.html

package info (click to toggle)
jsxgraph 1.3.5+dfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 26,044 kB
  • sloc: xml: 5,869; java: 1,072; python: 747; php: 192; makefile: 146; sh: 47
file content (112 lines) | stat: -rw-r--r-- 4,607 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
<html>
<head>
   <title>JSXGraph example</title>
   <link rel="stylesheet" type="text/css" href="../../distrib/jsxgraph.css" />
   <script type="text/javascript" src="/javascript/prototype/prototype.js"></script>
   <script type="text/javascript" src="../../src/loadjsxgraph.js"></script>
</head>
<body>
<h2>Watt's Curve</h2>
<div style="width:800px">
  <div id="jxgbox" class="jxgbox" style="width:600px; height:450px; float:left"></div>
</div>
   <script type="text/javascript">
    /* <![CDATA[ */

    board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-2, 10, 14, -2], axis: true, grid: false});
    p1 = board.createElement('point', [1, 1], {style:2,name:"A"});
    p2 = board.createElement('point', [1, 3], {style:2,name:"B"});
    p3 = board.createElement('point', [8, 1], {style:2,name:"C"});

    l1 = board.createElement('line', [p1, p3]);
    c1 = board.createElement('circle', [p1, p2]);
    g1 = board.createElement('glider', [4, 4, c1], {style:5,name:"D"});

    m1 = board.createElement('midpoint', [g1, p3], {style: '[]', size: 1});
    c2 = board.createElement('circle', [m1, 1]);
    m2 = board.createElement('intersection', [l1, c2, 0], {style: '[]', size: 1});
    m3 = board.createElement('midpoint', [m2, g1], {style: '[]', size: 1, trace:true});

    loc = board.createElement('locus', [m3], {strokeColor: 'red'});

    function groebner(p, debug) {
        if(debug)
            JXG.Math.Symbolic.geometricLocusByGroebnerBase(board, p, cb, true);
        else
            JXG.Math.Symbolic.geometricLocusByGroebnerBase(board, p, cb);
    }

    function symbcoords(p) {
        JXG.Math.Symbolic.generateSymbolicCoordinatesPartial(board, p, 'u', 'underscore');

        $('debug').innerHTML = '';
        for(var o in board.objects) {
            if(typeof board.objects[o].symbolic.x != 'undefined') {
                $('debug').innerHTML += board.objects[o].name + ': ';
                $('debug').innerHTML += '(' + board.objects[o].symbolic.x + ', ' + board.objects[o].symbolic.y + ')<br />';
                board.objects[o].label.content.setText(board.objects[o].name + ' (' + board.objects[o].symbolic.x + ', ' + board.objects[o].symbolic.y + ')');
            }
        }
        board.update();
        JXG.Math.Symbolic.clearSymbolicCoordinates(board);
    }

    function genpoly(p, method) {
        var m = 'underscore';
        if(method == 2)
            m = 'brace';
        JXG.Math.Symbolic.generateSymbolicCoordinatesPartial(board, p, 'u', m);

        var poly = JXG.Math.Symbolic.generatePolynomials(board, p, false);

        if(method==2)
            $('debug').innerHTML = 'Ideal(';
        else
            $('debug').innerHTML = '<ul>';

        for(var i=0; i<poly.length; i++) {
            if(method==2) {
                $('debug').innerHTML += '' + poly[i];
                if(i < poly.length-1)
                    $('debug').innerHTML += ', ';
            } else {
                poly[i] = poly[i].replace(/\^(\d+)/g,'<sup>$1</sup>');
                poly[i] = JXG.GeonextParser.replaceSub(poly[i]);
                poly[i] = poly[i].replace(/\*/g,'');
                $('debug').innerHTML += '<li>' + poly[i] + '</li>';
            }
        }
        if(method==2)
            $('debug').innerHTML += ')';
        else
            $('debug').innerHTML += '</ul>';

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

    function cb(poly) {
        alert(poly[0].replace(/\*\*(\d+)/g,'<sup>$1</sup>').replace(/\*/g,''));
    }
  /* ]]> */
  </script>
m<sub>1</sub><br/>
<a href="#" onclick="symbcoords(m1);">Generate symbolic coordinates</a><br />
<a href="#" onclick="genpoly(m1, 1);">Build polynomials (human readable)</a><br />
<a href="#" onclick="genpoly(m1, 2);">Build polynomials (cocoa ideal generator)</a><br />
<a href="#" onclick="groebner(m1);">Generate locus</a><br />
<br/>
m<sub>2</sub><br/>
<a href="#" onclick="symbcoords(m2);">Generate symbolic coordinates</a><br />
<a href="#" onclick="genpoly(m2, 1);">Build polynomials (human readable)</a><br />
<a href="#" onclick="genpoly(m2, 2);">Build polynomials (cocoa ideal generator)</a><br />
<a href="#" onclick="groebner(m2);">Generate locus</a><br />

m<sub>3</sub><br/>
<a href="#" onclick="symbcoords(m3);">Generate symbolic coordinates</a><br />
<a href="#" onclick="genpoly(m3, 1);">Build polynomials (human readable)</a><br />
<a href="#" onclick="genpoly(m3, 2);">Build polynomials (cocoa ideal generator)</a><br />
<a href="#" onclick="groebner(m3);">Generate locus</a><br />

<div id="debug" style="display:block; width: 400px;"></div>
</body>
</html>