OpenLexocad  28.0
Geom::Vec Class Reference

Defines a non-persistent vector in 3D space.
More...

#include <Vec.h>

Public Member Functions

 Vec ()
 Creates an indefinite vector.
More...
 
 Vec (const Geom::Dir &V)
 Creates a unitary vector from a direction V.
More...
 
 Vec (const Geom::XYZ &Coord)
 Creates a vector with a triplet of coordinates.
More...
 
 Vec (const double Xv, const double Yv, const double Zv)
 Creates a point with its three Cartesian coordinates.
More...
 
 Vec (const Geom::Pnt &P1, const Geom::Pnt &P2)
 
 Vec (const Vec &rhs)
 Copy constructor. More...
 
void setCoord (const int Index, const double Xi)
 
void setCoord (const double Xv, const double Yv, const double Zv)
 
void setX (const double X)
 Assigns the given value to the X coordinate of this vector.
More...
 
void setY (const double Y)
 Assigns the given value to the X coordinate of this vector.
More...
 
void setZ (const double Z)
 Assigns the given value to the X coordinate of this vector.
More...
 
void setXYZ (const Geom::XYZ &Coord)
 Assigns the three coordinates of Coord to this vector.
More...
 
double coord (const int Index) const
 
void coord (double &Xv, double &Yv, double &Zv) const
 For this vector returns its three coordinates Xv, Yv, and Zvinline
More...
 
double x () const
 For this vector, returns its X coordinate.
More...
 
double y () const
 For this vector, returns its Y coordinate.
More...
 
double z () const
 For this vector, returns its Z coordinate.
More...
 
const Geom::XYZxyz () const
 
float fx () const
 
float fy () const
 
float fz () const
 
bool isEqual (const Vec &Other, const double LinearTolerance, const double AngularTolerance) const
 
bool isNormal (const Vec &Other, const double AngularTolerance) const
 
bool isOpposite (const Vec &Other, const double AngularTolerance) const
 
bool isParallel (const Vec &Other, const double AngularTolerance) const
 
double angle (const Vec &Other) const
 
double angleWithRef (const Vec &Other, const Vec &VRef) const
 
double magnitude () const
 Computes the magnitude of this vector.
More...
 
double squareMagnitude () const
 Computes the square magnitude of this vector.
//! Adds two vectors
More...
 
void add (const Vec &Other)
 
void operator+= (const Vec &Other)
 
Vec added (const Vec &Other) const
 Adds two vectors
//! Subtracts two vectors
More...
 
Vec operator+ (const Vec &Other) const
 
void subtract (const Vec &Right)
 
void operator-= (const Vec &Right)
 
Vec subtracted (const Vec &Right) const
 Subtracts two vectors
//! Multiplies a vector by a scalar
More...
 
Vec operator- (const Vec &Right) const
 
void multiply (const double Scalar)
 
void operator*= (const double Scalar)
 
Vec multiplied (const double Scalar) const
 Multiplies a vector by a scalar
//! Divides a vector by a scalar
More...
 
Vec operator* (const double Scalar) const
 
void divide (const double Scalar)
 
void operator/= (const double Scalar)
 
Vec divided (const double Scalar) const
 Divides a vector by a scalar
//! computes the cross product between two vectors
More...
 
Vec operator/ (const double Scalar) const
 
void cross (const Vec &Right)
 
void operator^= (const Vec &Right)
 
Vec crossed (const Vec &Right) const
 computes the cross product between two vectors
More...
 
Vec operator^ (const Vec &Right) const
 
double crossMagnitude (const Vec &Right) const
 
double crossSquareMagnitude (const Vec &Right) const
 
void crossCross (const Vec &V1, const Vec &V2)
 
Vec crossCrossed (const Vec &V1, const Vec &V2) const
 
double dot (const Vec &Other) const
 computes the scalar product
More...
 
double operator* (const Vec &Other) const
 
double dotCross (const Vec &V1, const Vec &V2) const
 
void normalize ()
 
Vec normalized () const
 
void reverse ()
 
Vec reversed () const
 Reverses the direction of a vector
More...
 
Vec operator- () const
 
Vec operator& (const Vec &rcVct) const
 
void setLinearForm (const double A1, const Vec &V1, const double A2, const Vec &V2, const double A3, const Vec &V3, const Vec &V4)
 
void setLinearForm (const double A1, const Vec &V1, const double A2, const Vec &V2, const double A3, const Vec &V3)
 
void setLinearForm (const double A1, const Vec &V1, const double A2, const Vec &V2, const Vec &V3)
 
void setLinearForm (const double A1, const Vec &V1, const double A2, const Vec &V2)
 
void setLinearForm (const double A1, const Vec &V1, const Vec &V2)
 <me> is setted to the following linear form : A1 * V1 + V2
More...
 
void setLinearForm (const Vec &V1, const Vec &V2)
 <me> is setted to the following linear form : V1 + V2
More...
 
void mirror (const Vec &V)
 
Vec mirrored (const Vec &V) const
 
void mirror (const Geom::Ax1 &A1)
 
Vec mirrored (const Geom::Ax1 &A1) const
 
void mirror (const Geom::Ax2 &A2)
 
Vec mirrored (const Geom::Ax2 &A2) const
 
void rotate (const Geom::Ax1 &A1, const double Ang)
 
Vec rotated (const Geom::Ax1 &A1, const double Ang) const
 
void scale (const double S)
 
Vec scaled (const double S) const
 Scales a vector. S is the scaling value.
//! Transforms a vector with the transformation T.
More...
 
void transform (const Geom::Trsf &T)
 
Vec transformed (const Geom::Trsf &T) const
 Transforms a vector with the transformation T.
More...
 
Geom::VecprojectToLine (const Geom::Vec &rclPoint, const Geom::Vec &rclLine)
 Projects this point onto the line given by the base rclPoint and the direction rclLine. More...
 
Geom::Vec perpendicular (const Geom::Vec &rclBase, const Geom::Vec &rclDir) const
 
double distanceToPlane (const Geom::Vec &rclBase, const Geom::Vec &rclNorm) const
 
double distanceToLine (const Geom::Vec &rclBase, const Geom::Vec &rclDirect) const
 Computes the distance from this point to the line given by rclBase and rclDirect. More...
 
Geom::Vec distanceToLineSegment (const Geom::Vec &rclP1, const Geom::Vec &rclP2) const
 
double & operator[] (int i)
 

Detailed Description

Defines a non-persistent vector in 3D space.

Constructor & Destructor Documentation

◆ Vec() [1/6]

Geom::Vec::Vec ( )

Creates an indefinite vector.

◆ Vec() [2/6]

Geom::Vec::Vec ( const Geom::Dir V)

Creates a unitary vector from a direction V.

◆ Vec() [3/6]

Geom::Vec::Vec ( const Geom::XYZ Coord)

Creates a vector with a triplet of coordinates.

◆ Vec() [4/6]

Geom::Vec::Vec ( const double  Xv,
const double  Yv,
const double  Zv 
)

Creates a point with its three Cartesian coordinates.

◆ Vec() [5/6]

Geom::Vec::Vec ( const Geom::Pnt P1,
const Geom::Pnt P2 
)

Creates a vector from two points. The length of the vector
is the distance between P1 and P2

◆ Vec() [6/6]

Geom::Vec::Vec ( const Vec rhs)

Copy constructor.

Member Function Documentation

◆ add()

void Geom::Vec::add ( const Vec Other)

◆ added()

Vec Geom::Vec::added ( const Vec Other) const

Adds two vectors
//! Subtracts two vectors

◆ angle()

double Geom::Vec::angle ( const Vec Other) const

Computes the angular value between <me> and <Other>
Returns the angle value between 0 and PI in radian.
Raises VectorWithNullMagnitude if <me>.Magnitude() <= Resolution from gp or
Other.Magnitude() <= Resolution because the angular value is
indefinite if one of the vectors has a null magnitude.

◆ angleWithRef()

double Geom::Vec::angleWithRef ( const Vec Other,
const Vec VRef 
) const

Computes the angle, in radians, between this vector and
vector Other. The result is a value between -Pi and Pi.
For this, VRef defines the positive sense of rotation: the
angular value is positive, if the cross product this ^ Other
has the same orientation as VRef relative to the plane
defined by the vectors this and Other. Otherwise, the
angular value is negative.
Exceptions
gp_VectorWithNullMagnitude if the magnitude of this
vector, the vector Other, or the vector VRef is less than or
equal to Geom::Precision::linear_Resolution().
Standard_DomainError if this vector, the vector Other,
and the vector VRef are coplanar, unless this vector and
the vector Other are parallel.

◆ coord() [1/2]

double Geom::Vec::coord ( const int  Index) const

Returns the coordinate of range Index :
Index = 1 => X is returned
Index = 2 => Y is returned
Index = 3 => Z is returned
//! Raised if Index != {1, 2, 3}.

◆ coord() [2/2]

void Geom::Vec::coord ( double &  Xv,
double &  Yv,
double &  Zv 
) const

For this vector returns its three coordinates Xv, Yv, and Zvinline

◆ cross()

void Geom::Vec::cross ( const Vec Right)

◆ crossCross()

void Geom::Vec::crossCross ( const Vec V1,
const Vec V2 
)

◆ crossCrossed()

Vec Geom::Vec::crossCrossed ( const Vec V1,
const Vec V2 
) const

Computes the triple vector product.
<me> ^ (V1 ^ V2)

◆ crossed()

Vec Geom::Vec::crossed ( const Vec Right) const

computes the cross product between two vectors

◆ crossMagnitude()

double Geom::Vec::crossMagnitude ( const Vec Right) const

Computes the magnitude of the cross
product between <me> and Right.
Returns || <me> ^ Right ||

◆ crossSquareMagnitude()

double Geom::Vec::crossSquareMagnitude ( const Vec Right) const

Computes the square magnitude of
the cross product between <me> and Right.
Returns || <me> ^ Right ||**2
//! Computes the triple vector product.
<me> ^ (V1 ^ V2)

◆ distanceToLine()

double Geom::Vec::distanceToLine ( const Geom::Vec rclBase,
const Geom::Vec rclDirect 
) const

Computes the distance from this point to the line given by rclBase and rclDirect.

◆ distanceToLineSegment()

