QCAD Application Framework
CAD Application Development and Automation.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RVector Class Reference

Represents a 3d vector (x/y/z). More...

#include <RVector.h>

List of all members.

Public Member Functions

RVector flipHorizontal ()
 Mirrors this vector at the Y-axis.
RVector flipVertical ()
 Mirrors this vector at the X-axis.
double getAngle () const
double getAngleTo (const RVector &v) const
double getAngleToPlaneXY () const
RVector getCeil () const
RVector getClosest (const QList< RVector > &list) const
double getClosestDistance (const QList< RVector > &list, int counts)
int getClosestIndex (const QList< RVector > &list) const
double getDistanceTo (const RVector &v) const
double getDistanceTo2d (const RVector &v) const
RVector getDividedComponents (const RVector &v) const
RVector getFloor () const
RVector getLerp (const RVector &v, double t) const
 Linear interpolation between this and v by fraction 't'.
double getMagnitude () const
double getMagnitude2d () const
RVector getMultipliedComponents (const RVector &v) const
RVector getNegated () const
RVector getNormalized () const
double getSquaredMagnitude () const
RVector getTransformed (const RMatrix &m) const
RVector getTransformed2d (const RMatrix &m) const
RVector getUnitVector () const
double getX ()
double getY ()
double getZ ()
bool isInside (const RBox &b) const
bool isInWindow (const RVector &firstCorner, const RVector &secondCorner)
RVector isoProject (RS::IsoProjectionType type)
 Changes this vector into its isometric projection.
bool isValid () const
RVector mirror (const RLine &axis)
 Mirrors this vector at the given axis.
RVector mirror (const RVector &axis1, const RVector &axis2)
RVector move (const RVector &offset)
 Moves this vector by the given offset.
RVector normalize ()
 Normalizes this vector and returns a reference to this vector.
bool operator!= (const RVector &v) const
RVector operator* (double s) const
 binary * operator.
void operator*= (double s)
 *= operator
RVector operator+ (const RVector &v) const
 binary + operator.
void operator+= (const RVector &v)
 += operator.
RVector operator- (const RVector &v) const
 binary - operator.
RVector operator- () const
 unary - operator.
void operator-= (const RVector &v)
 -= operator.
RVector operator/ (double s) const
 binary / operator.
void operator/= (double s)
 /= operator
bool operator== (const RVector &v) const
 == operator
RVector rotate (double rotation)
 Rotates this vector around 0/0 by the given angle.
RVector rotate (double rotation, const RVector &center)
 Rotates this vector around the given center by the given angle.
 RVector ()
 Constructor for a valid vector (0/0/0).
 RVector (double vx, double vy, double vz=0.0, bool valid_in=true)
 Constructor for a point with given valid flag.
RVector scale (double factor, const RVector &center=nullVector)
 Scales this vector by the given factor with the given center.
RVector scale (const RVector &factors, const RVector &center=nullVector)
 Scales this vector by the given factors with the given center.
void set (double vx, double vy, double vz=0.0)
 Sets new values for the vector and makes the vector valid.
void setAngle (double a)
void setMagnitude2d (double m)
 Sets the vector magnitude without chaning the direction.
void setPolar (double radius, double angle)
 Sets a new position for the vector in polar coordinates.
void setX (double x)
void setY (double y)
void setZ (double z)
RVector stretch (const RPolyline &area, const RVector &offset)
 Moves this vector by offset if it is inside the given area.
RVector transform (const RMatrix &m)
 Generic 3d transformation.
RVector transform2d (const RMatrix &m)
 Generic 2d transformation.
RVector transform2d (const QTransform &t)
 Transforms this vector with the given transformation matrix.

Static Public Member Functions

static RVector createPolar (double radius, double angle)
static RVector getAverage (const RVector &v1, const RVector &v2)
 Convenience function.
static RVector getCrossProduct (const RVector &v1, const RVector &v2)
static double getDotProduct (const RVector &v1, const RVector &v2)
 Scalarproduct (dot product).
static RVector getMaximum (const QList< RVector > &vectors)
static RVector getMaximum (const RVector &v1, const RVector &v2)
static RVector getMinimum (const QList< RVector > &vectors)
static RVector getMinimum (const RVector &v1, const RVector &v2)
static QList< double > getXList (const QList< RVector > &vectors)
static QList< double > getYList (const QList< RVector > &vectors)
static QList< double > getZList (const QList< RVector > &vectors)
static bool greaterThanX (const RVector &v1, const RVector &v2)
static bool greaterThanY (const RVector &v1, const RVector &v2)
static bool lessThanX (const RVector &v1, const RVector &v2)
static bool lessThanY (const RVector &v1, const RVector &v2)
static void moveList (QList< RVector > &list, const RVector &offset)
static void rotateList (QList< RVector > &list, double rotation)
static void rotateList (QList< RVector > &list, double rotation, const RVector &center)
static void scaleList (QList< RVector > &list, double factor, const RVector &center=nullVector)
static void scaleList (QList< RVector > &list, const RVector &factors, const RVector &center=nullVector)

Public Attributes

bool valid
 Getter function for this property: isValid.
double x
 Getter function for this property: getX.
double y
 Getter function for this property: getY.
double z
 Getter function for this property: getZ.

Static Public Attributes

static const RVector invalid = RVector(0, 0, 0, false)
 invalid vector
static const RVector nullVector = RVector(0, 0, 0, true)
 null vector

Detailed Description

Represents a 3d vector (x/y/z).

Scriptable:
This class is wrapped for script environments.
Copyable:
Script wrappers of this class should pass objects by reference.

Constructor & Destructor Documentation

RVector::RVector ( )
inline

Constructor for a valid vector (0/0/0).

RVector::RVector ( double  vx,
double  vy,
double  vz = 0.0,
bool  valid_in = true 
)

Constructor for a point with given valid flag.

Parameters:
vtrue: a valid vector with default coordinates is created. false: an invalid vector is created Constructor for a point with given coordinates.

Member Function Documentation

static RVector RVector::createPolar ( double  radius,
double  angle 
)
inlinestatic
RVector RVector::flipHorizontal ( )

Mirrors this vector at the Y-axis.

RVector RVector::flipVertical ( )

Mirrors this vector at the X-axis.

double RVector::getAngle ( ) const
Returns:
The angle from zero to this vector (in rad).
double RVector::getAngleTo ( const RVector v) const
Returns:
The angle from this and the given coordinate (in rad).
double RVector::getAngleToPlaneXY ( ) const
Returns:
Angle between this vector and XY plane (horizontal plane).
RVector RVector::getAverage ( const RVector v1,
const RVector v2 
)
static

Convenience function.

Returns:
(v1 + v2) / 2.0
RVector RVector::getCeil ( ) const
Returns:
Vector with all components ceiled to the next higher integer.
RVector RVector::getClosest ( const QList< RVector > &  list) const
Returns:
The vector in the given vectors that is closest to this vector or an invalid vector if the given vector does not contain any (valid) vectors.
double RVector::getClosestDistance ( const QList< RVector > &  list,
int  counts 
)
int RVector::getClosestIndex ( const QList< RVector > &  list) const
RVector RVector::getCrossProduct ( const RVector v1,
const RVector v2 
)
static
Returns:
Cross product of two vectors.
double RVector::getDistanceTo ( const RVector v) const
Returns:
The distance between this and the given coordinate.
double RVector::getDistanceTo2d ( const RVector v) const
Returns:
The distance between this and the given coordinate on the XY plane.
RVector RVector::getDividedComponents ( const RVector v) const
Returns:
A new vector with all components divided by the components given in vector v. Note that the division of two vectors is not defined. This is merely a helper function that does what it does.
Todo:
refactor
double RVector::getDotProduct ( const RVector v1,
const RVector v2 
)
static

Scalarproduct (dot product).

RVector RVector::getFloor ( ) const
Returns:
Vector with all components floored to the next lower integer.
RVector RVector::getLerp ( const RVector v,
double  t 
) const

Linear interpolation between this and v by fraction 't'.

double RVector::getMagnitude ( ) const
Returns:
Magnitude (length) of the vector.
double RVector::getMagnitude2d ( ) const
Returns:
Magnitude (length) of the vector projected to the x/y plane (2d).
RVector RVector::getMaximum ( const QList< RVector > &  vectors)
static
Returns:
A vector with the maximum components from the given vectors. These might be mixed components from all vectors.
RVector RVector::getMaximum ( const RVector v1,
const RVector v2 
)
static
Returns:
A vector with the maximum values from the vectors v1 and v2
RVector RVector::getMinimum ( const QList< RVector > &  vectors)
static
Returns:
A vector with the minimum components from the given vectors. These might be mixed components from all vectors.
RVector RVector::getMinimum ( const RVector v1,
const RVector v2 
)
static
Returns:
A vector with the minimum components from the vectors v1 and v2. These might be mixed components from both vectors.
RVector RVector::getMultipliedComponents ( const RVector v) const
Returns:
A new vector with all components multiplied by the components given in vector v. Note that the multiplication of two vectors is not defined. This is merely a helper function that does what it does.
Todo:
refactor
RVector RVector::getNegated ( ) const
Returns:
New vector with negated components.
RVector RVector::getNormalized ( ) const
Returns:
A new unit vector with the same direction as this vector.
double RVector::getSquaredMagnitude ( ) const
Returns:
Square of magnitude (length).
RVector RVector::getTransformed ( const RMatrix m) const
Returns:
A new vector which is the result of this vector transformed by the given matrix.
RVector RVector::getTransformed2d ( const RMatrix m) const
Returns:
A new vector which is the result of this vector transformed by the given matrix.
RVector RVector::getUnitVector ( ) const
Returns:
Unit vector for this vector.
double RVector::getX ( )
QList< double > RVector::getXList ( const QList< RVector > &  vectors)
static
Returns:
All X values of the given list of vectors as a new list.
double RVector::getY ( )
QList< double > RVector::getYList ( const QList< RVector > &  vectors)
static
Returns:
All Y values of the given list of vectors as a new list.
double RVector::getZ ( )
QList< double > RVector::getZList ( const QList< RVector > &  vectors)
static
Returns:
All Z values of the given list of vectors as a new list.
static bool RVector::greaterThanX ( const RVector v1,
const RVector v2 
)
inlinestatic
static bool RVector::greaterThanY ( const RVector v1,
const RVector v2 
)
inlinestatic
bool RVector::isInside ( const RBox b) const
Returns:
True if this vector is inside the given box, false otherwise.
bool RVector::isInWindow ( const RVector firstCorner,
const RVector secondCorner 
)
Returns:
true if this vector is within the given range (2d).
RVector RVector::isoProject ( RS::IsoProjectionType  type)

