Quadratic Equation of Sphere

Quadratic Equation of Circle

Line Equation

m is the gradient and c is the height at which the line crosses the y-axis, also known as the y -intercept.

y=mx +c 
y=x

Vector Form Of Equations Of Line

\vec{r} = \vec{r_0} + t \vec{v} = \langle x_0, y_0, z_0 \rangle + t \langle a,b,c \rangle

Parametric Equations Of Line

r_x = r_{0_x} + b_xt
\\
r_y = r_{0_y} + b_yt

Equation of Circle

(x-a)^2+(y-b)^2=r^2

(a,b) is the center of the circle. If our center is located on origin

(x-a)^2+(y-b)^2=r^2\\
a=0, b=0 \\
x^2+y^2 = r^2 \\~~\\

Quadratic form

If we write the parametric line equation into x and y:

x^2 + y^2 -r^2 = 0 \\
x = a_x + b_xt,~~~~~~y=  a_y + b_yt \\
(a_x + b_xt)^2 +( a_y + b_yt)^2 - r^2 = 0 

If we write the equation in parametric form:

(a_x + b_xt)^2 +( a_y + b_yt)^2 - r^2 = 0 \\
(a_x + b_xt)(a_x + b_xt) +( a_y + b_yt)( a_y + b_yt) - r^2 = 0 \\
(a_x^2 + 2a_xb_xt +b_x^2t^2) + (a_y^2 + 2a_yb_yt +b_y^2t^2) -r^2 = 0 \\
t^2(b_x^2+b_y^2) + t(2a_xb_x+ 2a_yb_y)+(a_x^2+a_y^2-r^2)=0 \\~~\\

a=(-3,-3), ~~~~ b=(1,1),~~~~r=2 \\
2t^2 -12t + 14 = 0

a is the point of the line, b is the vector of the line, r is the radius of the sphere

Quadratic formula

ax^2+bx+c=0 \\ \Downarrow \\
x=\frac{-b \pm \sqrt{b^2-4ac}}{2a} \\~~\\
\Delta = b^2-4ac \\
\Delta \gt 0 \Rightarrow 2~real~solution\\
\Delta = 0 \Rightarrow 1~real~solution\\
\Delta \lt 0 \Rightarrow 0~real~solution\\

Find the roots:

2t^2 -12t + 14 = 0 \\ 
\Delta = (-12)^2-4*2*14\\
\Delta = 32\\
\Delta \gt 0 \Rightarrow 2~real~solution\\~~\\

t_0 = \frac{12 + \sqrt{32} }{4} \approx 4.414\\
t_1 = \frac{12 - \sqrt{32} }{4} \approx 1.585

We can find the coordinates of the intersection points:

x = a_x + b_xt\\y=  a_y + b_yt \\~~\\
a=(-3,-3), b=(1,1)\\~~\\
t=4.414\\
x_0 = -3 + 4.414*1  = 1.414 \\
y_0 = -3 + 4.414*1  = 1.414 \\~~\\

t=1.585\\
x_0 = -3 + 1.585*1  = -1.415\\
y_0 = -3 + 1.585*1  = -1.415

Quadratic Equation of Sphere

x^2 + y^2 + z^2 = r^2
r_x = a_x + b_xt \\
r_y = a_y + b_yt \\
r_z = a_z + b_zt \\

(a_x + b_xt) ^2 + (a_y + b_yt) ^2 + (a_z + b_zt) ^2 - r^2 = 0 \\
t^2(b_x^2+b_y^2+b_z^2) + t(2a_xb_x+ 2a_yb_y+ 2a_zb_z)+ (a_x^2 + a_y^2 + a_z^2 - r^2) = 0

Vector form & Dot product

Sphere: \\
x^2+y^2+z^2=r^2 \\~~\\
Sphere~located~at~(C_x,C_y,C_z):\\
(x-C_x)^2+(y-C_y)^2+(z-C_z)^2=r^2 \\~~\\
IF:\\
P=(x,y,z)\\ 
C=(C_x,C_y,C_z)\\
dot~product~of~~(P-C):\\
(P-C) . (P-C) = (x-C_x)^2+(y-C_y)^2+(z-C_z)^2  \\
\Downarrow \\
(P-C) . (P-C) = r^2 

Ray

Ray: P(t) =A+tb \\
(P(t)-C).(P(t)-C)=r^2\\
(A+tb-C).(A+tb-C)=r^2\\~~\\
(tb+(A-C)).(tb+(A-C))=r^2\\
t^2b.b+2tb+(A-C)+(A-C).(A-C)-r^2 = 0\\~~\\

\frac{-b \pm\sqrt{b^2-4ac}}{2a} \\~~\\
a = b.b\\
b=2b.(A-C)\\
c=(A-C).(A-C)-r^"

Resources:

https://raytracing.github.io/books/RayTracingInOneWeekend.html#addingasphere/ray-sphereintersection


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *