CVector3 Class Reference
 
 
 
CVector3 Class Reference

#include <xsi_vector3.h>


Class Description

A 3-element vector that is represented by double precision floating point x,y,z coordinates.

In this API vectors are considered as row vectors as described in [Foley, J., and A. van Dam, Fundamentals of Interactive Computer Graphics, Addison-Wesley, Reading, MA, 1982]. This is important when you multiply a CVector3 by a CMatrix3 or a CMatrix4.

See also:
CMatrix3, CMatrix4, CTransformation
Example:
                using namespace XSI;
                using namespace MATH;
                Application app;
                Model root = app.GetActiveSceneRoot();

                X3DObject myCube;
                root.AddGeometry( L"Cube", L"MeshSurface",L"",myCube );

                KinematicState  globalKinematicState = myCube.GetKinematics().GetGlobal();
                globalKinematicState.PutParameterValue(L"posy", 4.0);
                globalKinematicState.PutParameterValue(L"posx", 2.0);

                X3DObject myCube2;
                myCube.AddGeometry( L"Cube", L"MeshSurface",L"",myCube2);

                globalKinematicState = myCube2.GetKinematics().GetGlobal();
                globalKinematicState.PutParameterValue(L"posz",3.0);
                globalKinematicState.PutParameterValue(L"rotx",45.0);

                CTransformation localTransformation =
                                                                myCube.GetKinematics().GetLocal().GetTransform();
                CTransformation globalTransformation = globalKinematicState.GetTransform();

                CVector3 translation(localTransformation.GetTranslation());

                app.LogMessage(L"The translation of the cube relative to its parent: x " +
                                                CValue(translation.GetX()).GetAsText() +
                                                L" y " +
                                                CValue(translation.GetY()).GetAsText() +
                                                L" z " +
                                                CValue(translation.GetZ()).GetAsText());

                MapObjectPoseToWorldSpace(      globalTransformation, localTransformation);

                translation = localTransformation.GetTranslation();

                app.LogMessage(L"The translation of the cube relative to the origin of the universe: x " +
                                          CValue(translation.GetX()).GetAsText() +
                                          L" y " + CValue(translation.GetY()).GetAsText() +
                                          L" z " + CValue(translation.GetZ()).GetAsText());

List of all members.

Public Member Functions