Geom::Vec Geom::Vec::distanceToLineSegment ( const Geom::Vec rclP1,
const Geom::Vec 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()

double Geom::Vec::distanceToPlane ( const Geom::Vec rclBase,
const Geom::Vec 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.

◆ divide()

void Geom::Vec::divide ( const double  Scalar)

◆ divided()

Vec Geom::Vec::divided ( const double  Scalar) const

Divides a vector by a scalar
//! computes the cross product between two vectors

◆ dot()

double Geom::Vec::dot ( const Vec Other) const

computes the scalar product

◆ dotCross()

double Geom::Vec::dotCross ( const Vec V1,
const Vec V2 
) const

Computes the triple scalar product <me> * (V1 ^ V2).
//! normalizes a vector
Raises an exception if the magnitude of the vector is
lower or equal to Resolution from gp.

◆ fx()

float Geom::Vec::fx ( ) const

◆ fy()

float Geom::Vec::fy ( ) const

◆ fz()

float Geom::Vec::fz ( ) const

◆ isEqual()

bool Geom::Vec::isEqual ( const Vec Other,
const double  LinearTolerance,
const double  AngularTolerance 
) const

Returns True if the two vectors have the same magnitude value
and the same direction. The precision values are LinearTolerance
for the magnitude and AngularTolerance for the direction.

◆ isNormal()

bool Geom::Vec::isNormal ( const Vec Other,
const double  AngularTolerance 
) const

Returns True if abs(<me>.Angle(Other) - PI/2.) <= AngularTolerance
Raises VectorWithNullMagnitude if <me>.Magnitude() <= Resolution or
Other.Magnitude() <= Resolution from gp

◆ isOpposite()

bool Geom::Vec::isOpposite ( const Vec Other,
const double  AngularTolerance 
) const

Returns True if PI - <me>.Angle(Other) <= AngularTolerance
Raises VectorWithNullMagnitude if <me>.Magnitude() <= Resolution or
Other.Magnitude() <= Resolution from gp

◆ isParallel()

bool Geom::Vec::isParallel ( const Vec Other,
const double  AngularTolerance 
) const

Returns True if Angle(<me>, Other) <= AngularTolerance or
PI - Angle(<me>, Other) <= AngularTolerance
This definition means that two parallel vectors cannot define
a plane but two vectors with opposite directions are considered
as parallel. Raises VectorWithNullMagnitude if <me>.Magnitude() <= Resolution or
Other.Magnitude() <= Resolution from gp

◆ magnitude()

double Geom::Vec::magnitude ( ) const

Computes the magnitude of this vector.

◆ mirror() [1/3]

void Geom::Vec::mirror ( const Geom::Ax1 A1)

◆ mirror() [2/3]

void Geom::Vec::mirror ( const Geom::Ax2 A2)

◆ mirror() [3/3]

void Geom::Vec::mirror ( const Vec V)

◆ mirrored() [1/3]

Vec Geom::Vec::mirrored ( const Geom::Ax1 A1) const

Performs the symmetrical transformation of a vector
with respect to an axis placement which is the axis
of the symmetry.

◆ mirrored() [2/3]

Vec Geom::Vec::mirrored ( const Geom::Ax2 A2) const

Performs the symmetrical transformation of a vector
with respect to a plane. The axis placement A2 locates
the plane of the symmetry : (Location, XDirection, YDirection).

◆ mirrored() [3/3]

Vec Geom::Vec::mirrored ( const Vec V) const

Performs the symmetrical transformation of a vector
with respect to the vector V which is the center of
the symmetry.

◆ multiplied()

Vec Geom::Vec::multiplied ( const double  Scalar) const

Multiplies a vector by a scalar
//! Divides a vector by a scalar

◆ multiply()

void Geom::Vec::multiply ( const double  Scalar)

◆ normalize()

void Geom::Vec::normalize ( )

◆ normalized()

Vec Geom::Vec::normalized ( ) const

normalizes a vector
Raises an exception if the magnitude of the vector is
lower or equal to Resolution from gp.
//! Reverses the direction of a vector

◆ operator&()

Vec Geom::Vec::operator& ( const Vec rcVct) const

◆ operator*() [1/2]

Vec Geom::Vec::operator* ( const double  Scalar) const
inline

◆ operator*() [2/2]

double Geom::Vec::operator* ( const Vec Other) const
inline

◆ operator*=()

void Geom::Vec::operator*= ( const double  Scalar)
inline

◆ operator+()

Vec Geom::Vec::operator+ ( const Vec Other) const
inline

◆ operator+=()

void Geom::Vec::operator+= ( const Vec Other)
inline

◆ operator-() [1/2]

Vec Geom::Vec::operator- ( ) const
inline

◆ operator-() [2/2]

Vec Geom::Vec::operator- ( const Vec Right) const
inline

◆ operator-=()

void Geom::Vec::operator-= ( const Vec Right)
inline

◆ operator/()

Vec Geom::Vec::operator/ ( const double  Scalar) const
inline

◆ operator/=()

void Geom::Vec::operator/= ( const double  Scalar)
inline

◆ operator[]()

double& Geom::Vec::operator[] ( int  i)

◆ operator^()

Vec Geom::Vec::operator^ ( const Vec Right) const
inline

◆ operator^=()

void Geom::Vec::operator^= ( const Vec Right)
inline

◆ perpendicular()

Geom::Vec Geom::Vec::perpendicular ( const Geom::Vec rclBase,
const Geom::Vec 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()

Geom::Vec& Geom::Vec::projectToLine ( const Geom::Vec rclPoint,
const Geom::Vec 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.

◆ reverse()

void Geom::Vec::reverse ( )

◆ reversed()

Vec Geom::Vec::reversed ( ) const

Reverses the direction of a vector

◆ rotate()

void Geom::Vec::rotate ( const Geom::Ax1 A1,
const double  Ang 
)

◆ rotated()

Vec Geom::Vec::rotated ( const Geom::Ax1 A1,
const double  Ang 
) const

Rotates a vector. A1 is the axis of the rotation.
Ang is the angular value of the rotation in radians.

◆ scale()

void Geom::Vec::scale ( const double  S)

◆ scaled()

Vec Geom::Vec::scaled ( const double  S) const

Scales a vector. S is the scaling value.
//! Transforms a vector with the transformation T.

◆ setCoord() [1/2]

void Geom::Vec::setCoord ( const double  Xv,
const double  Yv,
const double  Zv 
)

For this vector, assigns

  • the values Xv, Yv and Zv to its three coordinates.

◆ setCoord() [2/2]

void Geom::Vec::setCoord ( const int  Index,
const double  Xi 
)

Changes the coordinate of range Index
Index = 1 => X is modified
Index = 2 => Y is modified
Index = 3 => Z is modified
//! Raised if Index != {1, 2, 3}.

◆ setLinearForm() [1/6]

void Geom::Vec::setLinearForm ( const double  A1,
const Vec V1,
const double  A2,
const Vec V2 
)

<me> is setted to the following linear form :
A1 * V1 + A2 * V2

◆ setLinearForm() [2/6]

void Geom::Vec::setLinearForm ( const double  A1,
const Vec V1,
const double  A2,
const Vec V2,
const double  A3,
const Vec V3 
)

<me> is setted to the following linear form :
A1 * V1 + A2 * V2 + A3 * V3

◆ setLinearForm() [3/6]

void Geom::Vec::setLinearForm ( const double  A1,
const Vec V1,
const double  A2,
const Vec V2,
const double  A3,
const Vec V3,
const Vec V4 
)

<me> is setted to the following linear form :
A1 * V1 + A2 * V2 + A3 * V3 + V4

◆ setLinearForm() [4/6]

void Geom::Vec::setLinearForm ( const double  A1,
const Vec V1,
const double  A2,
const Vec V2,
const Vec V3 
)

<me> is setted to the following linear form :
A1 * V1 + A2 * V2 + V3

◆ setLinearForm() [5/6]

void Geom::Vec::setLinearForm ( const double  A1,
const Vec V1,
const Vec V2 
)

<me> is setted to the following linear form : A1 * V1 + V2

◆ setLinearForm() [6/6]

void Geom::Vec::setLinearForm ( const Vec V1,
const Vec V2 
)

<me> is setted to the following linear form : V1 + V2

◆ setX()

void Geom::Vec::setX ( const double  X)

Assigns the given value to the X coordinate of this vector.

◆ setXYZ()

void Geom::Vec::setXYZ ( const Geom::XYZ Coord)

Assigns the three coordinates of Coord to this vector.

◆ setY()

void Geom::Vec::setY ( const double  Y)

Assigns the given value to the X coordinate of this vector.

◆ setZ()

void Geom::Vec::setZ ( const double  Z)

Assigns the given value to the X coordinate of this vector.

◆ squareMagnitude()

double Geom::Vec::squareMagnitude ( ) const

Computes the square magnitude of this vector.
//! Adds two vectors

◆ subtract()

void Geom::Vec::subtract ( const Vec Right)

◆ subtracted()

Vec Geom::Vec::subtracted ( const Vec Right) const

Subtracts two vectors
//! Multiplies a vector by a scalar

◆ transform()

void Geom::Vec::transform ( const Geom::Trsf T)

◆ transformed()

Vec Geom::Vec::transformed ( const Geom::Trsf T) const

Transforms a vector with the transformation T.

◆ x()

double Geom::Vec::x ( ) const

For this vector, returns its X coordinate.

◆ xyz()

const Geom::XYZ& Geom::Vec::xyz ( ) const

For this vector, returns

  • its three coordinates as a number triple

◆ y()

double Geom::Vec::y ( ) const

For this vector, returns its Y coordinate.

◆ z()

double Geom::Vec::z ( ) const

For this vector, returns its Z coordinate.


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