#### Archived

This topic is now archived and is closed to further replies.

# OBB question

This topic is 5198 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have the local-to-world transform matrix for a model. I also have the OBBtree for this model. Now I want to implement the intersection algorithm of two OBB (A,B) Supposing that both (fixed) OBB are given relative to the same coordinate system . question: An axis v is a separating axis if | v * c | > | v * ha | + | v * hb | when: * : dot product c: vector from A''s center to B''s center ha: extent vector of A hb: extent vector of B v : potential separating axis is correct the above-mentioned ??? If it is, how would it be when both OBB has arbitrary rotation and translation? thanks in advance. (sorry for my bad english).

##### Share on other sites
for AABB, with no arbitrary rotation

the format of the box is (Centre, Extent)

so, for boxes (OA, Vector(a0, a1, a2)) and (OB, Vector(b0, b1, b2))

c = OB - OA

r = |v . c|
ra = |v.x| * a0 + |v.y| * a1 + |v.z| * a2
rb = |v.x| * b0 + |v.y| * b1 + |v.z| * b2

v is a separating axis if r > (ra + rb)

so, for OBB, the format of the boxes are

(Centre, Extent, A0, A1, A2)

so for boxes (OA, Vector(a0, a1, a2), A0, A1, A2) and (OB, Vector(b0, b1, b2), B0, B1, B2)

C = OB - OA

r = |v . c|
ra = |v . A0| * a0 + |v . A1| * a1 + |v * A2| * a2
rb = |v . B0| * b0 + |v . B1| * b1 + |v * B2| * b2

v is a separating axis if r > (ra + rb)

##### Share on other sites
Thanks for it.

I''ll check it right now.

##### Share on other sites
(again, sorry for my bad english)
This doesn't work for me.

I have drawn everything to see what is wrong. But everything seems to be well .

This is what I am doing.

This image explains what I want to do.

Just for simplicity, I pass everything to world coordinate system.

hA = A_basis.transpose() * hA ;
hA = local_to_wold_A.getBasis() * hA; // only rotation

hA = B_basis.transpose() * hB ;
hA = local_to_wold_B.getBasis() * hB; // only rotation

centro_A = A_basis.transpose() * centro_A ;
centro_A = local_to_wold_A * centro_A ; // rotation and translation

centro_B = B_basis.transpose() * centro_B ;
centro_B = local_to_wold_B * centro_B ; // rotation and translation

// for the 3 eigen vectors of A in world coordinate system

... ??

// for the 3 eigen vectors of B in world coordinate system

... ??

//for the 9 cross product in world coordinate system

..... ??

I cannot see what is wrong !!!
(Clearly my math is not very good)

[edited by - luzop on April 22, 2004 6:40:03 PM]

##### Share on other sites
you can''t use ha and hb like this.

as you can see on the picture, for A, it''s right, but for B, you''d have to use -hb and project it on the axis.

each components of hb has to be in the opposite direction of the separation axis in test, and each components of A has to be oriented in the positive direction of the separation axis.

anyway, I''m not explaining it very well, but it''s not the way it works. what you could do, is take the min and max corners of the box when projected to the axis, to find the interval of the two boxes, and test intersection between the intervals.

the OBB interval calculations take advantage of the fact that the box is symetrical along it''s three base axes. so, the ''radius'' of the box along an axis is |v . A0| * a0 + |v . A1| * a1 + |v . A2| * a2, Vector(a0, a1, a2) being the extent of the box (a0, a1, a2 are all > 0), and A0, A1, A2 are the three unit orthogonal vectors that define the basis of the box.

you get these vectors by either extracting the rows of the matrices, or the columns.

so in the end, the code is actually a lot simpler than what you have. you don''t need all that funky transpose and object-to-world transforms.

that''s an example for a separation axis test. not exactly the same ago as yours or the one I presented, but close enough

##### Share on other sites

I will read this carefully.

Thank you again.

##### Share on other sites
luzop,

I''m very impressed with your images. This is extremely useful in illustrating your issue. Thanks for including them!

Graham Rhodes
Principal Scientist
Applied Research Associates, Inc.

1. 1
2. 2
Rutin
21
3. 3
JoeJ
18
4. 4
5. 5

• 14
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631722
• Total Posts
3001892
×