SICPPSDK_INLINE  CVector3 ()
SICPPSDK_INLINE  CVector3 (double in_dX, double in_dY, double in_dZ)
SICPPSDK_INLINE  CVector3 (const CVector3 &in_vector3)
SICPPSDK_INLINE  ~CVector3 ()
SICPPSDK_INLINE CVector3 operator= (const CVector3 &in_vector3)
SICPPSDK_INLINE bool  operator== (const CVector3 &in_vector3) const
SICPPSDK_INLINE bool  operator!= (const CVector3 &in_vector3) const
SICPPSDK_INLINE CVector3 operator~ ()
SICPPSDK_INLINE CVector3 operator+= (const CVector3 &in_vector3)
SICPPSDK_INLINE CVector3 operator-= (const CVector3 &in_vector3)
SICPPSDK_INLINE CVector3 operator*= (const CMatrix3 &in_matrix3)
SICPPSDK_INLINE CVector3 operator*= (const CMatrix4 &in_matrix4)
SICPPSDK_INLINE CVector3 operator*= (const CTransformation &in_transformation)
SICPPSDK_INLINE CVector3 operator*= (const double &in_dAlpha)
SICPPSDK_INLINE double  operator[] (const short &in_sIndex)
SICPPSDK_INLINE CVector3 MulByMatrix3InPlace (const CMatrix3 &in_matrix3)
SICPPSDK_INLINE CVector3 MulByMatrix3 (const CVector3 &in_vector3, const CMatrix3 &in_matrix3)
SICPPSDK_INLINE CVector3 MulByMatrix4InPlace (const CMatrix4 &in_matrix4)
SICPPSDK_INLINE CVector3 MulByMatrix4 (const CVector3 &in_vector3, const CMatrix4 &in_matrix4)
SICPPSDK_INLINE CVector3 MulByTransformationInPlace (const CTransformation &in_transformation)
CVector3 MulByTransformation (const CVector3 &in_vector3, const CTransformation &in_transformation)
SICPPSDK_INLINE CVector3 PutNull ()
SICPPSDK_INLINE short  GetMaxComponentIndex () const
SICPPSDK_INLINE double  GetMaxComponent () const
SICPPSDK_INLINE short  GetMinComponentIndex () const
SICPPSDK_INLINE double  GetMinComponent () const
SICPPSDK_INLINE double  GetLength () const
SICPPSDK_INLINE double  GetLengthSquared () const
CStatus  NormalizeInPlace ()
CStatus  Normalize (const CVector3 &in_vector3)
SICPPSDK_INLINE double  Dot (const CVector3 &in_vector3) const
SICPPSDK_INLINE CVector3 Cross (const CVector3 &in_vector3A, const CVector3 &in_vector3B)
double  GetAngle (const CVector3 &in_vector3) const
SICPPSDK_INLINE CVector3 LinearlyInterpolate (const CVector3 &in_vector3A, const CVector3 &in_vector3B, double in_dAlpha)
CVector3 AbsoluteInPlace ()
CVector3 Absolute (const CVector3 &in_vector3)
CVector3 ClampInPlace (double in_dMinValue, double in_dMaxValue)
SICPPSDK_INLINE CVector3 Clamp (double in_dMinValue, double in_dMaxValue, const CVector3 &in_vector3)
SICPPSDK_INLINE bool  EpsilonEquals (const CVector3 &in_vector3, double in_dEpsilon) const
SICPPSDK_INLINE bool  Equals (const CVector3 &in_vector3) const
SICPPSDK_INLINE CVector3 ScaleAddInPlace (double in_dS, const CVector3 &in_vector3)
SICPPSDK_INLINE CVector3 ScaleAdd (double in_dS, const CVector3 &in_vector3A, const CVector3 &in_vector3B)
SICPPSDK_INLINE CVector3 ScaleInPlace (double in_dAlpha)
SICPPSDK_INLINE CVector3 Scale (double in_dAlpha, const CVector3 &in_vector3)
SICPPSDK_INLINE CVector3 NegateInPlace ()
SICPPSDK_INLINE CVector3 Negate (const CVector3 &in_vector3)
SICPPSDK_INLINE CVector3 SubInPlace (const CVector3 &in_vector3)
SICPPSDK_INLINE CVector3 Sub (const CVector3 &in_vector3A, const CVector3 &in_vector3B)
SICPPSDK_INLINE CVector3 AddInPlace (const CVector3 &in_vector3)
SICPPSDK_INLINE CVector3 Add (const CVector3 &in_vector3A, const CVector3 &in_vector3B)
void  Get (double &io_dX, double &io_dY, double &io_dZ) const
SICPPSDK_INLINE CVector3 Set (double in_dX, double in_dY, double in_dZ)
SICPPSDK_INLINE double  GetZ () const
SICPPSDK_INLINE CVector3 PutZ (double in_dZ)
SICPPSDK_INLINE double  GetY () const
SICPPSDK_INLINE CVector3 PutY (double in_dY)
SICPPSDK_INLINE double  GetX () const
SICPPSDK_INLINE CVector3 PutX (double in_dX)

Constructor & Destructor Documentation

SICPPSDK_INLINE CVector3 ( )

Default constructor.

SICPPSDK_INLINE CVector3 ( double  in_dX,
double  in_dY,
double  in_dZ 
)

Constructor.

Parameters:
in_dX Value of the x component
in_dY Value of the y component
in_dZ Value of the z component
SICPPSDK_INLINE CVector3 ( const CVector3 in_vector3 )

Copy constructor.

Parameters:
in_vector3 constant class object.
SICPPSDK_INLINE ~CVector3 ( )

Default destructor.


Member Function Documentation

SICPPSDK_INLINE CVector3 & operator= ( const CVector3 in_vector3 )

Assignment operator.

Parameters:
in_vector3 constant class object.
Returns:
A reference to this vector.
SICPPSDK_INLINE bool operator== ( const CVector3 in_vector3 ) const

Equality operator tests the strict equality of this CVector3 with the specified vector3.

Parameters:
in_vector3 Operand vector.
Returns:
true if equal else false.
See also:
CVector3::Equals
SICPPSDK_INLINE bool operator!= ( const CVector3 in_vector3 ) const

Inequality operator tests the strict inequality of this CVector3 with the specified vector3.

Parameters:
in_vector3 Operand vector.
Returns:
true if equal else false.
See also:
CVector3::Equals
SICPPSDK_INLINE CVector3 & operator~ ( )

