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

Sphere.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/Sphere.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/Distance/PlaneDistance.h"
00033 #include "Geometry/Distance/RayDistance.h"
00034 #include "Geometry/Distance/SegmentDistance.h"
00035 #include "Geometry/Distance/SphereDistance.h"
00036 #include "Geometry/Intersection/AxisAlignedBoxIntersection.h"
00037 #include "Geometry/Intersection/CapsuleIntersection.h"
00038 #include "Geometry/Intersection/ConeIntersection.h"
00039 #include "Geometry/Intersection/LineIntersection.h"
00040 #include "Geometry/Intersection/OrientedBoxIntersection.h"
00041 #include "Geometry/Intersection/PlaneIntersection.h"
00042 #include "Geometry/Intersection/RayIntersection.h"
00043 #include "Geometry/Intersection/SegmentIntersection.h"
00044 #include "Geometry/Intersection/SphereIntersection.h"
00045 
00046 namespace Lamp{
00047 
00048 //------------------------------------------------------------------------------
00049 // 定数
00050 //------------------------------------------------------------------------------
00051 // ゼロ球
00052 const Sphere Sphere::zero(0.f, 0.f, 0.f, 0.f);
00053 
00054 // 単位球
00055 const Sphere Sphere::unit(0.f, 0.f, 0.f, 1.f);
00056 
00057 //------------------------------------------------------------------------------
00058 // 距離
00059 //------------------------------------------------------------------------------
00060 // 点距離の二乗
00061 float Sphere::getSquaredDistance(const Vector3& point) const{
00062     return SphereDistance::squaredDistance(*this, point);
00063 }
00064 //------------------------------------------------------------------------------
00065 // 軸沿いボックス距離の二乗
00066 float Sphere::getSquaredDistance(const AxisAlignedBox& axisAlignedBox) const{
00067     return AxisAlignedBoxDistance::squaredDistance(axisAlignedBox, *this);
00068 }
00069 //------------------------------------------------------------------------------
00070 // カプセル距離の二乗
00071 float Sphere::getSquaredDistance(const Capsule& capsule) const{
00072     return CapsuleDistance::squaredDistance(capsule, *this);
00073 }
00074 //------------------------------------------------------------------------------
00075 // コーン距離の二乗
00076 float Sphere::getSquaredDistance(const Cone& cone) const{
00077     return ConeDistance::squaredDistance(cone, *this);
00078 }
00079 //------------------------------------------------------------------------------
00080 // ライン距離の二乗
00081 float Sphere::getSquaredDistance(const Line& line) const{
00082     return LineDistance::squaredDistance(line, *this);
00083 }
00084 //------------------------------------------------------------------------------
00085 // 指向性ボックス距離の二乗
00086 float Sphere::getSquaredDistance(const OrientedBox& orientedBox) const{
00087     return OrientedBoxDistance::squaredDistance(orientedBox, *this);
00088 }
00089 //------------------------------------------------------------------------------
00090 // 平面距離
00091 float Sphere::getDistance(const Plane& plane) const{
00092     return PlaneDistance::distance(plane, *this);
00093 }
00094 //------------------------------------------------------------------------------
00095 // レイ距離の二乗
00096 float Sphere::getSquaredDistance(const Ray& ray) const{
00097     return RayDistance::squaredDistance(ray, *this);
00098 }
00099 //------------------------------------------------------------------------------
00100 // セグメント距離の二乗
00101 float Sphere::getSquaredDistance(const Segment& segment) const{
00102     return SegmentDistance::squaredDistance(segment, *this);
00103 }
00104 //------------------------------------------------------------------------------
00105 // 球距離の二乗
00106 float Sphere::getSquaredDistance(const Sphere& sphere) const{
00107     return SphereDistance::squaredDistance(*this, sphere);
00108 }
00109 //------------------------------------------------------------------------------
00110 // 三角距離の二乗
00111 float Sphere::getSquaredDistance(const Triangle& triangle) const{
00112     return SphereDistance::squaredDistance(*this, triangle);
00113 }
00114 //------------------------------------------------------------------------------
00115 // 交差
00116 //------------------------------------------------------------------------------
00117 // 点交差
00118 bool Sphere::intersect(const Vector3& point) const{
00119     return SphereIntersection::intersect(*this, point);
00120 }
00121 //------------------------------------------------------------------------------
00122 // 軸沿いボックス交差
00123 bool Sphere::intersect(const AxisAlignedBox& axisAlignedBox) const{
00124     return AxisAlignedBoxIntersection::intersect(axisAlignedBox, *this);
00125 }
00126 //------------------------------------------------------------------------------
00127 // コーン交差
00128 bool Sphere::intersect(const Cone& cone) const{
00129     return ConeIntersection::intersect(cone, *this);
00130 }
00131 //------------------------------------------------------------------------------
00132 // カプセル交差
00133 bool Sphere::intersect(const Capsule& capsule) const{
00134     return CapsuleIntersection::intersect(capsule, *this);
00135 }
00136 //------------------------------------------------------------------------------
00137 // ライン交差
00138 bool Sphere::intersect(const Line& line) const{
00139     return LineIntersection::intersect(line, *this);
00140 }
00141 //------------------------------------------------------------------------------
00142 // 指向性ボックス交差
00143 bool Sphere::intersect(const OrientedBox& orientedBox) const{
00144     return OrientedBoxIntersection::intersect(orientedBox, *this);
00145 }
00146 //------------------------------------------------------------------------------
00147 // 平面交差
00148 bool Sphere::intersect(const Plane& plane) const{
00149     return PlaneIntersection::intersect(plane, *this);
00150 }
00151 //------------------------------------------------------------------------------
00152 // レイ交差
00153 bool Sphere::intersect(const Ray& ray) const{
00154     return RayIntersection::intersect(ray, *this);
00155 }
00156 //------------------------------------------------------------------------------
00157 // セグメント交差
00158 bool Sphere::intersect(const Segment& segment) const{
00159     return SegmentIntersection::intersect(segment, *this);
00160 }
00161 //------------------------------------------------------------------------------
00162 // 球交差
00163 bool Sphere::intersect(const Sphere& sphere) const{
00164     return SphereIntersection::intersect(*this, sphere);
00165 }
00166 //------------------------------------------------------------------------------
00167 // 球交差
00168 bool Sphere::intersect(Intersection* intersection, const Sphere& sphere) const{
00169     return SphereIntersection::intersect(intersection, *this, sphere);
00170 }
00171 //------------------------------------------------------------------------------
00172 // 三角交差
00173 bool Sphere::intersect(const Triangle& triangle) const{
00174     return SphereIntersection::intersect(*this, triangle);
00175 }
00176 //------------------------------------------------------------------------------
00177 // 三角交差
00178 bool Sphere::intersect(
00179     Intersection* intersection, const Triangle& triangle) const{
00180     return SphereIntersection::intersect(intersection, *this, triangle);
00181 }
00182 //------------------------------------------------------------------------------
00183 } // End of namespace Lamp
00184 //------------------------------------------------------------------------------

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