00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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 }
00204