70 #ifndef __OutOfBoundsException_h 82 template<
typename T>
Vec3<T>::Vec3(
const T& aX,
const T& aY,
const T& aZ):
84 m_x(aX), m_y(aY), m_z(aZ)
142 return (sqrt(m_x * m_x + m_y * m_y + m_z * m_z));
150 return (
Vec3(m_x, m_y, m_z) / length());
158 double vector_length(length());
159 m_x /= vector_length;
160 m_y /= vector_length;
161 m_z /= vector_length;
169 return (normalize());
177 return (m_x * aVector.m_x + m_y * aVector.m_y + m_z * aVector.m_z);
185 return (
Vec3( m_y * aVector.m_z - m_z * aVector.m_y,
186 -(m_x * aVector.m_z - m_z * aVector.m_x),
187 m_x * aVector.m_y - m_y * aVector.m_x));
204 return (
Vec3(m_x * aVector.m_x, m_y * aVector.m_y, m_z * aVector.m_z));
213 pow(m_x - aVector.m_x, 2.0) +
214 pow(m_y - aVector.m_y, 2.0) +
215 pow(m_z - aVector.m_z, 2.0)
225 return (
Vec3(m_x + aValue.m_x, m_y + aValue.m_y, m_z + aValue.m_z));
245 return (
Vec3(m_x - aValue.m_x, m_y - aValue.m_y, m_z - aValue.m_z));
265 return (
Vec3(m_x * aValue, m_y * aValue, m_z * aValue));
285 return (
Vec3(m_x * aValue, m_y * aValue, m_z * aValue));
305 return (
Vec3(m_x / aValue, m_y / aValue, m_z / aValue));
325 return (
Vec3(m_x / aValue, m_y / aValue, m_z / aValue));
345 return (crossProduct(aValue));
353 return (
Vec3(-m_x, -m_y, -m_z));
362 std::abs(m_x - aVector.m_x) < 0.0000001 &&
363 std::abs(m_y - aVector.m_y) < 0.0000001 &&
364 std::abs(m_z - aVector.m_z) < 0.0000001);
366 return (return_value);
375 std::abs(m_x - aVector.m_x) >= 0.0000001 ||
376 std::abs(m_y - aVector.m_y) >= 0.0000001 ||
377 std::abs(m_z - aVector.m_z) >= 0.0000001);
379 return (return_value);
485 template<
typename T> std::ostream&
operator<<(std::ostream& anOutputStream,
489 anOutputStream << aVector.
getX() <<
", " << aVector.
getY() <<
", " << aVector.
getZ();
490 return (anOutputStream);
T m_z
the position along the z-axi
Image< T > operator+(const T &aValue, const Image< T > &anImage)
T m_x
the position along the x-axis
Vec3 is a template class to handle a 3D vector.
T getX() const
Accessor on the position along the x-axis.
T getZ() const
Accessor on the position along the z-axis.
Image< T > operator/(const T &aValue, const Image< T > &anImage)
T m_y
the position along the y-axi
T getY() const
Accessor on the position along the y-axis.
std::ostream & operator<<(std::ostream &anOutputSream, const gVirtualXRay::AtomicElement &anElement)
operator <<
Image< T > operator-(const T &aValue, const Image< T > &anImage)
Image< T > abs(const Image< T > &anImage)
Class to handle exceptions when accessing an array cell that is not accessible, i.e. out of bounds memory access.
Image< T > operator*(const T &aValue, const Image< T > &anImage)
Vec3(const T &aX=0, const T &aY=0, const T &aZ=0)
Default Constructor.