Box to Plane Intersection With Quaternions
At the moment I'm trying to make an efficient box to plane intersection test for my game. My bounding boxes are oriented, and the rotation is represented by quaternions. I have only been able to find one equation to do box to plane intersections, which is.
d <= a1n*A1 + a2n*A2 + a3n*A3
d = distance from the center of the box to the plane.
a1a3 The extents of the box from the center.
n = Normal of the plane
A1A3 = The x,y,z axis of the box
http://www.gamasutra.com/features/19991018/Gomez_7.htm
I have tested this equation and it works perfectly. Although my problem is when I begin to encorperate the quaternions into the equation for the box rotation. I have been successful by rotating each axis by the quaternion, although I'm doing way to much math for this to be efficient. My only other idea was rotate the normal by the quaternion, although that failed horribly.
Does anyone have any thoughts on how I might accomplish this better?
d <= a1n*A1 + a2n*A2 + a3n*A3
d = distance from the center of the box to the plane.
a1a3 The extents of the box from the center.
n = Normal of the plane
A1A3 = The x,y,z axis of the box
http://www.gamasutra.com/features/19991018/Gomez_7.htm
I have tested this equation and it works perfectly. Although my problem is when I begin to encorperate the quaternions into the equation for the box rotation. I have been successful by rotating each axis by the quaternion, although I'm doing way to much math for this to be efficient. My only other idea was rotate the normal by the quaternion, although that failed horribly.
Does anyone have any thoughts on how I might accomplish this better?
KiroNeem Wrote:My only other idea was rotate the normal by the quaternion, although that failed horribly.
unrotate instead.
Sir, e^iÏ€ + 1 = 0, hence God exists; reply!
KiroNeem Wrote:At the moment I'm trying to make an efficient box to plane intersection test for my game. My bounding boxes are oriented, and the rotation is represented by quaternions. I have only been able to find one equation to do box to plane intersections, which is.
d <= a1n*A1 + a2n*A2 + a3n*A3
d = distance from the center of the box to the plane.
a1a3 The extents of the box from the center.
n = Normal of the plane
A1A3 = The x,y,z axis of the box
http://www.gamasutra.com/features/19991018/Gomez_7.htm
I have tested this equation and it works perfectly. Although my problem is when I begin to encorperate the quaternions into the equation for the box rotation. I have been successful by rotating each axis by the quaternion, although I'm doing way to much math for this to be efficient. My only other idea was rotate the normal by the quaternion, although that failed horribly.
Does anyone have any thoughts on how I might accomplish this better?
Apply the transformation to the vertices of the box to get them in the same coordinate system as the plane. For the box to insersect the plane, it is necessary and sufficient that at least one vertex of the box lies above the plane, and at least one vertex lies below the plane.
To figure out which vertices are above or below the plane, apply the quaternion to each vertex so that it is in the same coordinate system as the plane. Now take each vertex of the box, and find the difference between its location and some location on the plane. Make this a vector and dot it with the normal vector of the plane. If the result is negative then you are below the plane, if it is positive you are above the plane. This is because the result of the dot product is a multiple of the cosine of the angle. So if two of your dot products differ in sign, then the box collides with the plane.
Holmes Wrote:Apply the transformation to the vertices of the box to get them in the same coordinate system as the plane.
I thought about that when first trying to figure this out. The suggest method would work, although to rotate each vertex by the quaternion would be even slower then just rotating each axis vector and using the posted equation.
unknown Wrote:unrotate instead.
...............
Sir, e^iÏ€ + 1 = 0, hence God exists; reply!
unknown Wrote:unrotate instead
Seconded then.
Possibly Related Threads...
Thread:  Author  Replies:  Views:  Last Post  
RayTriangle Intersection  mikey  2  5,693 
Aug 15, 2010 05:11 AM Last Post: mikey 

Skewed Vertices with Quaternions, Matrices, and Good Ol' Trig  Oddity007  4  5,071 
May 12, 2009 03:13 PM Last Post: Oddity007 

Triangle Intersection Tests  merrill541  1  3,791 
Feb 6, 2009 12:13 PM Last Post: scgames 

Quaternions: Pointing one vector at another  wonza  4  4,872 
Oct 1, 2008 12:34 PM Last Post: wonza 

Problems with Rotation using Quaternions  wyrmmage  2  4,729 
Apr 6, 2008 05:57 PM Last Post: wyrmmage 