"spline" - mkraska/meclib GitHub Wiki

[ "spline", "eqn", [X0, Y0], [x1, y1], [x2,y2], [xt1, yt1], [xt2,yt2], style, status ]

linear/quadratic/cubic spline for interactive function graphing. The coordinates of the control points are displayed in scaled grid coordinates. The object returns the function of the graph as algebraic expression (polynom of order up to 3) in a local but unscaled coordinate system.

  • [X0,Y0] origin of the local system. The other points are given in this local system. Note that the dynamic display of co-ordinates uses scaling defined by "grid".
  • [x1, y1], [x2,y2] start and end points.
  • [xt1, yt1], [xt2, yt2] points to define the respective tangent directions. Points are only visible in active state. If they coincide with the boundary points, no tangent condition is assumed and a quadratic or linear spline is drawn.
  • style list of style specifications: [linestyle, [fx,fy], [dpx, dpy]
    • linestyle currently ignored, might specify color and dashing and width
    • [fx,fy] scaling factors
    • [dpx,dpy] decimal precision
  • status is "active", "inactive", "locked" or "pure". The spline can be switched between active and inactive state by doubleclick except if it is locked or pure, then it is black. Otherwise the curve is plotted in blue. "pure" plots only the curve, switches off highlighting and gridsnap.

Feedback

See Values and Slope of Splines on how to generate feedback on splines.

Usage hint (copy to the question text)

https://raw.githubusercontent.com/mkraska/meclib/main/Snippets/Spline.html

Example

image

[
  [ "grid", "x","y", -5,5,-4,5, 50, [10,10], [0,0] ],
  [ "spline", "", [1, 1], [0, 1], [2,1], [0.5, 0], [0.5,1], "", "active" ],
  [ "point", "0", [1,1] ],
  ["label", "1", [0.6,2]],
  ["label", "2", [3.2,2]],
  ["label", "t1", [1.5,0.75]],
  [ "label", "t2", [1.4,2.25] ]
]