nurbsCurve.toJSON

The curve as plain JSON: degree, Euclidean control points, weights and knots.

Value helperSince 0.4.0

Usage

TypeScript
curve.toJSON(): { degree: number; points: number[]; weights: number[]; knots: number[] }

Returns

Plain arrays: points as [x0, y0, z0, …], one weight per point, the full knot vector in knot units.

Example

TypeScript
const q = NurbsCurve.create([Point3.of(1, 0, 0), Point3.of(1, 1, 0), Point3.of(0, 1, 0)], 2, { weights: [1, Math.SQRT1_2, 1], knots: [0, 0, 0, 1, 1, 1] }).value
q.toJSON().knots // → [0, 0, 0, 1, 1, 1]

See also