Pages

Saturday, December 4, 2010

Custom Helix


How to create helix spline with custom amount of knots (via MAXScript) was asked here, and here is my snippet code --

spline = splineShape()

addNewSpline spline

addKnot spline 1 #smooth #curve [0,0,0]

numK = 12 -- num.knots

incr = pi -- increment

rad = for i = 1 to numK collect i * incr

ang = 30 -- angle

points = for i = 1 to numK collect

[rad[i]*(sin(i*ang)),rad[i]*(cos(i*ang)),0]

for p in points do addKnot spline 1 #smooth #curve p

updateShape spline

Shortly, in this example, 12 knots with angle 30 made full turn (12*30=360). So, what else... If you like some improvements like adding a height, then here is --

spline = splineShape()

addNewSpline spline

addKnot spline 1 #smooth #curve [0,0,0]

numK = 12 -- num.knots

incr = pi -- increment

rad = for i = 1 to numK collect i * incr

ang = 30 -- angle

h = 10 as float -- example height

step = h / numK

points = for i = 1 to numK collect

[rad[i]*(sin(i*ang)),rad[i]*(cos(i*ang)),step*i]

for p in points do addKnot spline 1 #smooth #curve p

updateShape spline

Thats it for now.

No comments:

Post a Comment

Thanks for your comment