Registered Member
|
Hi,
I am trying to find an implementation of Oriented Bounding Box. Would be nice if its implemented like AlignedBox (template with Scalar and Dim). Any one knows one? Im aware of this post viewtopic.php?f=74&t=111329&p=265713&hilit=oriented+box#p265713 but as far as i can find its never been published. Im looking methods for intersection and containsPoint tests. if you can help me a bit on this methods i am willing to do/publish rest of the work If there is no such a implementation. Thanks a lot! |
Registered Member
|
Now i have this which is probably not the best Eigen way of implementing it. I tried to implement ideas in http://stackoverflow.com/questions/7328424/point-in-obb-oriented-bounding-box-algorithm and http://www.flipcode.com/archives/2D_OBB_Intersection.shtml and i dont know how to apply for N dimensions and maybe Eigen has better routines to implement this?
|
Moderator
|
What about implementing it as an aggregate of an AxisAlignedBox and a rotation matrix? You could even add a third template parameter to let the user choose its own representation of rotation with a Matrix<> as default parameter. In 3D, one might typically use a Quaternion to get a more compact representation.
|
Registered Member
|
Hi,
Thanks a lot. Do you mean something like this? template<typename Scalar, typename RotationMatrix, int Dim> OrientedBox: public AxisAlignedBox<Scalar, Dim> { bool isIntersect( const OrientedBox<Scalar, RotationMatrix, Dim> & other ) bool contains( const Matrix<Scalar, Dim, 1, DontAlign, Dim, 1> & vec ) }; Also how one can implement generic Separating Axis Theorem function to test intersection between two OrientedBox<Scalar, Ndim>? As far as i know in 2d we need to use edge normals but in 3d face normals. Is it good a idea to specialise OrientedBox for 2 and 3 dimension? Im trying to figure this function design. Any tip for this? |
Registered Member
|
I haven't fully tested yet (did a quick one with 2d) but i managed to implement generalized test for intersection and contains methods.
I am trying to follow the optimized version of SAT http://www.jkh.me/files/tutorials/Separating%20Axis%20Theorem%20for%20Oriented%20Bounding%20Boxes.pdf Still not sure if its correct for 3D or not. Any help/test/suggestion would be appreciated.
|
Registered Member
|
As far as I learned from SAT docs and tutorials there is no easy way to implement generalized (and simplified) method for testing 2d, 3d. All docs I have found are suggesting different optimisations for each case.
For this reason I went back to implement 2d and 3d in different specializations. Now 2d is tested and working. Im just getting compiler error for containsOriented method. Error is
Current implementation :
|
Registered Member
|
I managed to test and implement 2d version. Intersection and contains point functions are working. Will be implementing 3d version in the next couple days. I replaced rotations with transforms and now class is called TransformedBox.
Let me know what you think Edit : Added default constructor
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]