Progessive spline with smooth at the ends

Hi,
I made a little script to make roads slopes references.
Actually it make a linear z offset of each point to have a constant slope.
To simplify I use Normalize spline to have equal distance between knots.
But I would like to have a little smooth effect and the ends.
And of course I'm not able to do it...

undo on(
aaa =$
for cyc=1 to 100 do
(
LLL = getSegLengths aaa 1 cum: true byVertex:false
nb = LLL.count
LONGG = LLL[nb]
verts = numKnots aaa
DIFF = (getKnotPoint aaa 1 verts) - (getKnotPoint aaa 1 1)
kntb = getKnotPoint aaa 1 1
for i=2 to (verts - 1) do
(
knt = getKnotPoint aaa 1 i
pp1 = LLL[i-1]
SEC = ( DIFF.z * pp1)
setKnotPoint aaa 1 i [knt.x,knt.y,kntb.z + SEC]
)
)
updateShape aaa
)---undo
AttachmentSize
script1.jpg73.88 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
titane357's picture

Thanks for your

Thanks for your interrest.
When I'll have time I will try to use my script on the middle knots minus a z value and use other method for the x knots at the ends....

jahman's picture

.

I'd create temporary spline with 4 bezier knots and then place initial points along it using interpCurve3D.

bezier maths

titane357's picture

arrggghhh I was sure there

arrggghhh I was sure there were some maths here !!!! :-)

jahman's picture

.

I'm not sure that you can create such easeInOut function that the middle slope part remains straight, but this way it is a pure math solution.
easing function generator

What is your end goal btw? Slope mesh between the road and the terrain?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.