# UnitMath Example: ( Geometric Intersections ) Last Modified: 1/15/2000

### email Examples FAQ Home Sales \$\$\$ What's New Windows demo

The following examples show how to use UnitMath with geometric Intersections. ### Sphere and Line TOP

Find the intersection between a sphere and a line. The standard equation for a sphere centered on point ( xc, yc, zc ) is:

( x - xc )^2 + ( y - yc )^2 + ( z - zc )^2 = radius^2

There are several ways to write the equation of a line.

Point Direction form: ( x - x1 ) / a = ( y - y1 ) / b = ( z - z1 ) / c
Two Point form: ( x - x1 ) / ( x2 - x1 ) = ( y - y1 ) / ( y2 - y1 ) = ( z - z1 ) / ( z2 - z1 )
Parametric form: x = x1 + a t; y = y1 + b t; z = z1 + c t

### Examples

Find the intersection between a sphere and a line defined by the "Point Direction" form

" Define the givens "
xc: 1 ft; yc: 2 ft; zc: -5 inches; radius: 2 ft;
x1: xc; y1: 1 ft; z1: 0 ft;
a: 1; b: 2; c: -1;

" Define the domains & required precision "
x: ( -1 to 3 ) ft as ft & in;
y: ( 0 to 4 ) ft as ft & in;
z: ( -3 to 2 ) ft as ft & in;
d: inch/100;

solve
(
( x - xc )^2 + ( y - yc )^2 + ( z - zc )^2 = radius^2;
( x - x1 ) / a = ( y - y1 ) / b;
( y - y1 ) / b = ( z - z1 ) / c;
x: d; y: d; z: d
) ~
x: ( 7.28 to 7.29 ) in; y: 2.57 in; z: ( 4.71 to 4.72 ) in;
x: 2 ft + 2.38 in; y: 3 ft + ( 4.76 to 4.77 ) in; z: -ft -2.38 in;

So there are two solutions
x: ( 7.28 to 7.29 ) in; y: 2.57 in; z: ( 4.71 to 4.72 ) in;
&
x: 2 ft + 2.38 in; y: 3 ft + ( 4.76 to 4.77 ) in; z: -ft -2.38 in;

Find the intersection between a sphere and a line defined by the "Two Point" form

" Define the givens "
xc: 1 ft; yc: 2 ft; zc: -5 inches; radius: 2 ft;
x1: 0 m; y1: 0 m; z1: 0 ft;
x2: xc; y2: yc; z2: zc;

" Define the domains & required precision "
x: ( -1 to 3 ) ft as ft & in;
y: ( 0 to 4 ) ft as ft & in;
z: ( -3 to 2 ) ft as ft & in;

d: inch/100;

solve
(
( x - xc )^2 + ( y - yc )^2 + ( z - zc )^2 = radius^2;
( x - x1 ) / ( x2 - x1 ) = ( y - y1 ) / ( y2 - y1 );
( y - y1 ) / ( y2 - y1 ) = ( z - z1 ) / ( z2 - z1 );
x: d; y: d; z: d
) ~
x: 1.45 in; y: ( 2.89 to 2.90 ) in; z: -0.60 in;
x: ft + 10.55 in; y: 3 ft + ( 9.10 to 9.11 ) in; z: -9.40 in;

Find the intersection between a sphere and a line defined by the "Parametric" form

" Define the givens "
xc: 1 ft; yc: 2 ft; zc: -5 inches; radius: 2 ft;
x1: xc; y1: 1 ft; z1: 0 ft;
a: 1; b: 2; c: -1;

" Define the domains & required precision "
x: ( -1 to 3 ) ft as ft & in;
y: ( 0 to 4 ) ft as ft & in;
z: ( -3 to 2 ) ft as ft & in;
t: (-10 to 10) ft as ft & in;

d: inch/100;

solve
(
( x - xc )^2 + ( y - yc )^2 + ( z - zc )^2 = radius^2;
x = x1 + a t; y = y1 + b t; z = z1 + c t;
x: d; y: d; z: d
) ~
t: ( -4.72 to -4.71 ) in; x: ( 7.28 to 7.29 ) in; y: 2.57 in; z: ( 4.71 to 4.72 ) in;
t: ft + 2.38 in; x: 2 ft + 2.38 in; y: 3 ft + ( 4.76 to 4.77 ) in; z: -ft -2.38 in;