[Closed] Script to make a bezier line segment touch several specified points?
To preface, I’m speaking here as someone who is not any kind of math genius.
What I want to make is a script where, taking 2 ends of a bezier spline segment, and specifying several points between, the bezier in/out handles will be adjusted such that the spline segment touches all the intervening points. If I have figured this correctly, it should be theoretically possible to make the spline segment touch up to 3 specified points (with some restrictions on where those points can be.)
I’ve figured out several ways to access and manipulate a spline’s bezier curve data, and plan on building a matrix based on the 2 splines ends and the world up vector. So, just assuming that end points A and B of a spline segment are laying flat along the x-axis, what kind of formula do I need to control the bezier curve to touch the points?
could you give us some more information, maybe draw an example and post the image?
Okay, here’s the setup I’m looking for: What I have are a spline segment, and 3 points. What the script does is move the bezier handles to where they have to be in order to hit those points.
Someone pointed me to this link. I’m trying to figure it out but it makes my head spin. Can anyone figure out a way to “reverse engineer” the formula shown into MaxScript?
That article is only to understand how the bezier curve is constructed. Then, to make it go through a number of given points, you’re going to need a polynomial interpolation formula
then you’ll need to figure out how to put both formulas together and code it in maxscript.
Sounds like a nice challenge
hmm, I dont know, is that possible that you build an other type of curve and then convert it to bezier? Because in some other type of curves the points are actually representing the curve knot points.
Edit
yes indeed its possible, after creating the spline just cycle through the curve’s knot points with SetKnotType command, where you should use #bezier as the type.
piece of cake!
Wait what? Sorry LB, you lost me there…
I think you’re under the impression that I want to divide up my spline segment using additional spline knots, which I don’t. I want to move ONLY the bezier handles, and by doing so make the spline segment intersect the reference points.
Unless I am completely misunderstanding you, in which case I will need some clarification.
in my understanding there are points in which trough you need to have a bezier spline. This is your target. This is your end result. Am I right?
now, that, how you define the points in between those two endpoints is an other story. On end I you just have a bezier spline.
However if you want to manually move the bezier control points on the ends then you need an other method.
Still if you only need the bezier spline on the end, without bothering with the controll points then my method is just perfect for you and all bezier contoll points will be on the right place along with the knots.
just for clarification here is the method.
you have the points, in which through we can draw a general spline with as many knots and segments as we want. So if your original spline has two segments then you draw segments. through the knots. You can also check which segment belongs to which knots.
So we can conclude that segments and point count doesn’t matter.
Next, so we have the spline with the knots, and segments or segment. Now we cycle trough all of these points and convert them to bezier knots, and then we update the shape and what we have a nice bezier spline which goes exactly through the control points. So it have exactly that much knots plus the two endpoints, exactly the same amount of segments etc.
Plus we dont need to bother with the bezier controll points, which is quite a complicated task.
My ultimate goal in doing this is to have as few points in the spline as possible, and control the shape using the bezier handles instead.
So I will take an existing spline with many points, and run the script. Then I select which of the points I want to keep, and it 3 additional points in between for each set to use as references for the bezier handles. Then a new spline will be created, with an appoximation of the original spline, but with many fewer points on it (for example,12 points instead of 45).
So, what you’re talking about is more or less the opposite of what I am trying to do…
in the last pot basically what you talking about is a spline simplification, nothing more. I dont understand how your first post and the images connected toghether. Spline simplification you can find in this forum. Good luck with it.