Upload
dale-parsons
View
39
Download
0
Embed Size (px)
DESCRIPTION
Object Intersection. Object Representation. Implicit forms F(x,y,z) = 0. testing. Explicit forms Analytic form x = F(y,z). generating. Parametric form (x,y,z) = P(t). Ray-Object Intersection. Implicit forms F(x,y,z) = 0. Ray: P(t) = (x,y,z) = source + t*direction = s + t*c. - PowerPoint PPT Presentation
Citation preview
CSE 681
Object Representation
Implicit formsF(x,y,z) = 0
Explicit formsAnalytic form x = F(y,z)
testing
generating
Parametric form (x,y,z) = P(t)
CSE 681
Ray-Object Intersection
Implicit formsF(x,y,z) = 0
Ray: P(t) = (x,y,z) = source + t*direction = s + t*c
Solve for t: F(P(t)) = 0
CSE 681
Ray-Sphere Intersection
Implicit form for sphere at origin of radius 1F(x,y,z) = x2 + y2 + z2 - 1 = 0
Ray: P(t) = (x,y,z) = s + t*c = (sx + t*cx, sy+t*cy, sz+t*cz)
Solve: F(P(t)) = (sx + t*cx)2 + (sy+t*cy)2 + (sz+t*cz)2 - 1 = 0sx
2+sy2+sz
2 + t*2*(sxcx+sycy+szcz) + t2*(cx2+cy
2+cz2) -1 = 0
Use quadratic equation…
CSE 681
Ray-Sphere Intersection
At2 + Bt + C = 0A = |c|2
B = 2s·cC = |s|2 - 1
B2-4AC < 0 => no intersection = 0 => just grazes > 0 => two hits
A
ACBBt
2
42
CSE 681
Axis-Aligned Cuboid (rectangular solid, rectangular parallelpiped)
X = x1 X = x2
Y = y2
Y = y1
Z = z1
Z = z2
P(t) = s + tc
tx1 = (x1 - sx)/cx
tx2 = (x2 - sx)/cx
ty1 = (y1 - sx)/cx
…
Solve for intersections with planes
Planar equationsRay equation
CSE 681
RectangleFor each intersection, note whether entering or leaving square side of plane
Ray is inside after last entering and before first leavingRay 1
Ray 2
CSE 681
Normal Vector
Given ordered sequence of points defining a polygon how do you find a normal vector for the plane?
Ordered: e.g., clockwise when viewed from the front of the face
Right hand v. left hand space
Note: 2 normal vectors to a plane, colinear and one is the negation of the other
CSE 681
Normal Vectormx = (yi - ynext(i)) (zi - znext(i))
V1
V2
V3
V4
V5
V1 V2
V3
V4
V5
V1
V2 V3
V4
V5
my = (zi - znext(i)) (xi - xnext(i))
mz = (xi - xnext(i)) (yi - ynext(i))
CSE 681
Ray-Plane
Ax + by + cz + d = 0
P = s + t*dir
n ·P = -d
n· (s+t*dir) = -dn·s + t*(n·dir) = -dt = -(d + n·s)/(n·dir)
CSE 681
Ray-Polyhedron
Polyhedron - volume bounded by flat facesEach face is defined by a ring of edgesEach edge is shared by 2 and only 2 faces
Faces can be convex or concave
The polyhedron can be convex or concave
CSE 681
Convex Polyhedronvolume bounded by finite number of infinite planes
Intersection going from outside to inside
Intersection going from inside to outside
Computing intersections is similar to cube but using ray-plane intersection and arbitrary number of planes
CSE 681
Convex Polyhedron
Intersection going from outside to insideIntersection going from inside to outside
Record maximum entering intersection - enterMaxRecord minimum leaving intersection - leaveMin
If (enterMax < leaveMin) polyhedron is intersected
CSE 681
Concave Polyhedron
Find first face (if any) intersected by ray
Need ray-face (ray-polygon) intersection test
CSE 681
Ray-Polyhedron
1. Intersect ray with plane
2. Determine if intersection point is inside of 2D polygon
A) Convex polygon
B) Concave polygon
CSE 681
Ray-Convex Polygon
Test to see if point is on‘inside’ side of each edge
E
V
n
n·(VxE) > 0
VxEDot product of
normalCross product of
ordered edge vector from edge source to point of intersection
CSE 681
Ray-concave polygon
Project to plane of 2 smallest coordinates of normal vector
Form semi-infinite ray and count ray-edge intersections
Project plane and point of intersection to 2D plane
2D point-inside-a-polygon test
CSE 681
Transformed objectsIntersect ray with transformed object
Use inverse of object transformation to transform rayIntersect transformed ray with untransformed object
e.g., Ellipse is transformed sphere
Object spaceWorld space
CSE 681
Transformed objects
R(t) T = M-1sT + M -1 cT
r(t) = s + t*c
s = [sx,sy,sz,1] c = [cx, cy, cz, 0]
Object space ray
World space ray
Transform intersection point and normal back to world space
worldPnt T= M*objPnt T
worldN = (M -1) T *N T
CSE 681
Ray-Cylinder
rP = s1 + t1*dir1
Q = s2 + t2*dir2
r
0)()(
0)()(
221
121
dirtQtP
dirtQtP
Compute distance to intercept at r from cylinder axis
CSE 681
Ray-Cylinder
0)()(
0)()(
221
121
dirtQtP
dirtQtP
0**
0**
2222111
1222111
dirdirtsdirts
dirdirtsdirts