113 return (sqrt(m_x * m_x + m_y * m_y));
121 return (
Vec2(m_x, m_y) / length());
129 double vector_length(length());
130 m_x /= vector_length;
131 m_y /= vector_length;
139 return (normalize());
147 return (m_x * aVector.m_x + m_y * aVector.m_y);
156 pow(m_x - aVector.m_x, 2.0) +
157 pow(m_y - aVector.m_y, 2.0))
167 return (
Vec2(m_x + aValue.m_x, m_y + aValue.m_y));
186 return (
Vec2(m_x - aValue.m_x, m_y - aValue.m_y));
205 return (
Vec2(m_x * aValue, m_y * aValue));
224 return (
Vec2(m_x * aValue, m_y * aValue));
243 return (
Vec2(m_x / aValue, m_y / aValue));
262 return (
Vec2(m_x / aValue, m_y / aValue));
281 return (
Vec2(-m_x, -m_y));
362 template <
typename T> std::ostream&
operator<<(std::ostream& anOutputStream,
366 anOutputStream << aVector.
getX() <<
", " << aVector.
getY();
367 return (anOutputStream);
Vec2 is a template class to handle a 2D vector.
T m_x
the position along the x-axis
Image< T > operator+(const T &aValue, const Image< T > &anImage)
Image< T > operator/(const T &aValue, const Image< T > &anImage)
T getX() const
Accessor on the position along the x-axis.
T m_y
the position along the y-axi
std::ostream & operator<<(std::ostream &anOutputSream, const gVirtualXRay::AtomicElement &anElement)
operator <<
Image< T > operator-(const T &aValue, const Image< T > &anImage)
Vec2(const T &aX=0.0f, const T &aY=0.0f)
Default Constructor.
T getY() const
Accessor on the position along the y-axis.
Image< T > operator*(const T &aValue, const Image< T > &anImage)