多边形,圆形等的jsxgraph反射

时间:2018-05-10 09:09:17

标签: jsxgraph

有一个反映点(link)的选项。是否有其他形状的反射选项,如多边形,圆形,直线,角度等。 我已经尝试了这个,但它不适用于圆圈,虽然工作得很好。

        var board = JXG.JSXGraph.initBoard('jxgbox', { boundingbox: [-5, 5, 5, -5], axis: true });
    linePt1 = board.create('point',[0,0],{name:''});
    linePt2 = board.create('point',[2,2],{name:''});

    p1 = board.create('point',[1,3],{name:''});
    p2 = board.create('point',[1,2],{name:''});
    c1 = board.create('circle', [p1, p2]);

    theLine = board.create('line',[linePt1,linePt2],{dash:1});


    i1 = board.create('point',[3,3],{name:''});
    i2 = board.create('point',[3,2],{name:''});
    c2 = board.create('circle', [i1, i2]);

    initialPt = board.create('point',[3,1],{name:'initial pt'});
    transform = board.create('transform',[theLine],{type:'reflect'});
    board.create('point',[initialPt,transform],{name:'reflection'});

    transform1 = board.create('transform',[theLine],{type:'reflect'});
    board.create('circle',[c2,transform1],{name:'reflection1'});
    board.update();

由于

2 个答案:

答案 0 :(得分:1)

今晚的夜间构建将包含将变换应用于弧形,扇形,圆形和角度的可能性。此外,元素reflectionmirrorelement允许这些元素arcsectorcircleangle作为输入元素。缺点 - 至少目前是 - 产生的元素是弧,扇区和角度的曲线。当输入元素是圆时,得到的元素是圆锥截面。原因是当将任意变换应用于例如圆圈,圆圈将是一个圆锥形。

这是一个扩展示例:

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

// reflection line
var li = board.create('line', [1,1,1], {
    strokeColor: '#aaaaaa', name: 'reflection line', withLabel: true});
var reflect = board.create('transform', [li], {type: 'reflect'});
var t = board.create('transform', [2, 1.5], {type: 'scale'});

// Mirror point
var p1 = board.create('point', [-0.5, 0], {name: "Mirror point"});

var c1 = board.create('circle', [[1.3, 1.3], [0, 1.3]], 
    {strokeColor: 'black', center: {visible:true}});
var c2 = board.create('circle', [c1, t], {strokeColor: 'black'});
var c3 = board.create('reflection', [c1, li], {strokeColor: 'black'});
var c4 = board.create('mirrorelement', [c1, p1], {strokeColor: 'black'});
// c2, c3, c4 are conics

var a1 = board.create('arc', [[1, 1], [0, 1], [1, 0]], 
    {strokeColor: 'red'});
var a2 = board.create('curve', [a1, t], {strokeColor: 'red'});
var a3 = board.create('mirrorelement', [a1, p1], {strokeColor: 'red'});
var a4 = board.create('reflection', [a2, li], {strokeColor: 'red'});
// a2, a3, a4 are curves

var s1 = board.create('sector', [[-3.5,-3], [-3.5, -2], [-3.5,-4]], 
    {
        anglepoint: {visible:true}, 
        center: {visible: true}, 
        radiuspoint: {visible: true}, 
        fillColor: 'yellow', strokeColor: 'black'});
var s2 = board.create('curve', [s1, reflect], 
    {fillColor: 'yellow', strokeColor: 'black'});
var s3 = board.create('mirrorelement', [s1, p1], 
    {fillColor: 'yellow', strokeColor: 'black'});
var s4 = board.create('reflection', [s2, li], 
    {fillColor: 'yellow', strokeColor: 'black', fillOpacity: 0.5});
// s2, s3, s4 are curves
var an1 = board.create('angle', [[-4,3.9], [-3, 4], [-3, 3]]);
var an2 = board.create('curve', [an1, t]);
var an3 = board.create('reflection', [an1, li]);
// an2, an3 are curves 

请试一试。

祝福, 阿尔弗雷德

答案 1 :(得分:0)

由于几周后,夜间构建已经包含对线,多边形和曲线应用变换的功能。我们将在下周添加圆圈,圆弧,扇形和角度。