OBB question

Started by
5 comments, last by luzop 20 years ago
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).
Advertisement
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)

Everything is better with Metal.

Thanks for it.

I''ll check it right now.
(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]
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

http://www.gamedev.net/community/forums/post.asp?method=reply&topic_id=220988

Everything is better with Metal.


I will read this carefully.

Thank you again.
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.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net

This topic is closed to new replies.

Advertisement