Three touching circles: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 4: Line 4:
     B  = brd.create('point', [2,0]),
     B  = brd.create('point', [2,0]),
     C  = brd.create('point', [1,2]),
     C  = brd.create('point', [1,2]),
     a1 = brd.create('segment', [A,B], {name:'a1', withLabel:true}),
     a1 = brd.create('segment', [A,B], {name:'a1', withLabel:true}),
     a2 = brd.create('segment', [B,C], {name:'a2', withLabel:true}),
     a2 = brd.create('segment', [B,C], {name:'a2', withLabel:true}),
     a3 = brd.create('segment', [C,A], {name:'a3', withLabel:true}),
     a3 = brd.create('segment', [C,A], {name:'a3', withLabel:true}),
     c1 = brd.create('circle', [A,  
     c1 = brd.create('circle',  
            function(){ var r1 = (C.Dist(A)-B.Dist(C)+A.Dist(B))/2.0;
            [A,  
            function(){ var r1 = (C.Dist(A)-B.Dist(C)+A.Dist(B))/2.0;
                         return r1; }
                         return r1; }
             ]);
             ]);
     c2 = brd.create('circle', [B,  
     c2 = brd.create('circle',  
            function(){ return A.Dist(B)-c1.Radius(); }
            [B,  
            function(){ return A.Dist(B)-c1.Radius(); }
             ]);
             ]);
     c3 = brd.create('circle', [C,  
     c3 = brd.create('circle',  
            function(){ return B.Dist(C)-c2.Radius(); }
            [C,  
            function(){ return B.Dist(C)-c2.Radius(); }
             ]);
             ]);
</jsxgraph>
=== The underlying JavaScript code ===
<source lang="javascript">
var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-2,5,5,-2]});
var A  = brd.create('point', [0,0]),
    B  = brd.create('point', [2,0]),
    C  = brd.create('point', [1,2]),


      
     a1 = brd.create('segment', [A,B], {name:'a1', withLabel:true}),
    a2 = brd.create('segment', [B,C], {name:'a2', withLabel:true}),
    a3 = brd.create('segment', [C,A], {name:'a3', withLabel:true}),
    c1 = brd.create('circle',
            [A,
            function(){ var r1 = (C.Dist(A)-B.Dist(C)+A.Dist(B))/2.0;
                        return r1; }
            ]);
    c2 = brd.create('circle',
            [B,
            function(){ return A.Dist(B)-c1.Radius(); }
            ]);
    c3 = brd.create('circle',
            [C,
            function(){ return B.Dist(C)-c2.Radius(); }
            ]);
</source>


</jsxgraph>
[[Category:Examples]]
[[Category:Geometry]]

Revision as of 10:45, 8 November 2011

The underlying JavaScript code

var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-2,5,5,-2]});
var A  = brd.create('point', [0,0]),
    B  = brd.create('point', [2,0]),
    C  = brd.create('point', [1,2]),

    a1 = brd.create('segment', [A,B], {name:'a1', withLabel:true}),
    a2 = brd.create('segment', [B,C], {name:'a2', withLabel:true}),
    a3 = brd.create('segment', [C,A], {name:'a3', withLabel:true}),
    c1 = brd.create('circle', 
            [A, 
             function(){ var r1 = (C.Dist(A)-B.Dist(C)+A.Dist(B))/2.0;
                        return r1; }
            ]);
    c2 = brd.create('circle', 
            [B, 
             function(){ return A.Dist(B)-c1.Radius(); }
            ]);
    c3 = brd.create('circle', 
            [C, 
             function(){ return B.Dist(C)-c2.Radius(); }
            ]);