graphics - Intersection between line and sphere -


i need find intersection between line , sphere defined following equations

line: p = p0 + tv, p0 eye of camera , v direction of ray.

sphere: (p - pc)^t (p - pc) = r^2, pc center of sphere , r radius

how solve t?

i assume v normalized.

the point of closest approach of line center of sphere occurs @ t1:

v . (p0 + t1 v - pc) = 0 v . (pc - p0) = t1 

at t1 distance line center of sphere is

h = sqrt((pc - p0)^2 - t1^2) 

the intersection surface of sphere occur (if occurs @ all) @ t1 +/- td, where

td^2 + h^2 = r^2 td^2 = r^2 - h^2      = r^2 - (pc - p0)^2 + t1^2      = r^2 - (pc - p0)^2 + (v . (pc - p0))^2 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -