|
Notes for Nov 25 class
Better surface of revolution
Rather than the naive approach I covered last week for creating
a surface of revolution, this week I showed how to control
two variables as a function of v: the z coordinate and the radius r.
If you want to test this, here is some code you can use.
This is the example I showed in class.
Note that I first convert both the spline for
z
and the spline for
r
from Bezier to Cubic coefficients. Then I pass an array
containing those two sets of coefficients to a generic method
to build a
u,v
mesh, together with a definition of a function
CG.uvToLathe() ,
which will convert each
(u,v)
to a vertex.
The end result will be a vertex buffer, which I
assign to variable
lathe
for rendering:
let lathe = CG.createMeshVertices(8, 16, CG.uvToLathe,
[ CG.bezierToCubic([-1.0,-1.0,-0.7,-0.3,-0.1 , 0.1, 0.3 , 0.7 , 1.0 ,1.0]),
CG.bezierToCubic([ 0.0, 0.5, 0.8, 1.1, 1.25, 1.4, 1.45, 1.55, 1.7 ,0.0]) ]);
Note that in my definition of a Bezier spline in the example above,
the last value in each group of four values is always the same as the
first value in the next group of four values. Therefore I don't repeat that value.
So for N spline segments I need only 3N+1 values.
In particular, the values in blue above are
shared between two Bezier spline segments.
When converted to a cubic spline, the total number of values will expand out to 4N,
since there will be no shared coefficients between cubic spline segments.
Two link IK
We showed an example of two-link IK.
If you want to test your IK, here is some code you can use:
After you have computed the elbow joint between
a shoulder and a wrist, you will want to actually
place a limb that goes from shoulder to elbow,
and another limb that goes from elbow to wrist.
In order to transform a shape so that it
ends up going betwee point A and point B,
you will
want to do the following three things:
-
Translate the shape so that it is located
at the midpoint (A+B)/2;
-
Rotate your shape so that its z axis
lies along the line from A to B;
-
Scale the shape in x and y so that it has
the desired thickness, and scale in z so that
it fits in the distance from A to B.
Only the second step above is tricky to implement.
The basic steps are as follows:
Given a target direction W in which to re-aim the Z axis:
W = normalize(W)
U0 = [0,1,0] ✕ W
U1 = [1,0,0] ✕ W
V0 = Z ✕ V0
V1 = Z ✕ V1
t = U1•U1 / (U0•U0 + U1•U1)
U = normalize( U0(1-t) + U1t )
V = normalize( V0(1-t) + V1t )
Ux Vx Wx 0
rotation matrix = Uy Vy Wy 0
Uz Vz Wz 0
0 0 0 1
Computing mesh normals automatically
For most types of mesh shapes you don't need to manually
compute surface normals. Instead, while you are evaluating
your function
f(u,v)
that converts
uv
to
xyz ,
you can also
be computing a surface normal, as well as a surface
tangent (which is useful for bump mapping).
One way to do this is to define a small offset ε,
which can be something like 1/1000.
For each
(u,v) ,
instead of just evaluating
f(u,v) ,
do four evaluations:
P = f(u-ε,v-ε),
Q = f(u+ε,v-ε),
R = f(u-ε,v+ε),
S = f(u+ε,v+ε).
You can now compute the tangent as
normalize((Q-P)+(S-R)),
and the binormal as
normalize((R-P)+(S-Q)),
Tne surface normal vector is then just the cross
product of the tangent and the binormal.
Final project ideas
At the end of class we divided you into seven
project groups. The attached file shows what
you each suggested for your final project.
Next Monday there will be a person from SVA joining
your group to help with design.
We will spend a large portion of this coming class
going through the projects and helping each other
to refine the ideas and
make sure that what you are proposing is
technically feasible:
Graduate Computer Graphics Fall 2019 Final Project Proposals
Happy Thanksgiving everyone!!!
| |