ScriptSpot

Forum topic · Scripts Wanted

Progessive spline with smooth at the ends

By titane357 · 2018-09-11

Downloads
Description

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

Comments (4)

titane357 · 2018-09-13

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 · 2018-09-11

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

bezier maths

titane357 · 2018-09-12

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

.

jahman · 2018-09-12

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?