So I am trying to symbolically solve a polynomial equation in mathematica that is described with vectors:
A = {Subscript[a, 0], Subscript[a, 1], Subscript[a, 2]}
B = {Subscript[b, 0], Subscript[b, 1], Subscript[b, 2]}
L = {Subscript[P, 0] + Subscript[tD, 0], Subscript[P, 1] + Subscript[tD, 1], Subscript[P, 2] + Subscript[tD, 2]}
K = Cross[(L - A), (L - B)]
Q = B - A
SolveAlways[((K[0]*K[0] + K[1]*K[1] + K[2]*K[2])^2/(Q[0]*Q[0] + Q[1]*Q[1] + Q[2]*Q[2])^2) - r^2, t]
but it cannot symbolically put together the last equation to solve for t. Is there another way for this to be specified for it to solve?
(I am learning mathematica for the first time and my mini project for learning is getting equations for raytracing surfaces, this specifies a cylinder)
1 Answer 1
So after learning the syntax deeper this was how I solved fixed the above
cylindA = {ax, ay, az}
cylindB = {bx, by, bz}
rayR = {px + t*dx, py + t*dy, pz + t*dz}
distInt = Cross[(rayR - cylindA), (rayR - cylindB)]
Q = cylindB - cylindA
Solve[((distInt . distInt)/(Q . Q)) - r^2 == 0, t]
(for things like cylindA you would access it like cylindA[[1]] where indexing starts at 1)
Comments
Explore related questions
See similar questions with these tags.