Negates this vector (this = - this).

Returns:
A reference to this vector.
See also:
CVector3::NegateInPlace
SICPPSDK_INLINE CVector3 & operator+= ( const CVector3 in_vector3 )

Adds the input vector to this one (this = this + in_vector3)

Parameters:
in_vector3 Operand vector..
Returns:
A reference to this vector.
See also:
CVector3::AddInPlace
SICPPSDK_INLINE CVector3 & operator-= ( const CVector3 in_vector3 )

Subtracts the input vector (in_vector3) from this one (this = this - in_vector3).

Parameters:
in_vector3 Operand vector.
Returns:
A reference to this vector.
See also:
CVector3::SubInPlace
SICPPSDK_INLINE CVector3 & operator*= ( const CMatrix3 in_matrix3 )

Right-multiplies this vector by the matrix m in place (this = this . m ).

Parameters:
in_matrix3 Operand matrix.
Returns:
A reference to this vector.
See also:
CVector3::MulByMatrix3InPlace
SICPPSDK_INLINE CVector3 & operator*= ( const CMatrix4 in_matrix4 )

Right-multiplies this vector by the matrix m in place (this = this . m ).

Parameters:
in_matrix4 Operand matrix.
Returns:
A reference to this vector.
See also:
CVector3::MulByMatrix4InPlace
SICPPSDK_INLINE CVector3 & operator*= ( const CTransformation in_transformation )

Right-multiplies this vector by the transformation t in place (this = this . t).

Parameters:
in_transformation transformation operand.
Returns:
A reference to this vector.
See also:
CVector3::MulByTransformationInPlace
SICPPSDK_INLINE CVector3 & operator*= ( const double &  in_dAlpha )

Scales this vector by the input scalar (alpha) (this = alpha * this).

Parameters:
in_dAlpha Scalar multiplicator.
Returns:
A reference to this vector.
See also:
CVector3::ScaleInPlace
SICPPSDK_INLINE double operator[] ( const short &  in_sIndex )

Read-only accessors to the X,Y,Z components.

Parameters:
in_sIndex 0,1,2 for X,Y and Z values.
Returns:
The value of the specified component. If the index supplied is out of range the function returns DBL_MAX.
See also:
CVector3::GetX(), CVector3::GetY(), CVector3::GetZ()
SICPPSDK_INLINE CVector3 & MulByMatrix3InPlace ( const CMatrix3 in_matrix3 )

Right-multiplies this vector by the matrix m in place (this = this . m ).

Parameters:
in_matrix3 Operand matrix.
Returns:
A reference to this vector.
SICPPSDK_INLINE CVector3 & MulByMatrix3 ( const CVector3 in_vector3,
const CMatrix3 in_matrix3 
)

Right-multiplies the vector v by the matrix m and store the result in this vector (this = v . m ).

Parameters:
in_vector3 Operand vector
in_matrix3 Operand matrix.
Returns:
A reference to this vector.
SICPPSDK_INLINE CVector3 & MulByMatrix4InPlace ( const CMatrix4 in_matrix4 )

Right-multiplies this vector by the matrix m in place (this = this . m ).

Parameters:
in_matrix4 Operand matrix.
Returns:
A reference to this vector.
SICPPSDK_INLINE CVector3 & MulByMatrix4 ( const CVector3 in_vector3,
const CMatrix4 in_matrix4 
)

Right-multiplies the vector v by the matrix m and store the result in this vector (this = v . m ).

Parameters:
in_vector3 Operand vector
in_matrix4 Operand matrix.
Returns:
A reference to this vector.
SICPPSDK_INLINE CVector3 & MulByTransformationInPlace ( const CTransformation in_transformation )

Right-multiplies this vector by the transformation t in place (this = this . t).

Parameters:
in_transformation transformation operand.
Returns:
A reference to this vector.
CVector3& MulByTransformation ( const CVector3 in_vector3,
const CTransformation in_transformation 
)

Right-multiplies the vector v by the transformation t and stores the result in this vector (this = v . t ).

Parameters:
in_vector3 transformation operand.
in_transformation transformation operand.
Returns:
A reference to this vector.
SICPPSDK_INLINE CVector3 & PutNull ( )

Sets this vector to a null vector.

Returns:
A reference to this vector.
SICPPSDK_INLINE short GetMaxComponentIndex ( ) const

