【问题标题】:JSXGraph 0.99.7 union of curvesJSXGraph 0.99.7 曲线联合
【发布时间】:2021-02-17 13:08:59
【问题描述】:

由于 Moodle-STACK 环境,我目前仅限于 JSXGraph 0.99.7。有没有办法获得该版本中坐标向量(多边形)给出的两条曲线的联合?

在 1.2.1 中,我使用 Clip.union() 执行此操作,它在 jsfiddle (not exactly a minimum working example) 中可以正常工作,但在 STACK 中却不行。

      this.b = board.create('curve', JXG.Math.Clip.union( bneu, this.b, board), 
    {opacity: true, fillcolor:'lightgray', strokeWidth: normalStyle.strokeWidth, 
     strokeColor: normalStyle.strokeColor});

【问题讨论】:

    标签: stack moodle jsxgraph


    【解决方案1】:

    在 0.99.7 中,您必须手动进行联合。只要形状不重叠,这可能不需要太多工作就可以实现。定义曲线并设置其 updataDataArray方法:

    c = board.create('curve', [[], []]);
    c.updateDataArray = function() {
        this.dataX = [];
        this.dataY = [];
        // copy now the coordinates of the polygons / curves into
        // these arrays.
    };
    board.update();
    

    您可以通过

    访问多边形顶点的坐标
    polygon.vertices[i].X();
    polygon.vertices[i].Y();
    

    注意:最后一个顶点是第一个顶点的副本,使多边形成为闭合曲线。

    可以通过以下方式访问曲线的坐标

    curve.points[i].usrCoords[1]; // x-coordinate
    curve.points[i].usrCoords[2]; // y-coordinate
    

    可以通过添加NaNs来打断曲线路径:

    this.dataX.push(NaN);
    this.dataY.push(NaN);
    

    希望能有所帮助。

    【讨论】:

    • 感谢您的解释。我已经想知道,为什么我在 1.2.1 中的不相交曲线的曲线数据数组中得到一个 NaN。我不会在 0.99.7 中执行联合,因为 STACK 很有可能很快更新。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-19
    • 2020-12-06
    • 2015-03-02
    相关资源
    最近更新 更多