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;
502 TAngle<T> getAngle_(
const T& a,
const T& b)
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
TVector3 & operator/=(const T &lambda)
static T getTripleProduct(const TVector3< T > &a, const TVector3< T > &b, const TVector3< T > &c)
bool isEqual(const T1 &a, const T2 &b)
TVector3 & operator*=(const T &scalar)
T getSquareDistance(const TVector3 &vector) const
static TVector3 getPerpendicularNormalization(const TVector3 &a, const TVector3 &b, const TVector3 &c)
const TVector3 & operator+() const
std::istream & operator>>(std::istream &is, TRegularData1D< ValueType > &grid)
Input operator.
TVector3 operator-() const
bool isNotZero(const T &t)
static const TVector3 & getUnit()
void write(PersistenceManager &pm) const
bool readPrimitive(T &t, const char *name)
void dump(std::ostream &s=std::cout, Size depth=0) const
static const TVector3 & getZero()
void writePrimitive(const T &t, const char *name)
TVector3 & operator=(const TVector3 &v)
BALL_EXTERN_VARIABLE const double c
bool read(PersistenceManager &pm)
TVector3 & operator-=(const TVector3 &vector)
T getSquareLength() const
#define BALL_DUMP_HEADER(os, cl, ob)
bool operator==(const TVector3 &vector) const
TVector3< float > Vector3
TVector3 operator%(const TVector3 &vector) const
TVector3 & operator+=(const TVector3 &vector)
void swap(TVector3 &vector)
bool isNotEqual(const T1 &a, const T2 &b)
TVector3 operator/(const T &lambda) const
bool isLess(const T1 &a, const T2 &b)
TAngle< T > getAngle(const TVector3 &vector) const
T getDistance(const TVector3 &vector) const
BALL_INLINE TAngle< T > operator*(const T &val, const TAngle< T > &angle)
#define BALL_DUMP_STREAM_PREFIX(os)
BALL_EXTERN_VARIABLE const double PI
PI.
T & operator[](Position position)
bool operator<(const TVector3 &vector) const
Needed for MSVC.
TVector3 getOrthogonalProjection(const TVector3 &direction) const
#define BALL_DUMP_STREAM_SUFFIX(os)
#define BALL_DUMP_DEPTH(os, depth)
bool isOrthogonalTo(const TVector3 &vector) const
TVector3 & operator%=(const TVector3 &vector)
bool operator!=(const TVector3 &vector) const
TVector3 operator*(const T &scalar) const