Metapostspline

Element

Interpolate data points by the spline curve from Metapost (by Donald Knuth and John Hobby). Create a dynamic metapost spline interpolated curve given by sample points p_1 to p_n.

Usage (signatures)
board.create('metapostspline', [...point, controls]);

Parameters are the points and controls for the spline interpolation.

Parameters
Name Type Attributes Description
point PointLike <repeatable>

Unspecified number of points

controls Object

Object containing MetaPost control values like tension, direction, curl.

Example
var po = [],
        attr = {
            size: 5,
            color: 'red'
        },
        controls;

    var tension = board.create('slider', [[-3, 6], [3, 6], [0, 1, 20]], {name: 'tension'});
    var curl = board.create('slider', [[-3, 5], [3, 5], [0, 1, 30]], {name: 'curl A, D'});
    var dir = board.create('slider', [[-3, 4], [3, 4], [-180, 0, 180]], {name: 'direction B'});

    po.push(board.create('point', [-3, -3]));
    po.push(board.create('point', [0, -3]));
    po.push(board.create('point', [4, -5]));
    po.push(board.create('point', [6, -2]));

    var controls = {
        tension: function() {return tension.Value(); },
        direction: { 1: function() {return dir.Value(); } },
        curl: { 0: function() {return curl.Value(); },
                3: function() {return curl.Value(); }
            },
        isClosed: false
    };

    // Plot a metapost curve
    var cu = board.create('metapostspline', [po, controls], {strokeColor: 'blue', strokeWidth: 2});


Attributes

Own

createPoints

Description

Controls if the data points of the cardinal spline when given as arrays should be converted into JXG.Points.

Type
Boolean
Default Value
true
See
Source
options.js, line 7758

isArrayOfCoordinates

Description

If set to true, the supplied coordinates are interpreted as [[x_0, y_0], [x_1, y_1], p, ...]. Otherwise, if the data consists of two arrays of equal length, it is interpreted as [[x_o x_1, ..., x_n], [y_0, y_1, ..., y_n]]

Type
Boolean
Default Value
true
Source
options.js, line 7773

points

Description

Attributes for the points generated by Metapost spline in cases createPoints is set to true

Type
Object
See
Source
options.js, line 7788

Inherited

Members

Own

none

Inherited

Methods

Own

none

Inherited

Events

Own

none

Inherited

Details

Type
JXG.Curve
See
Source
base/curve.js, line 2201

Extends