Message Boards Message Boards


how define a system of equations

Posted 10 years ago
4 Replies
0 Total Likes
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.
Solve[(((x - Subscript[c, x])^2 + (y - Subscript[c, y])^2 + (z -

          Subscript[c, z])^2) - r^2 == 0) && (x == Subscript[t, x]*Subscript[d, x] + Subscript[p, x]) &&
  y == Subscript[t, y]*Subscript[d, y] + Subscript[p, y] && z == Subscript[t, z] + Subscript[d, z] + Subscript[p,z], {Subscript[t, x], Subscript[t, y], Subscript[t, z]}]
POSTED BY: lespaullpj
4 Replies
Posted 10 years ago
Thank you!
POSTED BY: lespaullpj

t/.solutions/.{xc -> 0, yc -> 0, zc -> 0, radiusSquared -> 1, 
  x0 -> -1/2, y0 -> 0, z0 -> 0,  x1 -> 1/2, y1 -> 0, z1 -> 0}
POSTED BY: W. Craig Carter
Here you go:
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*)
HTH, Craig
POSTED BY: W. Craig Carter
Posted 10 years ago
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. 

Thanks in advance.
POSTED BY: lespaullpj
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract