CSCE 441 Lecture 24

From Notes
Jump to navigation Jump to search

« previous | Wednesday, March 19, 2014 | next »


Surfaces

Implicit

Defined by a function; points are not directly defined.

F(x,y,z)=0

For example, a sphere is defined by the function

x2+y2+z2r2=0

Shapes that are easy to define implicitly are:

  • spheres
  • planes
  • cylinders
  • cones
  • tori

These types of shapes are easy for raytracers to handle.

Intersections

Given a ray L(t)=P+vt that starts at a point P and extends to infinity in the direction of v, find the intersection of L(t) with F(x,y,z)=0:

Substitute L(t) for x,y,z in the function and solve for t in F(L(t))=0.

Example: L(t)=(0,0,2)+(0,0,1)t and F(x,y,z)=x2+y2+z21=0

F(L(t))=0=(0+0t)2+(0+0t)2+(2+1t)21=44t+t2t=1,3

The solution to the intersection is L(t), so L(1)=(0,0,1) and L(3)=(0,0,1).


Normals

Given F(x,y,z)=0, find the normal at a point (x,y,z)

Assume we have a parametric curve (x(t),y(t),z(t)) on the surface of F(x,y,z), we set F(x(t),y(t),z(t))=0 and differentiate with respect to t:

Fxdxdt+Fydydt+Fzdzdt=0Fx,Fy,Fzdxdt,dydt,dzdt=0=Fv

This represents conceptually the dot product between what must be the normal of the surface and the slope of a line on the surface (i.e. must be tangent to the surface)


Summary

Advantages

  • easy to calculate intersections and normals

Disadvantages:

  • hard to calculate points on the surface


Parametric

P(s,t)=x(s,t),y(s,t),z(s,t)

Intersections

Set L(t)=P(u,v), and solve a system of three equations (each of x, y, and z) for the parameters t, u, and v.

Plug parameters back into equation to find solution.


Example: P(u,v)=u,v,u+v and L(t)=(0,0,1)+(1,0,0)t

{u=tv=0u+v=1

Normals

Assume t is fixed. Set P(s,t)=F(s) and differentiate with respect to s:

P(s,t)s=F(s)s

The RHS represents the tangent at s


Perform a similar operation with t:

P(s,t)t=F(t)t

The RHS represents the tangent at t.

To find the normal, take cross product of tangents:

P(s,t)s×P(s,t)t

Summary

Advantages:

  • easy to generate points on surface

Disadvantages:

  • hard to determine if point is inside or outside
  • hard to determine if point is on the surface


Deformed

Given a surface S and a deformation function D(x,y,z), D(S) is a new surface representing the deformed surface.

This is useful for creating complicated shapes from simple objects.

Intersections

  1. Assume D(x,y,z) is a simple matrix (e.g. affine transformation)
  2. First deform L(t) by D1
  3. Calculate intersection with undeformed surface S
  4. Transform intersection point and normal by D.

Example: deformation of a circle that stretches by factor of two in the x direction: D(x,y)=(2x,y)

L(t)=(1,1,1)+(1,1,0)t

D1(L(t))=[1200010001]([111]+[110]t)


Normals

Define how tangents transform first. Assume C(t) is a curve on the surface:

C(t)C(t+h)C(t)hD(C)(t)D(C)(t+h)D(C)(t)h


Tangents deform by applying transformation D (multiply by matrix)


Normals and tangents are orthogonal both before and after transformation.

Let N be the normal and T be the tangent:

(MN)TDT=0NTMTDT=0NT(MTD)T=0MTD=IM=DT

Hence

Normals transform by the inverse transpose of the deformation matrix, NOT by the deformation matrix.

(why? normal vectors are covectors, not vectors)


Summary

Advantages

  • simple surfaces can represent complex shapes
  • affine transformations yield simple calculations
  • If we are given D1, we never have to compute any matrix inverse.

Disadvantages