<p>Ray vs OBB intersection works by shooting a ray towards the OBB's planes. This results in 2 intersections referred to as <code>t1</code> and <code>t2</code> (per axis), also referred to as <code>tNear</code> and <code>tFar</code> or <code>tMin</code> and <code>tMax</code>.</p>

<p><a href="https://i.sstatic.net/saY7S.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/saY7S.png" alt=""></a></p>

<p>Checking whether the ray intersects with the box, can then be done by comparing the largest <code>tNear</code> against the smallest <code>tFar</code>. If the largest <code>tNear</code> is less than the smallest <code>tFar</code> then there is a intersection.</p>

CC BY-SA 3.0
2017-03-26T13:48:13.903Z
thanks for this i just have couple of questions....first what are the equations of this plane and for 3d i should have a pair of z planes right?
dkoder
CC BY-SA 3.0
2017-03-28T00:33:58.307Z
Yes for 3D you'd just have to add z as well, the concept stays the same. I can write you a short snippet of the algorithm. Do you have a preferred language? C, Python or?
vallentin
CC BY-SA 3.0
2017-03-30T16:21:13.487Z
Sorry for the late reply...python code would be nice
dkoder
CC BY-SA 3.0
2017-03-25T16:59:26.117Z
2017-03-25T16:59:26.117Z
vallentin
<p>I am trying to make 3D drawing software. I wanted to have the drag feature so I am using object picking using the OBB algorithm. I am facing problems in understanding the algorithm, and my implementation thus is having bugs.</p>

<p>How do I implement object picking, using OBB in OpenGL? As I am new to OpenGL (free-glut library), a step by step explanation would be helpful.</p>

<p>I am not able to understand what t1 and t2 mean and how the algorithm is working. If you explain the algorithm that would be enough.</p>

CC BY-SA 3.0
2017-03-25T16:13:41.017Z
Could you elaborate on the problems? Also just to be sure, this doesn't have anything directly to do with OpenGL right?
vallentin
CC BY-SA 3.0
2017-03-25T16:32:12.700Z
I am facing problem in implementing object picking using obb algorithm.I am not able to understand what does t1 and t2 means and how the algorithm is working. And for opengl i am using glut library if you explain the algorithm that would be enough.
dkoder
CC BY-SA 3.0
2017-03-27T05:17:16.937Z
First of go with GLFW library rather than going with freeglut And check out this tutorial... http://antongerdelan.net/opengl/raycasting.html
videogamechef
CC BY-SA 3.0
2017-03-27T17:02:34.117Z
@dkoder Can you edit the question to summarize what you understand already and where specifically you're having trouble? Currently your question is too unclear to really answer. :(
Nathan Reed
<opengl><raytracing><3d>
How do I implement object picking, using OBB in OpenGL?
dkoder
# How do I implement object picking, using OBB in OpenGL?

(Asked by: username_0 on 2017-03-25)

I am trying to make 3D drawing software. I wanted to have the drag feature so I am using object picking using the OBB algorithm. I am facing problems in understanding the algorithm, and my implementation thus is having bugs.

How do I implement object picking, using OBB in OpenGL? As I am new to OpenGL (free-glut library), a step by step explanation would be helpful.

I am not able to understand what t1 and t2 mean and how the algorithm is working. If you explain the algorithm that would be enough.

**Tags:** opengl, raytracing, 3d

> **Comments:**
> **username_1**: Could you elaborate on the problems? Also just to be sure, this doesn't have anything directly to do with OpenGL right?  
> **username_0**: I am facing problem in implementing object picking using obb algorithm.I am not able to understand what does t1 and t2 means and how the algorithm is working. And for opengl i am using glut library if you explain the algorithm that would be enough.  
> **username_2**: First of go with GLFW library rather than going with freeglut And check out this tutorial... http://antongerdelan.net/opengl/raycasting.html  
> **username_3**: @username_0 Can you edit the question to summarize what you understand already and where specifically you're having trouble? Currently your question is too unclear to really answer. :(  

---

## 1 answers

### Answer by username_1 on 2017-03-25. Score: 3

Ray vs OBB intersection works by shooting a ray towards the OBB's planes. This results in 2 intersections referred to as `t1` and `t2` (per axis), also referred to as `tNear` and `tFar` or `tMin` and `tMax`.

[![](https://i.sstatic.net/saY7S.png)](https://i.sstatic.net/saY7S.png)

Checking whether the ray intersects with the box, can then be done by comparing the largest `tNear` against the smallest `tFar`. If the largest `tNear` is less than the smallest `tFar` then there is a intersection.

> **Comments:**
> **username_0**: thanks for this i just have couple of questions....first what are the equations of this plane and for 3d i should have a pair of z planes right?  
> **username_1**: Yes for 3D you'd just have to add z as well, the concept stays the same. I can write you a short snippet of the algorithm. Do you have a preferred language? C, Python or?  
> **username_0**: Sorry for the late reply...python code would be nice  

---

