24 #ifndef BASE_VECTOR3D_H 25 #define BASE_VECTOR3D_H 32 # define F_PI 3.1415926f 36 # define D_PI 3.141592653589793 40 # define FLOAT_MAX 3.402823466E+38F 44 # define FLOAT_MIN 1.175494351E-38F 48 # define DOUBLE_MAX 1.7976931348623157E+308 52 # define DOUBLE_MIN 2.2250738585072014E-308 77 template <
class _Precision>
93 explicit Vector3 (_Precision fx = 0.0, _Precision fy = 0.0, _Precision fz = 0.0);
102 const _Precision &
operator [] (
unsigned short usIndex)
const;
141 void ScaleX (_Precision f);
142 void ScaleY (_Precision f);
143 void ScaleZ (_Precision f);
144 void Scale (_Precision fX, _Precision fY, _Precision fZ);
145 void MoveX (_Precision f);
146 void MoveY (_Precision f);
147 void MoveZ (_Precision f);
148 void Move (_Precision fX, _Precision fY, _Precision fZ);
154 void Set (_Precision fX, _Precision fY, _Precision fZ);
158 _Precision
Length (
void)
const;
161 _Precision
Sqr (
void)
const;
219 template <
class _Precision>
222 _Precision x=v1.
x-v2.
x, y=v1.
y-v2.
y, z=v1.
z-v2.
z;
223 return static_cast<_Precision>(sqrt((x * x) + (y * y) + (z * z)));
227 template <
class _Precision>
230 _Precision x=v1.
x-v2.
x, y=v1.
y-v2.
y, z=v1.
z-v2.
z;
231 return x * x + y * y + z * z;
235 template <
class _Precision>
241 template <
class _Pr1,
class _Pr2>
244 return Vector3<_Pr1>(static_cast<_Pr1>(v.
x),static_cast<_Pr1>(v.
y),static_cast<_Pr1>(v.
z));
252 #endif // BASE_VECTOR3D_H _Precision z
Definition: Vector3D.h:89
_Precision DistanceToPlane(const Vector3 &rclBase, const Vector3 &rclNorm) const
Vector3 operator &(const Vector3< _Precision > &rcVct) const
static float_type maximum()
Definition: Vector3D.h:73
Vector3 & operator+=(const Vector3< _Precision > &rcVct)
Vector summation.
#define F_PI
Definition: Vector3D.h:32
_Precision y
Definition: Vector3D.h:88
Vector3 & operator -=(const Vector3< _Precision > &rcVct)
Vector subtraction.
void Scale(_Precision fX, _Precision fY, _Precision fZ)
Vector3 operator *(_Precision fScale) const
Vector scaling.
void TransformToCoordinateSystem(const Vector3 &rclBase, const Vector3 &rclDirX, const Vector3 &rclDirY)
_Precision num_type
Definition: Vector3D.h:81
_Precision Dot(const Vector3< _Precision > &rcVct) const
Scalar product.
_Precision DistanceP2(const Vector3< _Precision > &v1, const Vector3< _Precision > &v2)
Returns the squared distance between two points.
Definition: Vector3D.h:228
float_traits< num_type > traits_type
Definition: Vector3D.h:82
bool IsEqual(const Vector3 &rclPnt, _Precision tol) const
IsEqual.
Vector3< _Pr1 > toVector(const Vector3< _Pr2 > &v)
Definition: Vector3D.h:242
static num_type epsilon()
Definition: Vector3D.h:83
Vector3< double > Vector3d
Definition: Vector3D.h:248
_Precision x
Definition: Vector3D.h:87
_Precision DistanceToLine(const Vector3 &rclBase, const Vector3 &rclDirect) const
Computes the distance from this point to the line given by rclBase and rclDirect.
Vector3 operator -(void) const
Negative vector.
Vector3 & operator/=(_Precision fDiv)
void RotateX(_Precision f)
Vector3 & ProjectToPlane(const Vector3 &rclBase, const Vector3 &rclNorm)
Projects this point onto the plane given by the base rclBase and the normal rclNorm.
bool IsOnLineSegment(const Vector3< _Precision > &startVct, const Vector3< _Precision > &endVct) const
Check if Vector is on a line segment.
Vector3 operator %(const Vector3< _Precision > &rcVct) const
Cross product.
_Precision Sqr(void) const
Squared length of the vector.
static float_type maximum()
Definition: Vector3D.h:65
static float_type epsilon()
Definition: Vector3D.h:64
double float_type
Definition: Vector3D.h:70
Vector3< float > Vector3f
Definition: Vector3D.h:247
Vector3 Perpendicular(const Vector3 &rclBase, const Vector3 &rclDir) const
void ScaleZ(_Precision f)
static float_type pi()
Definition: Vector3D.h:63
_Precision Distance(const Vector3< _Precision > &v1, const Vector3< _Precision > &v2)
Returns the distance between two points.
Definition: Vector3D.h:220
_Precision GetAngle(const Vector3 &rcVect) const
Get angle between both vectors. The returned value lies in the interval [0,pi].
bool operator==(const Vector3< _Precision > &rcVct) const
Comparing for equality.
Vector3 Cross(const Vector3< _Precision > &rcVct) const
Cross product.
void RotateZ(_Precision f)
Vector3 DistanceToLineSegment(const Vector3 &rclP1, const Vector3 &rclP2) const
float float_type
Definition: Vector3D.h:62
Vector3(_Precision fx=0.0, _Precision fy=0.0, _Precision fz=0.0)
Construction.
_Precision & operator [](unsigned short usIndex)
Returns a reference to a coordinate. usIndex must be in the range [0,2].
Vector3 & ProjectToLine(const Vector3 &rclPoint, const Vector3 &rclLine)
Projects this point onto the line given by the base rclPoint and the direction rclLine.
Vector3 operator/(_Precision fDiv) const
Vector3 & Normalize(void)
Set length to 1.
Vector3 & operator=(const Vector3< _Precision > &rcVct)
Assignment.
void Move(_Precision fX, _Precision fY, _Precision fZ)
static float_type pi()
Definition: Vector3D.h:71
bool operator !=(const Vector3< _Precision > &rcVct) const
Comparing for inequality.
void RotateY(_Precision f)
Vector3 & operator *=(_Precision fScale)
Definition: AbstractXMLReader.h:5
Definition: Vector3D.h:78
Vector3 operator+(const Vector3< _Precision > &rcVct) const
Vector addition.
void Set(_Precision fX, _Precision fY, _Precision fZ)
static float_type epsilon()
Definition: Vector3D.h:72
#define D_PI
Definition: Vector3D.h:36
_Precision Length(void) const
Length of the vector.
Definition: Vector3D.h:58
void ScaleY(_Precision f)
DualNumber operator *(DualNumber a, DualNumber b)
Definition: DualNumber.h:71
void ScaleX(_Precision f)