Returns the index of the maximum component of this vector.

Returns:
Index of the maximum component of this vector.
SICPPSDK_INLINE double GetMaxComponent ( ) const

Returns the maximum component value of this vector.

Returns:
Maximum component value of this vector.
SICPPSDK_INLINE short GetMinComponentIndex ( ) const

Returns the index of the minimum component of this vector.

Returns:
Index of the minimum component of this vector.
SICPPSDK_INLINE double GetMinComponent ( ) const

Returns the minimum component value of this vector.

Returns:
Minimum component value of this vector.
SICPPSDK_INLINE double GetLength ( ) const

Returns the length of this vector.

Returns:
Length of this vector.
SICPPSDK_INLINE double GetLengthSquared ( ) const

Returns the squared length of this vector.

Returns:
Squared length of this vector.
CStatus NormalizeInPlace ( )

Normalizes this vector in place.

Returns:
CStatus::OK if the normalization has been computed,
CStatus Normalize ( const CVector3 in_vector3 )

Sets the value of this vector to the normalization of inputed vector.

Parameters:
in_vector3 vector operand.
Returns:
CStatus::OK if the normalization has been computed.
SICPPSDK_INLINE double Dot ( const CVector3 in_vector3 ) const

Returns the dot product of this vector and the inputed vector.

Parameters:
in_vector3 vector operand.
Returns:
Dot product of this vector and vector in_vector3.
SICPPSDK_INLINE CVector3 & Cross ( const CVector3 in_vector3A,
const CVector3 in_vector3B 
)

Sets this vector to the vector cross product of vectors A and B.

Parameters:
in_vector3A vector operand.
in_vector3B vector operand.
Returns:
A reference to this vector.
double GetAngle ( const CVector3 in_vector3 ) const

Returns the angle (in radians) between this vector and the inputed vector.

Parameters:
in_vector3 vector operand.
Returns:
Angle (in radians) between this vector and the inputed vector.
SICPPSDK_INLINE CVector3 & LinearlyInterpolate ( const CVector3 in_vector3A,
const CVector3 in_vector3B,
double  in_dAlpha 
)

Linearly interpolates between vectors A and B and places the result into this vector: this = (1-alpha)*A + alpha*B.

Parameters:
in_vector3A vector operand.
in_vector3B vector operand.
in_dAlpha Scalar interpolator
Possible Values: [0.0, 1.0] Domain of validity
Returns:
A reference to this vector.
CVector3& AbsoluteInPlace ( )

Sets each component of this vector3 to its absolute value.

Returns:
A reference to this vector.
CVector3& Absolute ( const CVector3 in_vector3 )

Sets each component of the specified MATH::CVector3 to its absolute value and places the modified values into this vector.

Parameters:
in_vector3 Vector to convert to absolute
Returns:
A reference to this vector.
CVector3& ClampInPlace ( double  in_dMinValue,
double  in_dMaxValue 
)

Clamps this vector3's components to the range [MinValue, MaxValue].

Parameters:
in_dMinValue Lower bound of the clamping domain.
in_dMaxValue Higher bound of the clamping domain.
Returns:
A reference to this vector.
SICPPSDK_INLINE CVector3& Clamp ( double  in_dMinValue,
double  in_dMaxValue,
const CVector3 in_vector3 
)

Clamps the specified vector3's components to the range [MinValue, MaxValue] and places the values into this vector3.

Parameters:
in_dMinValue Lower bound of the clamping domain.
in_dMaxValue Higher bound of the clamping domain.
in_vector3 Operand vector.
Returns:
A reference to this vector.
SICPPSDK_INLINE bool EpsilonEquals ( const CVector3 in_vector3,
double  in_dEpsilon 
) const

Tests the equality of this vector3 with the specified vector3, with a tolerance of Epsilon.

