Hello,
I am a begin mathematica user.
I will try to find the intersection formula between a 3d sphere against 3d line.
I know the center of the sphere a 3d point (Cx,Cy,Cz) and the ray R.
The 3d line is defined how: P+D*t where the P is the line start point, D is the line direction and t is the time where intersection happen.
if intersection exist I should try the scalar value t.
I am trying to solve the equation system in mathematica but I get empty solution. Someone can help me to fix the system?
Thanks in advance.
sphere = (x - xc)^2 + (y - yc)^2 + (z - zc)^2 == radiusSquared
line = y == y0 + t (y1 - y0) && x == x0 + t (x1 - x0) &&
z == z0 + t (z1 - z0)
solutions = Simplify[Solve[sphere && line, {x, y, z, t}]]; (* long expression, perhaps could be simpler with assumption of real parameters*)
Length[solutions] (* two solutions---makes sense*)
Thank you very much to reply. Nice code. The problem is in 3d space and domain is real number.
I try your code but I need to find the solution respect only the t parameters.
How can do it? I need numerical approximate solution.