Add comments to r quickstart example.
@@ -5,8 +5,12 @@ dyn.load(paste("tinyspliner", .Platform$dynlib.ext, sep=""))
source("tinyspline.R")
cacheMetaData(1)
+# Create a cubic spline with 7 control points in 2D using
+# a clamped knot vector. This call is equivalent to:
+# spline <- BSpline(7)
spline <- BSpline(7)
+# Setup control points.
ctrlp <- BSpline_ctrlp_get(spline)
ctrlp[1] = -1.75 # x0
ctrlp[2] = -1.0 # y0
@@ -24,13 +28,16 @@ ctrlp[13] = 0.5 # x6
ctrlp[14] = 0.0 # y6
invisible(BSpline_ctrlp_set(spline, ctrlp))
+# Evaluate `spline` at u = 0.4.
result = BSpline_evaluate(spline, 0.4)
result = DeBoorNet_result_get(.Last.value)
cat("x = ", result[1], "y = ", result[2], "\n")
+# Derive `spline` and subdivide it into a sequence of Bezier curves.
beziers = BSpline_derive(spline)
beziers = BSpline_toBeziers(.Last.value)
+# Evaluate `beziers` at u = 0.3.
result = BSpline_evaluate(beziers, 0.3)
result = DeBoorNet_result_get(.Last.value)
cat("x = ", result[1], "y = ", result[2], "\n")
