|
![](/i/fill.gif) |
No, it should work. Here's a part of a code I once wrote when playing with bezier
curves. What do you need the tangents for? Perhaps it's necessary to normalize them...
#default {
finish { ambient 1 }
}
#declare curve_size = 0.05;
#declare point_size = 0.20;
#declare col = color rgb <1,1,1>;
camera {
orthographic
location <0,0,-30>
look_at 0
}
#macro drawBezierCurve(p0,p1,p2,p3)
#local s = 0;
#while (s <= 1)
#local p = bezier(p0,p1,p2,p3,s);
#local n = dbezier(p0,p1,p2,p3,s);
sphere {
p,curve_size
pigment { color col }
}
cylinder {
p,p+vnormalize(n)*5,curve_size/2
pigment { color col }
}
#local s = s + 1/50;
#end
#end
#macro bezier(p0,p1,p2,p3,s)
#local B0 = (1 - s) * (1 - s) * (1 - s);
#local B1 = 3 * s * (1 - s) * (1 - s);
#local B2 = 3 * s * s * (1 - s);
#local B3 = s * s * s;
p0 * B0 + p1 * B1 + p2 * B2 + p3 * B3
#end
#macro bezier2(p0,p1,p2,s)
#local B0 = (1 - s) * (1 - s);
#local B1 = 2 * s * (1 - s);
#local B2 = s * s;
p0 * B0 + p1 * B1 + p2 * B2
#end
#macro dbezier(p0,p1,p2,p3,s)
#local n0 = p1 - p0;
#local n1 = p2 - p1;
#local n2 = p3 - p2;
bezier2(n0,n1,n2,s)
#end
#macro drawPoint(p)
sphere {
p,point_size
pigment { col }
}
#end
#macro drawLine(a,b)
cylinder {
a,b,curve_size
pigment { col }
}
#end
#macro setColor(c)
#declare col = color rgb c;
#end
#if (true)
#declare A = <-10,-5>;
#declare B = <-5,5>;
#declare C = <5,5>;
#declare D = <10,-5>;
setColor(<1,0,0>)
drawPoint(A)
drawPoint(B)
drawPoint(C)
drawPoint(D)
setColor(<0,0,1>)
drawBezierCurve(A,B,C,D)
#end
Post a reply to this message
|
![](/i/fill.gif) |