Parameters:
in_vector3 Operand vector.
in_dEpsilon Error margin
Possible Values: [0, +INF[ should be a positive value
Returns:
true if equal else false.
SICPPSDK_INLINE bool Equals ( const CVector3 in_vector3 ) const

Tests the strict equality of this vector3 with the specified vector3.

Parameters:
in_vector3 Operand vector.
Returns:
true if equal else false.
SICPPSDK_INLINE CVector3 & ScaleAddInPlace ( double  in_dS,
const CVector3 in_vector3 
)

Sets the value of this vector to the scalar multiplication of itself by s and then adds vector3 v. (this = s*this + v)

Parameters:
in_dS Scalar multiplicator.
in_vector3 Operand vector.
Returns:
A reference to this vector.
SICPPSDK_INLINE CVector3 & ScaleAdd ( double  in_dS,
const CVector3 in_vector3A,
const CVector3 in_vector3B 
)

Sets the value of this vector3 to the scalar multiplication of vector3 A by s and then adds vector3 B. (this = s*v1 + v2).

Parameters:
in_dS Scalar multiplicator.
in_vector3A Operand vector.
in_vector3B Operand vector.
Returns:
A reference to this vector.
SICPPSDK_INLINE CVector3 & ScaleInPlace ( double  in_dAlpha )

Scales this vector by the input scalar (alpha) (this = alpha * this).

Parameters:
in_dAlpha Scalar multiplicator.
Returns:
A reference to this vector.
SICPPSDK_INLINE CVector3 & Scale ( double  in_dAlpha,
const CVector3 in_vector3 
)

Scales the input vector (v) by (alpha) store the result into this one (this = alpha * v).

Parameters:
in_dAlpha Scalar multiplicator.
in_vector3 Operand vector.
Returns:
A reference to this vector.
SICPPSDK_INLINE CVector3 & NegateInPlace ( )

Negates this vector (this = - this).

Returns:
A reference to this vector.
SICPPSDK_INLINE CVector3 & Negate ( const CVector3 in_vector3 )

Negates the input vector (v) store the result into this one (this = - v).

Parameters:
in_vector3 Operand vector.
Returns:
A reference to this vector.
SICPPSDK_INLINE CVector3 & SubInPlace ( const CVector3 in_vector3 )

Subtracts the input vector3 (v) from this one (this = this - v).

Parameters:
in_vector3 Operand vector.
Returns:
A reference to this vector.
SICPPSDK_INLINE CVector3 & Sub ( const CVector3 in_vector3A,
const CVector3 in_vector3B 
)

Subtracts the input vector3 (in_vector3B) from the input vector3 (in_vector3A) and stores the result in this one (this = A - B).

Parameters:
in_vector3A Operand vector.
in_vector3B Operand vector.
Returns:
A reference to this vector.
SICPPSDK_INLINE CVector3 & AddInPlace ( const CVector3 in_vector3 )

Adds the input vector to this one (this = this + in_vector3).

Parameters:
in_vector3 Operand vector.
Returns:
A reference to this vector.
SICPPSDK_INLINE CVector3 & Add ( const CVector3 in_vector3A,
const CVector3 in_vector3B 
)

Adds both input vectors and stores the result in this one. (this = A + B)

Parameters:
in_vector3A Operand vector.
in_vector3B Operand vector.
Returns:
A reference to this vector.
SICPPSDK_INLINE void Get ( double &  io_dX,
double &  io_dY,
double &  io_dZ 
) const

Returns the X, Y and Z values of the vector.

Parameters:
io_dX X value to get in the vector.
io_dY Y value to get in the vector.
io_dZ Z value to get in the vector.
SICPPSDK_INLINE CVector3 & Set ( double  in_dX,
double  in_dY,
double  in_dZ 
)

Sets the X, Y and Z values of the vector.

Parameters:
in_dX X value to set in the vector.
in_dY Y value to set in the vector.
in_dZ Z value to set in the vector.
Returns:
A reference to the vector.
SICPPSDK_INLINE double GetZ ( ) const

Returns the Z value of this vector.

Returns:
Z value of this vector.
SICPPSDK_INLINE CVector3 & PutZ ( double  in_dZ )

Sets the Z value of this vector.

Parameters:
in_dZ z value.
Returns:
A reference to this vector.
SICPPSDK_INLINE double GetY ( ) const

Returns the Y value of this vector.

Returns:
Y value of this vector.
SICPPSDK_INLINE CVector3 & PutY ( double  in_dY )

Sets the Y value of this vector.

Parameters:
in_dY y value.
Returns:
A reference to this vector.
SICPPSDK_INLINE double GetX ( ) const

Returns the X value of this vector.

Returns:
X value of this vector.
SICPPSDK_INLINE CVector3 & PutX ( double  in_dX )

Sets the X value of this vector.

Parameters:
in_dX x value.
Returns:
A reference to this vector.

The documentation for this class was generated from the following file: