|
@@ -308,6 +308,7 @@ inline float Vec3::dot(const Vec3& b) const
|
|
|
return x() * b.x() + y() * b.y() + z() * b.z();
|
|
return x() * b.x() + y() * b.y() + z() * b.z();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// cross prod
|
|
// cross prod
|
|
|
inline Vec3 Vec3::cross(const Vec3& b) const
|
|
inline Vec3 Vec3::cross(const Vec3& b) const
|
|
|
{
|
|
{
|
|
@@ -316,42 +317,49 @@ inline Vec3 Vec3::cross(const Vec3& b) const
|
|
|
x() * b.y() - y() * b.x());
|
|
x() * b.y() - y() * b.x());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// getLength
|
|
// getLength
|
|
|
inline float Vec3::getLength() const
|
|
inline float Vec3::getLength() const
|
|
|
{
|
|
{
|
|
|
return Math::sqrt(getLengthSquared());
|
|
return Math::sqrt(getLengthSquared());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// getLengthSquared
|
|
// getLengthSquared
|
|
|
inline float Vec3::getLengthSquared() const
|
|
inline float Vec3::getLengthSquared() const
|
|
|
{
|
|
{
|
|
|
return x() * x() + y() * y() + z() * z();
|
|
return x() * x() + y() * y() + z() * z();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// getDistanceSquared
|
|
// getDistanceSquared
|
|
|
inline float Vec3::getDistanceSquared(const Vec3& b) const
|
|
inline float Vec3::getDistanceSquared(const Vec3& b) const
|
|
|
{
|
|
{
|
|
|
return ((*this) - b).getLengthSquared();
|
|
return ((*this) - b).getLengthSquared();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// normalize
|
|
// normalize
|
|
|
inline void Vec3::normalize()
|
|
inline void Vec3::normalize()
|
|
|
{
|
|
{
|
|
|
(*this) /= getLength();
|
|
(*this) /= getLength();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// getNormalized
|
|
// getNormalized
|
|
|
inline Vec3 Vec3::getNormalized() const
|
|
inline Vec3 Vec3::getNormalized() const
|
|
|
{
|
|
{
|
|
|
return (*this) / getLength();
|
|
return (*this) / getLength();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// getProjection
|
|
// getProjection
|
|
|
inline Vec3 Vec3::getProjection(const Vec3& toThis) const
|
|
inline Vec3 Vec3::getProjection(const Vec3& toThis) const
|
|
|
{
|
|
{
|
|
|
return toThis * ((*this).dot(toThis) / (toThis.dot(toThis)));
|
|
return toThis * ((*this).dot(toThis) / (toThis.dot(toThis)));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// getRotated
|
|
// getRotated
|
|
|
inline Vec3 Vec3::getRotated(const Quat& q) const
|
|
inline Vec3 Vec3::getRotated(const Quat& q) const
|
|
|
{
|
|
{
|
|
@@ -368,12 +376,14 @@ inline Vec3 Vec3::getRotated(const Quat& q) const
|
|
|
return (*this) + qXyz.cross(qXyz.cross((*this)) + (*this) * q.w()) * 2.0;
|
|
return (*this) + qXyz.cross(qXyz.cross((*this)) + (*this) * q.w()) * 2.0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// rotate
|
|
// rotate
|
|
|
inline void Vec3::rotate(const Quat& q)
|
|
inline void Vec3::rotate(const Quat& q)
|
|
|
{
|
|
{
|
|
|
(*this) = getRotated(q);
|
|
(*this) = getRotated(q);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// lerp
|
|
// lerp
|
|
|
inline Vec3 Vec3::lerp(const Vec3& v1, float t) const
|
|
inline Vec3 Vec3::lerp(const Vec3& v1, float t) const
|
|
|
{
|
|
{
|
|
@@ -392,6 +402,7 @@ inline Vec3 Vec3::getTransformed(const Vec3& translate, const Mat3& rotate,
|
|
|
return (rotate * ((*this) * scale)) + translate;
|
|
return (rotate * ((*this) * scale)) + translate;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// Mat3
|
|
// Mat3
|
|
|
inline void Vec3::transform(const Vec3& translate, const Mat3& rotate,
|
|
inline void Vec3::transform(const Vec3& translate, const Mat3& rotate,
|
|
|
float scale)
|
|
float scale)
|
|
@@ -399,6 +410,7 @@ inline void Vec3::transform(const Vec3& translate, const Mat3& rotate,
|
|
|
(*this) = getTransformed(translate, rotate, scale);
|
|
(*this) = getTransformed(translate, rotate, scale);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// Mat3 no scale
|
|
// Mat3 no scale
|
|
|
inline Vec3 Vec3::getTransformed(const Vec3& translate,
|
|
inline Vec3 Vec3::getTransformed(const Vec3& translate,
|
|
|
const Mat3& rotate) const
|
|
const Mat3& rotate) const
|
|
@@ -406,12 +418,14 @@ inline Vec3 Vec3::getTransformed(const Vec3& translate,
|
|
|
return (rotate * (*this)) + translate;
|
|
return (rotate * (*this)) + translate;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// Mat3 no scale
|
|
// Mat3 no scale
|
|
|
inline void Vec3::transform(const Vec3& translate, const Mat3& rotate)
|
|
inline void Vec3::transform(const Vec3& translate, const Mat3& rotate)
|
|
|
{
|
|
{
|
|
|
(*this) = getTransformed(translate, rotate);
|
|
(*this) = getTransformed(translate, rotate);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// Quat
|
|
// Quat
|
|
|
inline Vec3 Vec3::getTransformed(const Vec3& translate, const Quat& rotate,
|
|
inline Vec3 Vec3::getTransformed(const Vec3& translate, const Quat& rotate,
|
|
|
float scale) const
|
|
float scale) const
|
|
@@ -419,6 +433,7 @@ inline Vec3 Vec3::getTransformed(const Vec3& translate, const Quat& rotate,
|
|
|
return ((*this) * scale).getRotated(rotate) + translate;
|
|
return ((*this) * scale).getRotated(rotate) + translate;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// Quat
|
|
// Quat
|
|
|
inline void Vec3::transform(const Vec3& translate, const Quat& rotate,
|
|
inline void Vec3::transform(const Vec3& translate, const Quat& rotate,
|
|
|
float scale)
|
|
float scale)
|
|
@@ -426,6 +441,7 @@ inline void Vec3::transform(const Vec3& translate, const Quat& rotate,
|
|
|
(*this) = getTransformed(translate, rotate, scale);
|
|
(*this) = getTransformed(translate, rotate, scale);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// Mat4
|
|
// Mat4
|
|
|
inline Vec3 Vec3::getTransformed(const Mat4& transform) const
|
|
inline Vec3 Vec3::getTransformed(const Mat4& transform) const
|
|
|
{
|
|
{
|
|
@@ -448,12 +464,14 @@ inline Vec3 Vec3::getTransformed(const Mat4& transform) const
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// Mat4
|
|
// Mat4
|
|
|
inline void Vec3::transform(const Mat4& transform)
|
|
inline void Vec3::transform(const Mat4& transform)
|
|
|
{
|
|
{
|
|
|
(*this) = getTransformed(transform);
|
|
(*this) = getTransformed(transform);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// Transform
|
|
// Transform
|
|
|
inline Vec3 Vec3::getTransformed(const Transform& transform) const
|
|
inline Vec3 Vec3::getTransformed(const Transform& transform) const
|
|
|
{
|
|
{
|
|
@@ -461,6 +479,7 @@ inline Vec3 Vec3::getTransformed(const Transform& transform) const
|
|
|
transform.getOrigin();
|
|
transform.getOrigin();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// Transform
|
|
// Transform
|
|
|
inline void Vec3::transform(const Transform& transform)
|
|
inline void Vec3::transform(const Transform& transform)
|
|
|
{
|
|
{
|