Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_DIMENSION_H__
00009 #define __SP_DIMENSION_H__
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "Base/spDimensionPoint2D.hpp"
00020 #include "Base/spDimensionSize2D.hpp"
00021 #include "Base/spDimensionRect2D.hpp"
00022
00023
00024 #include "Base/spDimensionVector3D.hpp"
00025 #include "Base/spDimensionLine3D.hpp"
00026 #include "Base/spDimensionTriangle3D.hpp"
00027 #include "Base/spDimensionQuadrangle3D.hpp"
00028 #include "Base/spDimensionPlane3D.hpp"
00029
00030
00031 #include "Base/spDimensionMatrix2.hpp"
00032 #include "Base/spDimensionMatrix3.hpp"
00033 #include "Base/spDimensionMatrix4.hpp"
00034
00035
00036 #include "Base/spDimensionQuaternion.hpp"
00037 #include "Base/spDimensionAABB.hpp"
00038 #include "Base/spDimensionOBB.hpp"
00039
00040
00041 #include "Base/spDimensionSecureList.hpp"
00042 #include "Base/spDimensionUniversalBuffer.hpp"
00043
00044
00045
00046
00047 namespace sp
00048 {
00049 namespace dim
00050 {
00051
00052
00053 template <typename T> vector3d<T>::vector3d(const point2d<T> &Other) :
00054 X(Other.X ),
00055 Y(Other.Y ),
00056 Z(0 )
00057 {
00058 }
00059 template <typename T> vector3d<T>::vector3d(const size2d<T> &Other) :
00060 X(Other.Width ),
00061 Y(Other.Height ),
00062 Z(1 )
00063 {
00064 }
00065
00066 template <typename T> point2d<T>::point2d(const vector3d<T> &Other) :
00067 X(Other.X),
00068 Y(Other.Y)
00069 {
00070 }
00071
00072 template <typename T> matrix4<T>::matrix4(const matrix3<T> &Other)
00073 {
00074 M[0] = Other[0]; M[4] = Other[3]; M[ 8] = Other[6]; M[12] = 0;
00075 M[1] = Other[1]; M[5] = Other[4]; M[ 9] = Other[7]; M[13] = 0;
00076 M[2] = Other[2]; M[6] = Other[5]; M[10] = Other[8]; M[14] = 0;
00077 M[3] = 0; M[7] = 0; M[11] = 0; M[15] = 1;
00078 }
00079
00080 template <typename T> inline plane3d<T> aabbox3d<T>::getLeftPlane() const
00081 {
00082 return plane3d<T>(vector3d<T>(-1, 0, 0), -Min.X);
00083 }
00084 template <typename T> inline plane3d<T> aabbox3d<T>::getRightPlane() const
00085 {
00086 return plane3d<T>(vector3d<T>(1, 0, 0), Max.X);
00087 }
00088 template <typename T> inline plane3d<T> aabbox3d<T>::getTopPlane() const
00089 {
00090 return plane3d<T>(vector3d<T>(0, 1, 0), Max.Y);
00091 }
00092 template <typename T> inline plane3d<T> aabbox3d<T>::getBottomPlane() const
00093 {
00094 return plane3d<T>(vector3d<T>(0, -1, 0), -Min.Y);
00095 }
00096 template <typename T> inline plane3d<T> aabbox3d<T>::getFrontPlane() const
00097 {
00098 return plane3d<T>(vector3d<T>(0, 0, -1), -Min.Z);
00099 }
00100 template <typename T> inline plane3d<T> aabbox3d<T>::getBackPlane() const
00101 {
00102 return plane3d<T>(vector3d<T>(0, 0, 1), Max.Z);
00103 }
00104
00105 template <typename T> inline bool obbox3d<T>::isPointInside(const vector3d<T> &Point) const
00106 {
00107 return isInversePointInside(matrix4<T>(*this).getInverse() * Point);
00108 }
00109
00110 template <typename T> inline bool obbox3d<T>::isBoxInside(const obbox3d<T> &Other) const
00111 {
00112 const matrix4<T> OtherMat(Other);
00113 const matrix4<T> ThisMat(matrix4<T>(*this).getInverse());
00114
00115 return
00116 isInversePointInside(ThisMat * (OtherMat * vector3d<T>( 1, 1, 1))) &&
00117 isInversePointInside(ThisMat * (OtherMat * vector3d<T>( 1, 1, -1))) &&
00118 isInversePointInside(ThisMat * (OtherMat * vector3d<T>( 1, -1, 1))) &&
00119 isInversePointInside(ThisMat * (OtherMat * vector3d<T>( 1, -1, -1))) &&
00120 isInversePointInside(ThisMat * (OtherMat * vector3d<T>(-1, 1, 1))) &&
00121 isInversePointInside(ThisMat * (OtherMat * vector3d<T>(-1, 1, -1))) &&
00122 isInversePointInside(ThisMat * (OtherMat * vector3d<T>(-1, -1, 1))) &&
00123 isInversePointInside(ThisMat * (OtherMat * vector3d<T>(-1, -1, -1)));
00124 }
00125
00126 template <typename T> inline vector3d<T> aabbox3d<T>::getClosestPoint(const plane3d<T> &Plane) const
00127 {
00128 dim::vector3d<T> Result, Corner;
00129
00130 T Distance = math::OMEGA;
00131 T Temp;
00132
00133 for (s32 i = 0; i < 8; ++i)
00134 {
00135 Corner = getCorner(i);
00136
00137 Temp = Plane.getPointDistance(Corner);
00138
00139 if (Temp < Distance)
00140 {
00141 Result = Corner;
00142 Distance = Temp;
00143 }
00144 }
00145
00146 return Result;
00147 }
00148
00149
00150 }
00151
00152 }
00153
00154
00155 #endif
00156
00157
00158
00159