# how define a system of equations

Posted 10 years ago
3065 Views
|
4 Replies
|
0 Total Likes
|
 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. 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]}]
4 Replies
Sort By:
Posted 10 years ago
 Thank you!
Posted 10 years ago
 t/.solutionst/.solutions/.{xc -> 0, yc -> 0, zc -> 0, radiusSquared -> 1,   x0 -> -1/2, y0 -> 0, z0 -> 0,  x1 -> 1/2, y1 -> 0, z1 -> 0}
Posted 10 years ago
 Here you go:sphere = (x - xc)^2 + (y - yc)^2 + (z - zc)^2 ==  radiusSquaredline = 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 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.