|
Notes for Wednesday March 31 -- splines 2
More about cubic splines
In class we looked at how to define Hermite splines
so that they can easily be strung end to end to
make one continuous curve.
The trick is to re-use the
P1 and R1
of each Hermite curve segment as the
P0 and R0
of the next Hermite curve segment.
All of the code for that is in the included
hw7.zip.
I also showed an example of the Catmull-Rom
interpolating spline, and we looked at how
I had used that to create a text font for a project in VR.
The 16 values of the Catmull-Rom matrix are given by:
catmullRomMatrix = [ -.5,1,-.5,0, 1.5,-2.5,0,1, -1.5,2,.5,0, .5,-.5,0,0 ]
It is used to transform any four successive
key points (A,B,C,D) of a curve to the cubic coefficients (a,b,c,d)
of the corresponding cubic curve (at3 + bt2 + ct + d)
between points B and C.
Remember from class that for the first
segment of the curve, since there is no point to the left of B, we just set A = B.
Similarly, for the last
segment of the curve, since there is no point to the right of C, we just set D = C.
World Builder
At the end of class,
we watched Bruce Branit's classic
2007 short film
World Builder.
Homework -- due before class on Wednesday April 7
|
|
The contour of a surface of revolution can be defined
by two functions: z(v) and r(v),
where both are functions of parameter v, which varies between 0.0 and 1.0.
As u and v both vary between 0.0 and 1.0, the surface
at that value of u is at point:
[ r(v) cosθ , r(v) sinθ , z(v) ].
where 0 ≤ θ < 2π.
|
-
Starting with the code we implemented in class,
which is in hw7.zip,
implement a surface of revolution (SOR).
That's a mesh which looks like something that might be
created on a lathe or a potter's wheel.
It can be defined by two spline curves S0 and S1 as follows:
S0 defines a changing value along the z axis,
S1 defines a varying radius.
Both splines are indexed by v.
Here is the general formula, where ε is a very small positive number (eg: 1/1000):
z0 = evalSpline(S0, v)
z1 = evalSpline(S0, v + ε)
r0 = evalSpline(S1, v)
r1 = evalSpline(S1, v + ε)
tilt = atan2(r0 - r1, z1 - z0)
x = r0 * cos(2 π u) // POSITION
y = r0 * sin(2 π u)
z = z0
nx = cos(tilt) * cos(2 π u) // NORMAL
ny = cos(tilt) * sin(2 π u)
nz = sin(tilt)
vertex = [ x,y,z, nx,ny,nz ]
Hint:
You can define a function uvToSOR(u,v,S)
The third argument S is an array that contains two elements:
an array of keypoints for S0 and
an array of keypoints for S1.
You can use an Hermite, Bezier or Catmul-Rom spline for this assignment,
whichever you prefer.
-
Use instances of your SOR mesh to create an animated creature.
You can use the same SOR mesh or different SOR meshes for different body parts
(eg: torso, head, arms, legs, etc).
Your creature can be a human,
an insect, a dragon, or just something from your imagination.
| |
|