# Hermite Curve

Hi there,

I’m trying to interpolate some points by using a HermiteCurve, but the output isn’t interpolated.

The way I use it is the following:

``````##
## create the curve
##

points = [...] # a list of points (Vec3)

curve = HermiteCurve()

for point in points:
curve.appendCv(4, point, point, point)

# HC_CUT = 1, HC_FREE = 2, HC_G1 = 3, or HC_SMOOTH = 4
# the 1st parameter '4' is for HC_SMOOTH
# because the constant HC_SMOOTH seems not to be defined in python

curve.recompute()

##
## draw the curve
##

resolution = 100
point = Vec3(0,0,0)
length = curve.getMaxT()

for i in xrange(0,resolution):
curve.getPoint(i*(length/resolution), point)

# draw the point into a bitmap...``````

I also tried to use a NurbsCurve. This interpolated the points very well, but I have to use a curve that goes through the points, which Nurbs actually doesn’t.

In the manual there is not much information about the HermiteCurve. Has anybody worked with it who could tell me how to get it interpolating points or what I’m doing wrong?

Carsten

A Hermite curve requires the user to explicitly set the tangent vectors of the curve at each control vertex, via setCvIn() and setCvOut(). If you do not do this, the curve will have zero tangents, which means it will linearly connect the dots instead of smoothly interpolating.

Note also that the C++ symbols lose their underscores in mapping to Python, so “HC_SMOOTH” becomes “HCSMOOTH”. This symbol has little effect on the result of the curve, however; the tangents are the only thing that really matters.

David

Hey, thank you, it works! I thought HCSMOOTH would set the tangents automatically,
but now I set them manually and … tadadada the curve is smoot thanks a lot!