diff options
Diffstat (limited to 'WebCore/platform/graphics/FloatPoint3D.h')
-rw-r--r-- | WebCore/platform/graphics/FloatPoint3D.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/WebCore/platform/graphics/FloatPoint3D.h b/WebCore/platform/graphics/FloatPoint3D.h index b6cbaa8..ba0ee9d 100644 --- a/WebCore/platform/graphics/FloatPoint3D.h +++ b/WebCore/platform/graphics/FloatPoint3D.h @@ -84,6 +84,11 @@ public: m_z *= sz; } + bool isZero() const + { + return !m_x && !m_y && !m_z; + } + void normalize(); float dot(const FloatPoint3D& a) const @@ -115,6 +120,8 @@ public: float lengthSquared() const { return this->dot(*this); } float length() const { return sqrtf(lengthSquared()); } + + float distanceTo(const FloatPoint3D& a) const; private: float m_x; @@ -160,6 +167,21 @@ inline float operator*(const FloatPoint3D& a, const FloatPoint3D& b) return a.dot(b); } +inline FloatPoint3D operator*(float k, const FloatPoint3D& v) +{ + return FloatPoint3D(k * v.x(), k * v.y(), k * v.z()); +} + +inline FloatPoint3D operator*(const FloatPoint3D& v, float k) +{ + return FloatPoint3D(k * v.x(), k * v.y(), k * v.z()); +} + +inline float FloatPoint3D::distanceTo(const FloatPoint3D& a) const +{ + return (*this - a).length(); +} + } // namespace WebCore #endif // FloatPoint3D_h |