Modified 8 years, 5 months ago Viewed 10k times 7 In 3D space I am trying to determine…
- User
Modified 8 years, 5 months ago Viewed 10k times 7
In 3D space I am trying to determine if a ray/line intersects a square and if so, the x and y position on the square that it intersects.
I have a ray represented by two points:
R1 = (Rx1, Ry1, Rz1) and R2 = (Rx2, Ry2, Rz2) And the square is represented by four vertices:
S1 = (Sx1, Sy1, Sz1), S2 = (Sx2, Sy2, Sz2), S3 = (Sx3, Sy3, Sz3) and S4 = (Sx4, Sy4, Sz4). I’ve found lots of algebraic equations for this online but none seem to fit this problem exactly. Ideally I would like the answer in Java code, but an equation that I can easily convert to code will do also.
All help will be appreciated.
Does he mean R1 is the origin and R2 is the direction, or R2 is the ending piont?
- Assistant