Go to the documentation of this file.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
00026
00027
00028
00029
00030
00031
00032
00033
00034
00037 #include "fcl/ccd/interval_vector.h"
00038 #include <iostream>
00039
00040 namespace fcl
00041 {
00042
00043
00044 IVector3::IVector3() {}
00045
00046 IVector3::IVector3(FCL_REAL v) { setValue(v); }
00047
00048 IVector3::IVector3(FCL_REAL x, FCL_REAL y, FCL_REAL z) { setValue(x, y, z); }
00049
00050 IVector3::IVector3(FCL_REAL xl, FCL_REAL xu, FCL_REAL yl, FCL_REAL yu, FCL_REAL zl, FCL_REAL zu)
00051 {
00052 setValue(xl, xu, yl, yu, zl, zu);
00053 }
00054
00055 IVector3::IVector3(FCL_REAL v[3][2]) { setValue(v); }
00056
00057 IVector3::IVector3(Interval v[3]) { setValue(v); }
00058
00059 IVector3::IVector3(const Interval& v1, const Interval& v2, const Interval& v3) { setValue(v1, v2, v3); }
00060
00061 IVector3::IVector3(const Vec3f& v) { setValue(v); }
00062
00063 void IVector3::setZero() { setValue((FCL_REAL)0.0); }
00064
00065 IVector3 IVector3::operator + (const IVector3& other) const
00066 {
00067 return IVector3(i_[0] + other.i_[0], i_[1] + other.i_[1], i_[2] + other.i_[2]);
00068 }
00069
00070 IVector3& IVector3::operator += (const IVector3& other)
00071 {
00072 i_[0] += other[0];
00073 i_[1] += other[1];
00074 i_[2] += other[2];
00075 return *this;
00076 }
00077
00078 IVector3 IVector3::operator - (const IVector3& other) const
00079 {
00080 return IVector3(i_[0] - other.i_[0], i_[1] - other.i_[1], i_[2] - other.i_[2]);
00081 }
00082
00083 IVector3& IVector3::operator -= (const IVector3& other)
00084 {
00085 i_[0] -= other[0];
00086 i_[1] -= other[1];
00087 i_[2] -= other[2];
00088 return *this;
00089 }
00090
00091 Interval IVector3::dot(const IVector3& other) const
00092 {
00093 return i_[0] * other.i_[0] + i_[1] * other.i_[1] + i_[2] * other.i_[2];
00094 }
00095
00096 IVector3 IVector3::cross(const IVector3& other) const
00097 {
00098 return IVector3(i_[1] * other.i_[2] - i_[2] * other.i_[1],
00099 i_[2] * other.i_[0] - i_[0] * other.i_[2],
00100 i_[0] * other.i_[1] - i_[1] * other.i_[0]);
00101 }
00102
00103 Interval IVector3::dot(const Vec3f& other) const
00104 {
00105 return i_[0] * other[0] + i_[1] * other[1] + i_[2] * other[2];
00106 }
00107
00108 IVector3 IVector3::cross(const Vec3f& other) const
00109 {
00110 return IVector3(i_[1] * other[2] - i_[2] * other[1],
00111 i_[2] * other[0] - i_[0] * other[2],
00112 i_[0] * other[1] - i_[1] * other[0]);
00113 }
00114
00115 FCL_REAL IVector3::volumn() const
00116 {
00117 return i_[0].diameter() * i_[1].diameter() * i_[2].diameter();
00118 }
00119
00120 void IVector3::print() const
00121 {
00122 std::cout << "[" << i_[0][0] << "," << i_[0][1] << "]" << std::endl;
00123 std::cout << "[" << i_[1][0] << "," << i_[1][1] << "]" << std::endl;
00124 std::cout << "[" << i_[2][0] << "," << i_[2][1] << "]" << std::endl;
00125 }
00126
00127 Vec3f IVector3::center() const
00128 {
00129 return Vec3f(i_[0].center(), i_[1].center(), i_[2].center());
00130 }
00131
00132 void IVector3::bound(const IVector3& v)
00133 {
00134 if(v[0][0] < i_[0][0]) i_[0][0] = v[0][0];
00135 if(v[1][0] < i_[1][0]) i_[1][0] = v[1][0];
00136 if(v[2][0] < i_[2][0]) i_[2][0] = v[2][0];
00137
00138 if(v[0][1] > i_[0][1]) i_[0][1] = v[0][1];
00139 if(v[1][1] > i_[1][1]) i_[1][1] = v[1][1];
00140 if(v[2][1] > i_[2][1]) i_[2][1] = v[2][1];
00141 }
00142
00143 void IVector3::bound(const Vec3f& v)
00144 {
00145 if(v[0] < i_[0][0]) i_[0][0] = v[0];
00146 if(v[1] < i_[1][0]) i_[1][0] = v[1];
00147 if(v[2] < i_[2][0]) i_[2][0] = v[2];
00148
00149 if(v[0] > i_[0][1]) i_[0][1] = v[0];
00150 if(v[1] > i_[1][1]) i_[1][1] = v[1];
00151 if(v[2] > i_[2][1]) i_[2][1] = v[2];
00152 }
00153
00154
00155 IVector3 bound(const IVector3& i, const IVector3& v)
00156 {
00157 IVector3 res(i);
00158 if(v[0][0] < res.i_[0][0]) res.i_[0][0] = v[0][0];
00159 if(v[1][0] < res.i_[1][0]) res.i_[1][0] = v[1][0];
00160 if(v[2][0] < res.i_[2][0]) res.i_[2][0] = v[2][0];
00161
00162 if(v[0][1] > res.i_[0][1]) res.i_[0][1] = v[0][1];
00163 if(v[1][1] > res.i_[1][1]) res.i_[1][1] = v[1][1];
00164 if(v[2][1] > res.i_[2][1]) res.i_[2][1] = v[2][1];
00165
00166 return res;
00167 }
00168
00169 IVector3 bound(const IVector3& i, const Vec3f& v)
00170 {
00171 IVector3 res(i);
00172 if(v[0] < res.i_[0][0]) res.i_[0][0] = v[0];
00173 if(v[1] < res.i_[1][0]) res.i_[1][0] = v[1];
00174 if(v[2] < res.i_[2][0]) res.i_[2][0] = v[2];
00175
00176 if(v[0] > res.i_[0][1]) res.i_[0][1] = v[0];
00177 if(v[1] > res.i_[1][1]) res.i_[1][1] = v[1];
00178 if(v[2] > res.i_[2][1]) res.i_[2][1] = v[2];
00179
00180 return res;
00181 }
00182
00183 bool IVector3::overlap(const IVector3& v) const
00184 {
00185 if(v[0][1] < i_[0][0]) return false;
00186 if(v[1][1] < i_[1][0]) return false;
00187 if(v[2][1] < i_[2][0]) return false;
00188
00189 if(v[0][0] > i_[0][1]) return false;
00190 if(v[1][0] > i_[1][1]) return false;
00191 if(v[2][0] > i_[2][1]) return false;
00192
00193 return true;
00194 }
00195
00196 bool IVector3::contain(const IVector3& v) const
00197 {
00198 if(v[0][0] < i_[0][0]) return false;
00199 if(v[1][0] < i_[1][0]) return false;
00200 if(v[2][0] < i_[2][0]) return false;
00201
00202 if(v[0][1] > i_[0][1]) return false;
00203 if(v[1][1] > i_[1][1]) return false;
00204 if(v[2][1] > i_[2][1]) return false;
00205
00206 return true;
00207 }
00208
00209
00210
00211 }