# Algorithm for trimming b-spline

I'm stuck with developing algorithm to trim b-spline so it begins at certain point without changing it's shape. I'm using these formulas: link. I have already implemented inserting knot at given t. Let me show you example of what I'm trying to do.

Control points of my spline are: ((0, 0), (19, 0), (0, 12), (28, 38), (56, 14), (34, 0), (56, 0))
Knot vector of original spline is: (0, 0, 0, 0, 0,25, 0,5, 0,75, 1, 1, 1, 1)
Degree of spline: 3.

Now I would like add a knot at let's say 0.3 and then cut all that preceeds 0.3 without changing the shape of curve so it starts at inserted point.

-
You're supposed to be able to use the Cox-de Boor recursion for something like this (analogous to the use of the de Casteljau recursion to cut off Bézier curves). – J. M. Jul 17 '12 at 12:21

Suppose your spline curve is $C(t)$, and let $m$ denote its degree. You need to insert the knot $t = 0.3$ repeatedly until its multiplicity is $m$. So, in your example, this will give you a new curve whose knot sequence is $(0,0,0,0,0.25,0.3,0.3,0.3, 0.5, 0.75, 1,1,1,1)$. Let $Q_1,Q_2, \ldots, Q_n$ be the control points of this curve, in your example, $n$ will be equal to 10.
The point $C(0.3)$ will be a control point of the new refined curve; call it $Q_r$. This control point divides the list of control points into two halves. The first half of the curve will be defined by the control points $Q_1,Q_2, \ldots, Q_r$ and the second half will be defined by the control points $Q_r, \ldots, Q_n$. The first half will have knots $(0,0,0,0,0.25,0.3,0.3,0.3, 0.3)$, and the second half will have knots $(0.3, 0.3, 0.3, 0,3, 0.5, 0.75, 1,1,1,1)$. If you want to, you can normalise each of these knot sequences to the range $[0,1]$. For example, normalising the first half would give (0,0,0,0, 2.5/3, 1,1,1,1).
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "http://math.stackexchange.com/questions/171855/algorithm-for-trimming-b-spline", "fetch_time": 1469794888000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2016-30/segments/1469257830066.95/warc/CC-MAIN-20160723071030-00233-ip-10-185-27-174.ec2.internal.warc.gz", "warc_record_offset": 160053198, "warc_record_length": 17515, "token_count": 640, "char_count": 1833, "score": 3.671875, "int_score": 4, "crawl": "CC-MAIN-2016-30", "snapshot_type": "latest", "language": "en", "language_score": 0.8784204125404358, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00052-of-00064.parquet"}