Math, asked by rockingramya7329, 1 year ago

Longest distance to travel from one vertex of a cube to another vertex

Answers

Answered by ganramesh
0

If you mean to say that you are looking for the entrance and exit points of the ray through the cube, I'd do this:

Given your ray r(t)=u⃗+v⃗tr(t)=u→+v→t, find the tt values of the intersections between this ray and the planes that make up the faces of the cuboid. Do not, at this point, filter out negative tt values.

Sort the intersections by these tt values; if no two of the highest three tt values are from opposite faces, then the middle two tt values define the entrance and exit points of your ray. Now you can figure out if your ray actually hits these points, or if they're actually behind the ray.

There are some special cases here: if your ray never touches some of the planes, then you don't need to keep them around, but your ray only touches the box if the ray is between opposite pairs of planes. This also reduces the list of intersections that you need to check for being on opposite sides by 1, for every 2 planes you don't hit.

Similar questions