Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

bs.inl

Go to the documentation of this file.
00001 /*
00002     Sheep - A Rigid Body Dynamics Engine
00003     Copyright (C) 2001-2004 Francois Beaune
00004     Contact: http://toxicengine.sourceforge.net/
00005 
00006     This file is part of Sheep.
00007 
00008     Sheep is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     Sheep is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with Sheep; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 */
00022 
00023 inline
00024 BS::BS() {
00025     Invalidate();
00026 }
00027 
00028 inline
00029 BS::BS(const BS &bs) :
00030     m_center(bs.m_center),
00031     m_radius(bs.m_radius)
00032 {
00033 }
00034 
00035 inline
00036 BS::BS(const Point3 &center) :
00037     m_center(center)
00038 {
00039     Invalidate();
00040 }
00041 
00042 inline
00043 BS::BS(const Point3 &center, Real radius) :
00044     m_center(center),
00045     m_radius(radius) {}
00046 
00047 inline
00048 void BS::Invalidate() {
00049     m_radius = -1.0;
00050 }
00051 
00052 inline
00053 void BS::ComputeSquareRadius() {
00054     m_radius2 = m_radius * m_radius;
00055 }
00056 
00057 inline
00058 void BS::Include(const Point3 &point) {
00059     const Real d = Vector3(point - m_center).Norm();
00060 
00061     if(d > m_radius)
00062         m_radius = d;
00063 }
00064 
00065 inline
00066 void BS::Include(const AABB3 &aabb) {
00067     Include(Point3(aabb.m_min.m_x, aabb.m_min.m_y, aabb.m_min.m_z));
00068     Include(Point3(aabb.m_min.m_x, aabb.m_min.m_y, aabb.m_max.m_z));
00069     Include(Point3(aabb.m_min.m_x, aabb.m_max.m_y, aabb.m_min.m_z));
00070     Include(Point3(aabb.m_min.m_x, aabb.m_max.m_y, aabb.m_max.m_z));
00071     Include(Point3(aabb.m_max.m_x, aabb.m_min.m_y, aabb.m_min.m_z));
00072     Include(Point3(aabb.m_max.m_x, aabb.m_min.m_y, aabb.m_max.m_z));
00073     Include(Point3(aabb.m_max.m_x, aabb.m_max.m_y, aabb.m_min.m_z));
00074     Include(Point3(aabb.m_max.m_x, aabb.m_max.m_y, aabb.m_max.m_z));
00075 }
00076 
00077 inline
00078 void BS::Include(const BS &bs) {
00079     const Real d = Vector3(bs.m_center - m_center).Norm() + bs.m_radius;
00080 
00081     if(d > m_radius)
00082         m_radius = d;
00083 }
00084 
00085 inline
00086 bool BS::Overlaps(const BS &bs) const {
00087     return Vector3(bs.m_center - m_center).Norm() < m_radius + bs.m_radius;
00088 }
00089 
00090 inline
00091 bool BS::Contains(const Point3 &point) const {
00092     return Vector3(point - m_center).Norm() <= m_radius;
00093 }

Generated on Tue May 11 01:31:49 2004 for toxic by doxygen 1.3.6