CSCE 441 Lecture 25
« previous | Friday, March 21, 2014 | next »
Intersecting Simple Surfaces
Infinite Planes
Defined by a normal vector and a point on the plane.
Given a ray , the intersection of the ray and the plane can be found by plugging in , solving for , and plugging that solution back into
Note: if , then the ray and plane are parallel.
In raytracing, we only need the parameter and the normal at that intersection since only the smallest positive value of will be rendered, and the normal is used to calculate lighting/reflection, etc.
Polygons
- Intersect infinite plane containing polygon
- Determine if ponit is inside polygon
Point inside a convex polygon
Check if point is on same side of all planes formed from the edges.
where and are consecutive points on the polygon.
Must be same sign
Ray Casting
Fire a ray from the point and count the number of intersections
- If the number of intersections is odd, then the point is inside the polygon
- If the number of intersections is even, then the point is outsie the polygon
Problems:
- Ray through vertex
- Ray parallel to (along) edge
Solution:
- Shoot a bunch of rays, and use them to "vote" whether you're inside or outside.
Better solution:
Winding numbers
Professor's dog's name is ALMONDS. Like all dogs, Almonds will run around a closed polygon, and if Dr. Schaefer is wrapped in the leash, then he is inside the polygon.
Requires oriented edges
Can be computed in any order.
Given unit normal
- Start with
- For each edge :
- If , then we are inside the polygon.
Advantages:
- Extends to 3D
- Numerically stable
- Even works on models with holes (sort of)
- No ray casting (or infinite amount of ray casting, depending on how you look at it)
Spheres
Three possible cases:
- no intersections: miss sphere entirely
- one intersection: tangent ray
- two intersections: hit sphere on front and back sides
How do we distinguish these cases?
Plug line definition into sphere definition, rearrange into quadratic equation :
- if , no intersection
- if , one intersection
- if , two intersections
Infinite Cylinders
Defined by center ponit , a unit axis direction , and radius
Given ray ,
Perform orthogonal projection to plane defined by on the line and intersect with the circle of radius in 2D
Normal is radially outward from center (normal of circle) at intersection point.