Skip to content

Commit

Permalink
Modify the CCVector code syntax + remove warning
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardeau committed Jun 28, 2024
1 parent 858826c commit d970f71
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions include/CCGeom.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ template <typename Type> class Vector2Tpl

//! Returns vector square norm
inline Type norm2() const { return (x*x) + (y*y); }
//! Returns vector square norm (forces double precision output)
inline double norm2d() const { return (static_cast<double>(x)*x) + (static_cast<double>(y)*y); }
//! Returns vector norm
inline Type norm() const { return std::sqrt(norm2()); }
inline Type norm() const { return static_cast<Type>(normd()); }
//! Returns vector norm (forces double precision output)
inline double normd() const { return std::sqrt(norm2d()); }
//! Sets vector norm to unity
inline void normalize() { Type n = norm2(); if (n > 0) *this /= std::sqrt(n); }
inline void normalize() { double n = normd(); if (n >= std::numeric_limits<double>::epsilon()) *this /= static_cast<Type>(n); }

//! Dot product
inline Type dot(const Vector2Tpl& v) const { return (x*v.x) + (y*v.y); }
Expand Down Expand Up @@ -188,16 +192,16 @@ template <typename Type> class Vector3Tpl : public Tuple3Tpl<Type>
inline Type dot(const Vector3Tpl& v) const { return x*v.x + y*v.y + z*v.z; }
//! Cross product
inline Vector3Tpl cross(const Vector3Tpl &v) const { return Vector3Tpl((y*v.z) - (z*v.y), (z*v.x) - (x*v.z), (x*v.y) - (y*v.x)); }
//! Returns vector square norm
inline Type norm2() const { return x*x + y*y + z*z; }
//! Returns vector square norm (forces double precision output)
inline double norm2d() const { return static_cast<double>(x)*x + static_cast<double>(y)*y + static_cast<double>(z)*z; }
//! Returns vector squared norm
inline Type norm2() const { return (x*x) + (y*y) + (z*z); }
//! Returns vector squared norm (forces double precision output)
inline double norm2d() const { return (static_cast<double>(x)*x) + (static_cast<double>(y)*y) + (static_cast<double>(z)*z); }
//! Returns vector norm
inline Type norm() const { return static_cast<Type>(std::sqrt(norm2d())); }
inline Type norm() const { return static_cast<Type>(normd()); }
//! Returns vector norm (forces double precision output)
inline double normd() const { return std::sqrt(norm2d()); }
//! Sets vector norm to unity
inline void normalize() { Type n = norm(); if (n > std::numeric_limits<Type>::epsilon()) *this /= n; }
inline void normalize() { double n = normd(); if (n >= std::numeric_limits<double>::epsilon()) *this /= static_cast<Type>(n); }
//! Returns a normalized vector which is orthogonal to this one
inline Vector3Tpl orthogonal() const { Vector3Tpl ort; vorthogonal(u, ort.u); return ort; }

Expand Down

0 comments on commit d970f71

Please sign in to comment.