Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

This has to do with collision detection between a ray and a cube. I have a camera position that I am looking from and a ray is being shot into the scene which contains a cube.

I have the ray starting position and direction in 3D space. The cube is defined by its center position coordinates along with height, width, and depth.

I am following an algorithm I found online, and a task that I have become stuck on is finding the closest and farthest points of the cube. Google searches haven't proved promising for me thus far, I would appreciate any suggestions!

share|improve this question
3  
The farthest point on the cube has to be a vertex, so that part is easy. (In general, the farthest point in any closed convex set has to be on its boundary - just check that it's true on any line segment - and all the faces and edges of the cube are also convex.) –  Greg Martin Feb 28 '12 at 0:18
    
Yes, I believe you are right. I wasn't quite sure before but this certainly makes intuitive sense. –  Aaron Feb 28 '12 at 0:46
1  
To clarify the question, do you mean the closest and farthest points on a fixed ray? Or do you mean the closest and farthest points on any ray from a fixed point? –  Code-Guru Jul 19 '12 at 14:47

1 Answer 1

Do you mean the longest distance of a ray drawn inside of the cube? If yes, then you need to draw the ray from one vertex to the other side in that way it forms a triangle with two diagonals of the square faces and the height will be the side of square face.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.