9 #ifndef MsiChart_Vector3D_h 10 #define MsiChart_Vector3D_h 13 #include "PDCHeader/PDCcmath" 20 template <
class T =
float>
30 Vector3D(
double iX = T(),
double iY = T(),
double iZ = T()) :
x(static_cast<T>(iX)),
y(static_cast<T>(iY)),
z(static_cast<T>(iZ)){}
44 :
x(static_cast<T>(irEnd.
x - irStart.
x)),
45 y(static_cast<T>(irEnd.
y - irStart.
y)),
46 z(static_cast<T>(irEnd.
z - irStart.
z)){}
134 return x * x + y * y + z * z;
141 return (x * irVector.
x + y * irVector.
y + z * irVector.
z);
148 return InnerProduct(irVector) / (std::sqrt(LengthSquared() * irVector.
LengthSquared()));
155 orCrossProduct.
x = y * irVector.
z - z * irVector.
y;
156 orCrossProduct.
y = z * irVector.
x - x * irVector.
z;
157 orCrossProduct.
z = x * irVector.
y - y * irVector.
x;
164 return Vector3D<T>(y * irVector.
z - z * irVector.
y, z * irVector.
x - x * irVector.
z, x * irVector.
y - y * irVector.
x);
170 double lTemp = InnerProduct(irVector) / (std::sqrt(LengthSquared() * irVector.
LengthSquared()));
171 lTemp = (lTemp > 1.0f) ? 1.0f : lTemp;
172 lTemp = (lTemp < -1.0f) ? -1.0f : lTemp;
173 return std::acos(lTemp);
179 return std::sqrt(LengthSquared());
185 double lLength = Length();
194 std::swap(x, iorVector.
x);
195 std::swap(y, iorVector.
y);
196 std::swap(z, iorVector.
z);
207 return Vector3D<T>(x - irVector.
x, y - irVector.
y, z - irVector.
z);
212 return Vector3D<T>(x + irVector.
x, y + irVector.
y, z + irVector.
z);
217 return Vector3D<T>(iFactor * x, iFactor * y, iFactor * z);
Vector3D< T > MultiplyBy(double iFactor) const
Definition: Vector3D.h:215
T z
Z component of current vector.
Definition: Vector3D.h:127
void Swap(Vector3D< T > &iorVector)
Definition: Vector3D.h:192
Vector3D(double iX=T(), double iY=T(), double iZ=T())
Definition: Vector3D.h:30
void Normalize()
Normalize the current vector.
Definition: Vector3D.h:183
Vector3D< float > FVector3D
Definition: Vector3D.h:220
double Length() const
Definition: Vector3D.h:177
T x
X component of current vector.
Definition: Vector3D.h:125
Definition: Vector3D.h:21
double IncludedAngle(const Vector3D< T > &irVector) const
Definition: Vector3D.h:168
double LengthSquared() const
Definition: Vector3D.h:132
Vector3D(const Point3D< T > &irPoint)
Definition: Vector3D.h:35
T y
Y component of current vector.
Definition: Vector3D.h:126
double InnerProduct(const Vector3D< T > &irVector) const
Definition: Vector3D.h:139
Vector3D< double > DVector3D
Definition: Vector3D.h:221
double NormalizedInnerProduct(const Vector3D< T > &irVector) const
Definition: Vector3D.h:146
Vector3D< T > operator+(const Vector3D< T > &irVector) const
Definition: Vector3D.h:210
Vector3D(const Point3D< U > &irStart, const Point3D< U > &irEnd)
Definition: Vector3D.h:43
Vector3D< T > operator-() const
Definition: Vector3D.h:200
void CrossProduct(const Vector3D< T > &irVector, Vector3D< T > &orCrossProduct) const
Definition: Vector3D.h:153