Changes this vector into its isometric projection.

Todo:
refactor
bool RVector::isValid ( ) const
static bool RVector::lessThanX ( const RVector v1,
const RVector v2 
)
inlinestatic
static bool RVector::lessThanY ( const RVector v1,
const RVector v2 
)
inlinestatic
RVector RVector::mirror ( const RLine axis)

Mirrors this vector at the given axis.

RVector RVector::mirror ( const RVector axis1,
const RVector axis2 
)
RVector RVector::move ( const RVector offset)

Moves this vector by the given offset.

Equal to the operator +=.

void RVector::moveList ( QList< RVector > &  list,
const RVector offset 
)
static
   \par Non-Scriptable:

This function is not available in script environments.

RVector RVector::normalize ( )

Normalizes this vector and returns a reference to this vector.

bool RVector::operator!= ( const RVector v) const
inline
RVector RVector::operator* ( double  s) const

binary * operator.

void RVector::operator*= ( double  s)

*= operator

RVector RVector::operator+ ( const RVector v) const

binary + operator.

void RVector::operator+= ( const RVector v)

+= operator.

The result is only valid if both vectors are valid.

RVector RVector::operator- ( const RVector v) const

binary - operator.

RVector RVector::operator- ( ) const

unary - operator.

void RVector::operator-= ( const RVector v)

-= operator.

The result is only valid if both vectors are valid.

RVector RVector::operator/ ( double  s) const

binary / operator.

void RVector::operator/= ( double  s)

/= operator

bool RVector::operator== ( const RVector v) const

== operator

RVector RVector::rotate ( double  rotation)

Rotates this vector around 0/0 by the given angle.

RVector RVector::rotate ( double  rotation,
const RVector center 
)

Rotates this vector around the given center by the given angle.

void RVector::rotateList ( QList< RVector > &  list,
double  rotation 
)
static
   \par Non-Scriptable:

This function is not available in script environments.

void RVector::rotateList ( QList< RVector > &  list,
double  rotation,
const RVector center 
)
static
   \par Non-Scriptable:

This function is not available in script environments.

RVector RVector::scale ( double  factor,
const RVector center = nullVector 
)

Scales this vector by the given factor with the given center.

RVector RVector::scale ( const RVector factors,
const RVector center = nullVector 
)

Scales this vector by the given factors with the given center.

void RVector::scaleList ( QList< RVector > &  list,
double  factor,
const RVector center = nullVector 
)
static
   \par Non-Scriptable:

This function is not available in script environments.

void RVector::scaleList ( QList< RVector > &  list,
const RVector factors,
const RVector center = nullVector 
)
static
   \par Non-Scriptable:

This function is not available in script environments.

void RVector::set ( double  vx,
double  vy,
double  vz = 0.0 
)
inline

Sets new values for the vector and makes the vector valid.

void RVector::setAngle ( double  a)
void RVector::setMagnitude2d ( double  m)

Sets the vector magnitude without chaning the direction.

void RVector::setPolar ( double  radius,
double  angle 
)

Sets a new position for the vector in polar coordinates.

Parameters:
radiusthe radius or the distance
anglethe angle in rad
void RVector::setX ( double  x)
void RVector::setY ( double  y)
void RVector::setZ ( double  z)
RVector RVector::stretch ( const RPolyline area,
const RVector offset 
)

Moves this vector by offset if it is inside the given area.

RVector RVector::transform ( const RMatrix m)

Generic 3d transformation.

m must be a 3x3 matrix.

RVector RVector::transform2d ( const RMatrix m)

Generic 2d transformation.

m must be a 3x2 matrix.

RVector RVector::transform2d ( const QTransform &  t)

Transforms this vector with the given transformation matrix.


Member Data Documentation

const RVector RVector::invalid = RVector(0, 0, 0, false)
static

invalid vector

const RVector RVector::nullVector = RVector(0, 0, 0, true)
static

null vector

bool RVector::valid

Getter function for this property: isValid.

double RVector::x

Getter function for this property: getX.

Setter function for this property: setX

double RVector::y

Getter function for this property: getY.

Setter function for this property: setY

double RVector::z

Getter function for this property: getZ.

Setter function for this property: setZ


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