FreeCAD C++
Public Member Functions | List of all members
Base::Vector3< _Precision > Class Template Reference

#include <Base/Vector3D.h>

Detailed Description

template<class _Precision>
class Base::Vector3< _Precision >

The Vector Base class.

Public Member Functions

 Vector3 (_Precision fx=0.0f, _Precision fy=0.0f, _Precision fz=0.0f)
 Construction.
 
 Vector3 (const Vector3< _Precision > &rcVct)
 Construction.
 
Operator
_Precision & operator [] (unsigned short usIndex)
 Returns a reference to a coordinate. usIndex must be in the range [0,2].
 
const _Precision & operator [] (unsigned short usIndex) const
 Returns a const reference to a coordinate. usIndex must be in the range [0,2].
 
Vector3 operator+ (const Vector3< _Precision > &rcVct) const
 Vector addition.
 
Vector3 operator & (const Vector3< _Precision > &rcVct) const
 
Vector3 operator - (const Vector3< _Precision > &rcVct) const
 Vector subtraction.
 
Vector3 operator - (void) const
 Negative vector.
 
Vector3operator+= (const Vector3< _Precision > &rcVct)
 Vector summation.
 
Vector3operator -= (const Vector3< _Precision > &rcVct)
 Vector subtraction.
 
Vector3 operator * (_Precision fScale) const
 Vector scaling.
 
Vector3 operator/ (_Precision fDiv) const
 
Vector3operator *= (_Precision fScale)
 
Vector3operator/= (_Precision fDiv)
 
Vector3operator= (const Vector3< _Precision > &rcVct)
 Assignment.
 
_Precision operator * (const Vector3< _Precision > &rcVct) const
 Scalar product.
 
_Precision Dot (const Vector3< _Precision > &rcVct) const
 Scalar product.
 
Vector3 operator % (const Vector3< _Precision > &rcVct) const
 Cross product.
 
Vector3 Cross (const Vector3< _Precision > &rcVct) const
 Cross product.
 
bool operator != (const Vector3< _Precision > &rcVct) const
 Comparing for inequality.
 
bool operator== (const Vector3< _Precision > &rcVct) const
 Comparing for equality.
 
Modification
void ScaleX (_Precision f)
 
void ScaleY (_Precision f)
 
void ScaleZ (_Precision f)
 
void Scale (_Precision fX, _Precision fY, _Precision fZ)
 
void MoveX (_Precision f)
 
void MoveY (_Precision f)
 
void MoveZ (_Precision f)
 
void Move (_Precision fX, _Precision fY, _Precision fZ)
 
void RotateX (_Precision f)
 
void RotateY (_Precision f)
 
void RotateZ (_Precision f)
 
Mathematics
_Precision Length (void) const
 Length of the vector.
 
_Precision Sqr (void) const
 Squared length of the vector.
 
Vector3Normalize (void)
 Set length to 1.
 
_Precision GetAngle (const Vector3 &rcVect) const
 Get angle between both vectors. The returned value lies in the interval [0,pi].
 
void TransformToCoordinateSystem (const Vector3 &rclBase, const Vector3 &rclDirX, const Vector3 &rclDirY)
 
bool IsEqual (const Vector3 &rclPnt, _Precision tol) const
 IsEqual. More...
 
Vector3ProjectToPlane (const Vector3 &rclBase, const Vector3 &rclNorm)
 Projects this point onto the plane given by the base rclBase and the normal rclNorm.
 
void ProjectToPlane (const Vector3 &rclBase, const Vector3 &rclNorm, Vector3 &rclProj) const
 
Vector3ProjectToLine (const Vector3 &rclPoint, const Vector3 &rclLine)
 Projects this point onto the line given by the base rclPoint and the direction rclLine. More...
 
Vector3 Perpendicular (const Vector3 &rclBase, const Vector3 &rclDir) const
 
_Precision DistanceToPlane (const Vector3 &rclBase, const Vector3 &rclNorm) const
 
_Precision DistanceToLine (const Vector3 &rclBase, const Vector3 &rclDirect) const
 Computes the distance from this point to the line given by rclBase and rclDirect.
 
Vector3 DistanceToLineSegment (const Vector3 &rclP1, const Vector3 &rclP2) const
 

Public Attributes

Public data members
_Precision x
 
_Precision y
 
_Precision z
 

Member Function Documentation

◆ DistanceToLineSegment()

template<class _Precision>
Vector3 Base::Vector3< _Precision >::DistanceToLineSegment ( const Vector3< _Precision > &  rclP1,
const Vector3< _Precision > &  rclP2 
) const

Computes the vector from this point to the point on the line segment with the shortest distance. The line segment is defined by rclP1 and rclP2. Note: If the projection of this point is outside the segment then the shortest distance to rclP1 or rclP2 is computed.

◆ DistanceToPlane()

template<class _Precision>
_Precision Base::Vector3< _Precision >::DistanceToPlane ( const Vector3< _Precision > &  rclBase,
const Vector3< _Precision > &  rclNorm 
) const

Computes the distance to the given plane. Depending on the side this point is located the distance can also be negative. The distance is positive if the point is at the same side the plane normal points to, negative otherwise.

◆ IsEqual()

template<class _Precision>
bool Base::Vector3< _Precision >::IsEqual ( const Vector3< _Precision > &  rclPnt,
_Precision  tol 
) const

IsEqual.

Parameters
rclPnt
tol
Returns
true or false If the distance to point rclPnt is within the tolerance tol both points are considered equal.

◆ Perpendicular()

template<class _Precision>
Vector3 Base::Vector3< _Precision >::Perpendicular ( const Vector3< _Precision > &  rclBase,
const Vector3< _Precision > &  rclDir 
) const

Get the perpendicular of this point to the line defined by rclBase and rclDir. Note: Do not mix up this method with ProjectToLine.

◆ ProjectToLine()

template<class _Precision>
Vector3& Base::Vector3< _Precision >::ProjectToLine ( const Vector3< _Precision > &  rclPoint,
const Vector3< _Precision > &  rclLine 
)

Projects this point onto the line given by the base rclPoint and the direction rclLine.

Projects a point rclPoint onto the line defined by the origin and the direction rclLine. The result is a vector from rclPoint to the point on the line. The length of this vector is the distance from rclPoint to the line. Note: The resulting vector does not depend on the current vector.

◆ ProjectToPlane()

template<class _Precision>
void Base::Vector3< _Precision >::ProjectToPlane ( const Vector3< _Precision > &  rclBase,
const Vector3< _Precision > &  rclNorm,
Vector3< _Precision > &  rclProj 
) const

Projects this point onto the plane given by the base rclBase and the normal rclNorm and stores the result in rclProj.

◆ TransformToCoordinateSystem()

template<class _Precision>
void Base::Vector3< _Precision >::TransformToCoordinateSystem ( const Vector3< _Precision > &  rclBase,
const Vector3< _Precision > &  rclDirX,
const Vector3< _Precision > &  rclDirY 
)

Transforms this point to the coordinate system defined by origin rclBase, vector vector rclDirX and vector vector rclDirY.

Note
rclDirX must be perpendicular to rclDirY, i.e. rclDirX * rclDirY = 0..

Member Data Documentation

◆ x

template<class _Precision>
_Precision Base::Vector3< _Precision >::x

x-coordinate

◆ y

template<class _Precision>
_Precision Base::Vector3< _Precision >::y

y-coordinate

◆ z

template<class _Precision>
_Precision Base::Vector3< _Precision >::z

z-coordinate