5 #ifndef BALL_MATHS_VECTOR3_H
6 #define BALL_MATHS_VECTOR3_H
8 #ifndef BALL_COMMON_EXCEPTION_H
12 #ifndef BALL_CONCEPT_PERSISTENCEMANAGER_H
16 #ifndef BALL_MATHS_ANGLE_H
20 #ifndef BALL_MATHS_COMMON_H
24 #ifdef BALL_HAS_IEEEFP_H
63 std::ostream& operator << (std::ostream& s, const TVector3<T>& vector);
102 template<
typename T2>
111 TVector3(
const T& vx,
const T& vy,
const T& vz);
153 void set(
const T* ptr);
159 void set(
const T& value);
166 void set(
const T& vx,
const T& vy,
const T& vz);
212 void get(T* ptr)
const;
219 void get(T&
x, T&
y, T&
z)
const;
470 void dump(std::ostream& s = std::cout,
Size depth = 0)
const;
532 template <
typename T>
541 template <
typename T>
555 template <
typename T>
564 template <
typename T>
template <
typename T2>
573 template <
typename T>
582 template <
typename T>
591 template <
typename T>
594 : x(r * cos(phi) * sin(theta)),
595 y(r * sin(phi) * sin(theta)),
600 template <
typename T>
606 template <
typename T>
613 template <
typename T>
625 template <
typename T>
634 template <
typename T>
643 template <
typename T>
652 template <
typename T>
656 x = r * cos(phi) * sin(theta);
657 y = r * sin(phi) * sin(theta);
661 template <
typename T>
677 template <
typename T>
688 template <
typename T>
697 template <
typename T>
711 template <
typename T>
720 template <
typename T>
729 template <
typename T>
733 r = sqrt(x * x + y * y + z * z);
734 phi = (
Angle)getAngle_(x, y);
735 theta = getAngle_(z, sqrt(x * x + y * y));
738 template <
typename T>
755 template <
typename T>
759 return (T)sqrt(x * x + y * y + z * z);
762 template <
typename T>
766 return (x * x + y * y + z * z);
769 template <
typename T>
772 T len = sqrt(x * x + y * y + z * z);
786 template <
typename T>
796 template <
typename T>
804 template <
typename T>
812 template <
typename T>
830 template <
typename T>
848 template <
typename T>
855 template <
typename T>
862 template <
typename T>
873 template <
typename T>
884 template <
typename T>
888 return TVector3<T>(x * scalar, y * scalar, z * scalar);
891 template <
typename T>
902 template <
typename T>
909 return TVector3<T>(x / lambda, y / lambda, z / lambda);
912 template <
typename T>
926 template <
typename T>
930 return (x * vector.
x + y * vector.
y + z * vector.
z);
933 template <
typename T>
936 return TVector3(y * v.
z - z * v.
y, z * v.
x - x * v.
z, x * v.
y - y * v.
x);
939 template <
typename T>
943 set(y * v.
z - z * v.
y, z * v.
x - x * v.
z, x * v.
y - y * v.
x);
947 template <
typename T>
955 return (T)sqrt(dx * dx + dy * dy + dz * dz);
958 template <
typename T>
966 return (dx * dx + dy * dy + dz * dz);
969 template <
typename T>
975 if (length_product == (T)0)
980 T acos_arg = ((*this) * vector) / sqrt(length_product);
985 if (fabs(acos_arg) > 1.0)
993 template <
typename T>
997 return ((direction * (*
this)) / (direction * direction) * direction);
1000 template <
typename T>
1008 (diff1.
y * diff2.
z - diff1.
z * diff2.
y,
1009 diff1.
z * diff2.
x - diff1.
x * diff2.
z,
1010 diff1.
x * diff2.
y - diff1.
y * diff2.
x);
1013 template <
typename T>
1020 return ( a.
x * (b.
y * c.
z - b.
z * c.
y)
1021 + a.
y * (b.
z * c.
x - b.
x * c.
z)
1022 + a.
z * (b.
x * c.
y - b.
y * c.
x));
1025 template <
typename T>
1032 template <
typename T>
1036 return (x < v.
x || y < v.
y || z < v.
z);
1040 template <
typename T>
1047 template <
typename T>
1054 template <
typename T>
1061 template <
typename T>
1068 template <
typename T>
1076 s <<
" (x = " << x <<
", y = " << y <<
", z = " << z <<
")" << std::endl;
1086 template <
typename T>
1093 template <
typename T>
1097 return TVector3<T>(x - b.x, y - b.y, z - b.z);
1100 template <
typename T>
1108 template <
typename T>
1119 template <
typename T>
1123 return TVector3<T>(scalar * vector.
x, scalar * vector.
y, scalar * vector.
z);
1126 template <
typename T>
1130 s >> c >> v.
x >> v.
y >> v.
z >>
c;
1135 template <
typename T>
1136 std::ostream& operator << (std::ostream& s, const TVector3<T>& v)
1138 s <<
"(" << v.x <<
' ' << v.y <<
' ' << v.z <<
')';
1143 #ifdef BALL_COMPILER_MSVC
1145 #ifdef BALL_HAS_EXTERN_TEMPLATES
1146 extern template class BALL_EXPORT std::vector<Vector3>;
1152 #ifdef BALL_HAS_EXTERN_TEMPLATES
1153 extern template class BALL_EXPORT TVector3<float>;
1158 #endif // BALL_MATHS_VECTOR3_H