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

Metapost spline

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

var tension = board.create('slider', [[-5, 6], [1, 6], [0, 1, 20]], {
     name: 'tension'
});
var curl = board.create('slider', [[-5, 5], [1, 5], [0, 1, 30]], {
     name: 'curl A, D'
});
var dir = board.create('slider', [[-5, 3.5], [2, 3.5], [-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: () => tension.Value(),
    0: {
        curl: () => curl.Value()
      },
    1: {
        direction: () => dir.Value()
      },
    3: {
        curl: () => 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 7875

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 7890

points

Description

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

Type
Object
See
Source
options.js, line 7905

Inherited

Members

Own

none

Inherited

Methods

Own

none

Inherited

Events

Own

none

Inherited

Details

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

Extends