Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

OrientedBox.cpp

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 // Lamp : Open source game middleware
00003 // Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //------------------------------------------------------------------------------
00019 
00020 /** @file
00021  * 指向性ボックス実装
00022  * @author Junpee
00023  */
00024 
00025 #include "LampBasic.h"
00026 #include "Geometry/Primitive/OrientedBox.h"
00027 #include "Geometry/Distance/AxisAlignedBoxDistance.h"
00028 #include "Geometry/Distance/CapsuleDistance.h"
00029 #include "Geometry/Distance/ConeDistance.h"
00030 #include "Geometry/Distance/LineDistance.h"
00031 #include "Geometry/Distance/OrientedBoxDistance.h"
00032 #include "Geometry/Intersection/AxisAlignedBoxIntersection.h"
00033 #include "Geometry/Intersection/CapsuleIntersection.h"
00034 #include "Geometry/Intersection/ConeIntersection.h"
00035 #include "Geometry/Intersection/LineIntersection.h"
00036 #include "Geometry/Intersection/OrientedBoxIntersection.h"
00037 
00038 namespace Lamp{
00039 
00040 //------------------------------------------------------------------------------
00041 // 定数
00042 //------------------------------------------------------------------------------
00043 // ゼロボックス
00044 const OrientedBox OrientedBox::zero(
00045     Matrix33::zero, Vector3::zero, Vector3::zero);
00046 
00047 // 単位ボックス
00048 const OrientedBox OrientedBox::unit(
00049     Matrix33::unit, Vector3::zero, Vector3(0.5f, 0.5f, 0.5f));
00050 
00051 //------------------------------------------------------------------------------
00052 // トランスフォーム
00053 //------------------------------------------------------------------------------
00054 // スケール有りトランスフォーム
00055 AxisAlignedBox OrientedBox::scaledTransform(const Matrix33& matrix) const{
00056     AxisAlignedBox result;
00057     Vector3 corner[8];
00058     getCornerArray(corner);
00059     Vector3 firstCorner = matrix * corner[7];
00060     result.set(firstCorner, firstCorner);
00061     for(int i = 0; i < 7; i++){ result.merge(matrix * corner[i]); }
00062     return result;
00063 }
00064 //------------------------------------------------------------------------------
00065 // スケール有りトランスフォーム
00066 AxisAlignedBox OrientedBox::scaledTransform(const Matrix34& matrix) const{
00067     AxisAlignedBox result;
00068     Vector3 corner[8];
00069     getCornerArray(corner);
00070     Vector3 firstCorner = matrix * corner[7];
00071     result.set(firstCorner, firstCorner);
00072     for(int i = 0; i < 7; i++){ result.merge(matrix * corner[i]); }
00073     return result;
00074 }
00075 //------------------------------------------------------------------------------
00076 // スケール有りトランスフォーム
00077 AxisAlignedBox OrientedBox::scaledTransform(const Matrix44& matrix) const{
00078     AxisAlignedBox result;
00079     Vector3 corner[8];
00080     getCornerArray(corner);
00081     Vector3 firstCorner = matrix * corner[7];
00082     result.set(firstCorner, firstCorner);
00083     for(int i = 0; i < 7; i++){ result.merge(matrix * corner[i]); }
00084     return result;
00085 }
00086 //------------------------------------------------------------------------------
00087 // 距離
00088 //------------------------------------------------------------------------------
00089 // 点距離の二乗
00090 float OrientedBox::getSquaredDistance(const Vector3& point) const{
00091     return OrientedBoxDistance::squaredDistance(*this, point);
00092 }
00093 //------------------------------------------------------------------------------
00094 // 軸沿いボックス距離の二乗
00095 float OrientedBox::getSquaredDistance(
00096     const AxisAlignedBox& axisAlignedBox) const{
00097     return AxisAlignedBoxDistance::squaredDistance(axisAlignedBox, *this);
00098 }
00099 //------------------------------------------------------------------------------
00100 // カプセル距離の二乗
00101 float OrientedBox::getSquaredDistance(const Capsule& capsule) const{
00102     return CapsuleDistance::squaredDistance(capsule, *this);
00103 }
00104 //------------------------------------------------------------------------------
00105 // コーン距離の二乗
00106 float OrientedBox::getSquaredDistance(const Cone& cone) const{
00107     return ConeDistance::squaredDistance(cone, *this);
00108 }
00109 //------------------------------------------------------------------------------
00110 // ライン距離の二乗
00111 float OrientedBox::getSquaredDistance(const Line& line) const{
00112     return LineDistance::squaredDistance(line, *this);
00113 }
00114 //------------------------------------------------------------------------------
00115 // 指向性ボックス距離の二乗
00116 float OrientedBox::getSquaredDistance(
00117     const OrientedBox& orientedBox) const{
00118     return OrientedBoxDistance::squaredDistance(*this, orientedBox);
00119 }
00120 //------------------------------------------------------------------------------
00121 // 平面距離
00122 float OrientedBox::getDistance(const Plane& plane) const{
00123     return OrientedBoxDistance::distance(*this, plane);
00124 }
00125 //------------------------------------------------------------------------------
00126 // レイ距離の二乗
00127 float OrientedBox::getSquaredDistance(const Ray& ray) const{
00128     return OrientedBoxDistance::squaredDistance(*this, ray);
00129 }
00130 //------------------------------------------------------------------------------
00131 // セグメント距離の二乗
00132 float OrientedBox::getSquaredDistance(const Segment& segment) const{
00133     return OrientedBoxDistance::squaredDistance(*this, segment);
00134 }
00135 //------------------------------------------------------------------------------
00136 // 球距離の二乗
00137 float OrientedBox::getSquaredDistance(const Sphere& sphere) const{
00138     return OrientedBoxDistance::squaredDistance(*this, sphere);
00139 }
00140 //------------------------------------------------------------------------------
00141 // 三角距離の二乗
00142 float OrientedBox::getSquaredDistance(const Triangle& triangle) const{
00143     return OrientedBoxDistance::squaredDistance(*this, triangle);
00144 }
00145 //------------------------------------------------------------------------------
00146 // 交差
00147 //------------------------------------------------------------------------------
00148 // 点交差
00149 bool OrientedBox::intersect(const Vector3& point) const{
00150     return OrientedBoxIntersection::intersect(*this, point);
00151 }
00152 //------------------------------------------------------------------------------
00153 // 軸沿いボックス交差
00154 bool OrientedBox::intersect(const AxisAlignedBox& axisAlignedBox) const{
00155     return AxisAlignedBoxIntersection::intersect(axisAlignedBox, *this);
00156 }
00157 //------------------------------------------------------------------------------
00158 // カプセル交差
00159 bool OrientedBox::intersect(const Capsule& capsule) const{
00160     return CapsuleIntersection::intersect(capsule, *this);
00161 }
00162 //------------------------------------------------------------------------------
00163 // コーン交差
00164 bool OrientedBox::intersect(const Cone& cone) const{
00165     return ConeIntersection::intersect(cone, *this);
00166 }
00167 //------------------------------------------------------------------------------
00168 // ライン交差
00169 bool OrientedBox::intersect(const Line& line) const{
00170     return LineIntersection::intersect(line, *this);
00171 }
00172 //------------------------------------------------------------------------------
00173 // 指向性ボックス交差
00174 bool OrientedBox::intersect(const OrientedBox& orientedBox) const{
00175     return OrientedBoxIntersection::intersect(*this, orientedBox);
00176 }
00177 //------------------------------------------------------------------------------
00178 // 平面交差
00179 bool OrientedBox::intersect(const Plane& plane) const{
00180     return OrientedBoxIntersection::intersect(*this, plane);
00181 }
00182 //------------------------------------------------------------------------------
00183 // レイ交差
00184 bool OrientedBox::intersect(const Ray& ray) const{
00185     return OrientedBoxIntersection::intersect(*this, ray);
00186 }
00187 //------------------------------------------------------------------------------
00188 // セグメント交差
00189 bool OrientedBox::intersect(const Segment& segment) const{
00190     return OrientedBoxIntersection::intersect(*this, segment);
00191 }
00192 //------------------------------------------------------------------------------
00193 // 球交差
00194 bool OrientedBox::intersect(const Sphere& sphere) const{
00195     return OrientedBoxIntersection::intersect(*this, sphere);
00196 }
00197 //------------------------------------------------------------------------------
00198 // 三角交差
00199 bool OrientedBox::intersect(const Triangle& triangle) const{
00200     return OrientedBoxIntersection::intersect(*this, triangle);
00201 }
00202 //------------------------------------------------------------------------------
00203 } // End of namespace Lamp
00204 //------------------------------------------------------------------------------

Generated on Wed Mar 16 10:29:33 2005 for Lamp by doxygen 1.3.2