Inserting Spline Point

Dominik_We

New member
Joined
Feb 12, 2021
Messages
7
Hi everyone,

I have a spline and want to insert a point between 2 other points, without changing the spline.

So as in the picture seen (hopefully, sry for using paint), given points A,B and their tangents, and the location of C, which is on the bezier curve, how can I get the tangents from C - C1 and C2, - so that the spline stays the same.

Hope you can help me.

InsertSplinePoint.png
 
Hi everyone,

I have a spline and want to insert a point between 2 other points, without changing the spline.

So as in the picture seen (hopefully, sry for using paint), given points A,B and their tangents, and the location of C, which is on the bezier curve, how can I get the tangents from C - C1 and C2, - so that the spline stays the same.

Hope you can help me.

View attachment 25096
What software are you using for your spline fit?

The user's manual should instruct you regarding the procedure to insert a point on the curve.
 
What software are you using for you spline fit?

The user's manual should instruct you regarding the procedure to insert a point on the curve.

I'm using Unreal Engine 4 USplineComponent. There are functions to add and insert into the spline but I can't completely use this, because I want to add points without changing the current splin and the Unreal Engine Splines change the bezier curve before the new added. For inserting the same, the spline changes. For adding at the end I just save the Tangent of the last point before adding and afterwards set it again, so it stays the same. For inserting I can't fix this behaviour
 
You already have the tangents. The line between p0 and pt 1 is a tangent line as well at the line between p2 and p3 is the other tangent on a standard cubic bezier. Your original curve looks like a quartic bezeir or degree 4 or "5th order". After insertion it looks like it will be a quintic. Your second segment of c1 and c2 is the tangent line. You can determine exact tangent line by first finding the derivative at that point and then using this common calculus technique

In general when you have a curve comprised of more than 4 points of degree 3 it is standard practice to use bsplines and not bezier.


 
Last edited:
You already have the tangents. The line between p0 and pt 1 is a tangent line as well at the line between p2 and p3 is the other tangent on a standard cubic bezier. Your original curve looks like a quartic bezeir or degree 4 or "5th order". After insertion it looks like it will be a quintic. Your second segment of c1 and c2 is the tangent line. You can determine exact tangent line by first finding the derivative at that point and then using this common calculus technique

In general when you have a curve comprised of more than 4 points of degree 3 it is standard practice to use bsplines and not bezier.


Maybe my question is not clear, I will try it again. I have all tangents of the curve. It's not 4. or 5. degree, it is a bezier curve between 2 points always and when I add the point I have 2 bezier curves afterwards.
My problem is, how "long" do the tangents have to be.
So I have given tangents at all points of the spline and need to know the length from A->A1, B->B1, C->C1, C->C2. Because, if the tangents length does not match, the new bezier curves don't match the old one.
 
Maybe my question is not clear, I will try it again. I have all tangents of the curve. It's not 4. or 5. degree, it is a bezier curve between 2 points always and when I add the point I have 2 bezier curves afterwards.
My problem is, how "long" do the tangents have to be.
So I have given tangents at all points of the spline and need to know the length from A->A1, B->B1, C->C1, C->C2. Because, if the tangents length does not match, the new bezier curves don't match the old one.
the length of the tangent line is the magnitude of the vector (see hermite spline https://www.cubic.org/docs/hermite.htm). The length is whatever you need it to be. Also Bezier curves have to have a minimum of 3 points and 2 hulls since there is no point drawing a bezier line. The number of control points on your bezier IS the degree of the curve. Are you implementing a Bezier in code? what is your goal, that may help explain things having some context
 
Last edited:
the length of the tangent line is the magnitude of the vector (see hermite spline https://www.cubic.org/docs/hermite.htm). The length is whatever you need it to be. Also Bezier curves have to have a minimum of 3 points and 2 hulls since there is no point drawing a bezier line. The number of control points on your bezier IS the degree of the curve. Are you implementing a Bezier in code? what is your goal, that may help explain things having some context
So for implementation I'm using Unreal Engines Spline Component. The bezier curve has 2 points + 2 control points.

So my goal is to "divide" one bezier curve into 2 other bezier curves that together match exactly the first curve.

In my picture this would be like this:

I have an existing bezier curve: A to B, with the control points A1, B1

I want to new bezier curves: A to C, with the control points A1 and C1
C to B, with the control points C2 B1

Note that A1, B1 is differentin the existing curve than in the new curves, name is just the same because of better visibility.

So A B C are given. A1,B1 from existing curve are also given. The direction of the tangent in C is also given.

What I need for the new curves: New A1, B1 and C1, C2.

So if we say the tangent in C is c we have C1 = C + x * c. What I need is x. Same for A1, B1, C2.
 
Ok, found the solution. Finding it was harder than implementing it, the solution is just the De Casteljau algorithm.
 
Beer soaked reply follows.
Is there a way to post code here with formatting or just a screenshot?
There is with just a screenshot.
You can see it just below.
It's an icon of a paperclip that says "Attach files".
You were able to upload a png file in at post #1.
 
Last edited:
Top