SLIDE 6 6
R.W. Lindeman - WPI Dept. of Computer Science 11
Determining A Hit (Sphere)
Parametric Equations
P = S + tD F(x,y,z) = x2 + y2 + z2 -1 F(P) = |P|2 -1 = 0 Substituting P into F(P) = 0, we get: D2 * t2 + 2(S•D)*t + (S2 – 1) = 0 Recall the dot-product relation: |a+b|2 = |a|2 + 2a•b + |b|2 This is a quadratic equation of A2*t2 + 2Bt + C = 0
where A = D2 B = S•D C = S2 – 1
R.W. Lindeman - WPI Dept. of Computer Science 12
Determining A Hit (Sphere)
Utilize quadratic equation:
Find the hit point using: If discriminant (B2-AC) is negative: ray misses sphere If discriminant is zero: ray grazes sphere edge Hit point is –B/A Discriminant positive: ray pierces sphere Two hits times (+ and – discriminant)
Normal?
Easy! It's the hit point!
thit = B A ± B2 AC A