# Cubic B spline, path generation in Julia and execution in C++

**URL:** <https://discourse.julialang.org/t/cubic-b-spline-path-generation-in-julia-and-execution-in-c/134020>\
**Category:** Numerics\
**Created:** [November 21, 2025, 9:47am UTC](https://discourse.julialang.org/t/cubic-b-spline-path-generation-in-julia-and-execution-in-c/134020 "2025-11-21T09:47:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![romain-chiap](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/romain-chiap/32/217795_2.png) [@romain-chiap](https://discourse.julialang.org/u/romain-chiap)\
**Post date:** [November 21, 2025, 9:47am UTC](https://discourse.julialang.org/t/cubic-b-spline-path-generation-in-julia-and-execution-in-c/134020/1 "2025-11-21T09:47:37Z")

</div>

Hello,

Given some data points tx, x. I would like to represent the path tx,x as well as its first and second derivative. I need my path to be C² continuous and small. It will be running in embedded C++

I have a set of data points which I curve fit with  
`Ax = BSplineApprox(x, tx, poly_deg, nb_pts_approx, :Uniform, :Uniform)`  
Then I didn’t find an easy way to obtain the knots and control points so I used forwardDiff to obtain the velocity.  
velx(t) = ForwardDiff.derivative(x → Ax(x), t)

now assuming we remain at the knots  
tc = collect(range(0,tx[end],nb\_pts\_approx))  
PATH\_X = Ax(tc)  
PATH\_VX = velx.(tc)

And now, I’m trying to use the [Hermite cubic basis functions](https://en.wikipedia.org/wiki/Cubic_Hermite_spline) to reconstruct my segments (with appropriate scaling / change of variable), but the acceleration is discontinuous.

Am I confusing splines and cubis hermite polynomial?  
How can I transport the spline data into my embedded system and reconstruct the path in real time?  
I guess I could use a quintic spline and quintic hermite polynomial, but that would be an overkill…

 ![path_x](https://global.discourse-cdn.com/julialang/original/3X/1/f/1fd6e52ba439119a6ed2e2ac6dfe64773788cac5.png)
