25 const int Vec3Impl::NUM_OF_COMPONENTS = 3;
41 :
mVec(v.x(), v.y(), v.z())
52 Vec3Impl::value_type Vec3Impl::Length()
const 59 Vec3Impl::value_type Vec3Impl::Length2()
const 65 Vec3Impl::value_type Vec3Impl::Normalize()
79 Vec3Impl::value_type& Vec3Impl::X()
85 Vec3Impl::value_type& Vec3Impl::Y()
91 Vec3Impl::value_type& Vec3Impl::Z()
97 Vec3Impl::value_type Vec3Impl::X()
const 103 Vec3Impl::value_type Vec3Impl::Y()
const 109 Vec3Impl::value_type Vec3Impl::Z()
const 115 Vec3Impl::value_type& Vec3Impl::R()
121 Vec3Impl::value_type& Vec3Impl::G()
127 Vec3Impl::value_type& Vec3Impl::B()
133 Vec3Impl::value_type Vec3Impl::R()
const 139 Vec3Impl::value_type Vec3Impl::G()
const 145 Vec3Impl::value_type Vec3Impl::B()
const 159 void Vec3Impl::Set(
const Vec3Impl& v)
161 mVec._v[0] = v[0];
mVec._v[1] = v[1];
mVec._v[2] = v[2];
173 mVec._v[0] = trUtil::Math::Lerp<value_type>(
mVec._v[0], to.X(), alpha);
174 mVec._v[1] = trUtil::Math::Lerp<value_type>(
mVec._v[1], to.Y(), alpha);
175 mVec._v[2] = trUtil::Math::Lerp<value_type>(
mVec._v[2], to.Z(), alpha);
181 return Vec3Impl(trUtil::Math::Lerp<value_type>(from.X(), to.X(), alpha), trUtil::Math::Lerp<value_type>(from.Y(), to.Y(), alpha), trUtil::Math::Lerp<value_type>(from.Z(), to.Z(), alpha));
187 return std::string(
"<" + trUtil::StringUtils::ToString<value_type>(
mVec._v[0], precision) +
", " + trUtil::StringUtils::ToString<value_type>(
mVec._v[1], precision) +
", " + trUtil::StringUtils::ToString<value_type>(
mVec._v[2], precision) +
">");
191 Vec3Impl::value_type* Vec3Impl::Ptr()
197 const Vec3Impl::value_type* Vec3Impl::Ptr()
const 203 Vec3Impl::value_type& Vec3Impl::operator [] (
int i)
209 Vec3Impl::value_type Vec3Impl::operator [] (
int i)
const 215 void Vec3Impl::operator = (
const Vec3Impl& v)
217 mVec._v[0] = v[0];
mVec._v[1] = v[1];
mVec._v[2] = v[2];
223 mVec._v[0] = v[0];
mVec._v[1] = v[1];
mVec._v[2] = v[2];
229 return mVec._v[0] == v[0] &&
mVec._v[1] == v[1] &&
mVec._v[2] == v[2];
235 return mVec._v[0] != v[0] ||
mVec._v[1] != v[1] ||
mVec._v[2] != v[2];
239 bool Vec3Impl::operator < (
const Vec3Impl& v)
const 241 if (
mVec._v[0]<v[0])
return true;
242 else if (
mVec._v[0]>v[0])
return false;
243 else if (
mVec._v[1]<v[1])
return true;
244 else if (
mVec._v[1]>v[1])
return false;
245 else return (
mVec._v[2]<v[2]);
249 bool Vec3Impl::operator > (
const Vec3Impl& v)
const 251 if (
mVec._v[0]>v[0])
return true;
252 else if (
mVec._v[0]<v[0])
return false;
253 else if (
mVec._v[1]>v[1])
return true;
254 else if (
mVec._v[1]<v[1])
return false;
255 else return (
mVec._v[2]>v[2]);
259 Vec3Impl::value_type Vec3Impl::operator * (
const Vec3Impl& rhs)
const 261 return mVec._v[0] * rhs[0] +
mVec._v[1] * rhs[1] +
mVec._v[2] * rhs[2];
265 const Vec3Impl Vec3Impl::operator * (Vec3Impl::value_type rhs)
const 271 Vec3Impl& Vec3Impl::operator *= (Vec3Impl::value_type rhs)
280 const Vec3Impl Vec3Impl::operator / (Vec3Impl::value_type rhs)
const 286 Vec3Impl& Vec3Impl::operator /= (Vec3Impl::value_type rhs)
303 mVec._v[0] += rhs[0];
304 mVec._v[1] += rhs[1];
305 mVec._v[2] += rhs[2];
318 mVec._v[0] -= rhs[0];
319 mVec._v[1] -= rhs[1];
320 mVec._v[2] -= rhs[2];
325 const Vec3Impl Vec3Impl::operator - ()
const 334 mVec._v[2] * rhs[0] -
mVec._v[0] * rhs[2],
335 mVec._v[0] * rhs[1] -
mVec._v[1] * rhs[0]);
365 ios <<
"<" << vec.X() <<
", " << vec.Y() <<
", " << vec.Z() <<
">";
372 return Vec3Impl(lhs[0] * rhs[0], lhs[1] * rhs[1], lhs[2] * rhs[2]);
378 return Vec3Impl(lhs[0] / rhs[0], lhs[1] / rhs[1], lhs[2] / rhs[2]);
std::string operator+(const std::string &s1, const RefStr &s2)
bool operator==(const std::string &s1, const RefStr &s2)
bool operator!=(const std::string &s1, const RefStr &s2)
TR_BASE_EXPORT std::ostream & operator<<(std::ostream &ios, const Matrixd &q)
Stream insertion operator.
std::string ToString(const T &t, int precision=-1)
A utility function to convert a basic type into a string.
TR_BASE_EXPORT Vec2b ComponentDivide(const Vec2b &lhs, const Vec2b &rhs)
Divide rhs components by rhs vector components.
TR_BASE_EXPORT Vec2b ComponentMultiply(const Vec2b &lhs, const Vec2b &rhs)
Multiply individual vector components.
int value_type
Data type of vector components.
T Lerp(T from, T to, T alpha)
Linear Interpolation function.