Simbody  3.4 (development)
OrientedBoundingBox.h
Go to the documentation of this file.
00001 #ifndef SimTK_SIMMATH_ORIENTED_BOUNDING_BOX_H_
00002 #define SimTK_SIMMATH_ORIENTED_BOUNDING_BOX_H_
00003 
00004 /* -------------------------------------------------------------------------- *
00005  *                        Simbody(tm): SimTKmath                              *
00006  * -------------------------------------------------------------------------- *
00007  * This is part of the SimTK biosimulation toolkit originating from           *
00008  * Simbios, the NIH National Center for Physics-Based Simulation of           *
00009  * Biological Structures at Stanford, funded under the NIH Roadmap for        *
00010  * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody.  *
00011  *                                                                            *
00012  * Portions copyright (c) 2008-12 Stanford University and the Authors.        *
00013  * Authors: Peter Eastman                                                     *
00014  * Contributors:                                                              *
00015  *                                                                            *
00016  * Licensed under the Apache License, Version 2.0 (the "License"); you may    *
00017  * not use this file except in compliance with the License. You may obtain a  *
00018  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0.         *
00019  *                                                                            *
00020  * Unless required by applicable law or agreed to in writing, software        *
00021  * distributed under the License is distributed on an "AS IS" BASIS,          *
00022  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
00023  * See the License for the specific language governing permissions and        *
00024  * limitations under the License.                                             *
00025  * -------------------------------------------------------------------------- */
00026 
00027 #include "SimTKcommon.h"
00028 #include "simmath/internal/common.h"
00029 
00030 namespace SimTK {
00031 
00042 class SimTK_SIMMATH_EXPORT OrientedBoundingBox {
00043 public:
00044     OrientedBoundingBox();
00051     OrientedBoundingBox(const Transform& transform, const Vec3& size);
00055     explicit OrientedBoundingBox(const Vector_<Vec3>& points);
00059     const Transform& getTransform() const;
00063     const Vec3& getSize() const;
00067     bool containsPoint(const Vec3& point) const;
00071     bool intersectsBox(const OrientedBoundingBox& box) const;
00082     bool intersectsRay(const Vec3& origin, const UnitVec3& direction, 
00083                        Real& distance) const;
00088     Vec3 findNearestPoint(const Vec3& position) const;
00094     void getCorners(Vec3 corners[8]) const;
00095 private:
00096     Real calculateVolume(const Vector_<Vec3>& points, const Rotation& rotation);
00097     Transform transform;
00098     Vec3 size;
00099 };
00100 
00101 SimTK_SIMMATH_EXPORT OrientedBoundingBox 
00102 operator*(const Transform& t, const OrientedBoundingBox& box);
00103 
00104 } // namespace SimTK
00105 
00106 #endif // SimTK_SIMMATH_ORIENTED_BOUNDING_BOX_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines