OpenVSP API Documentation 3.41.0
 
Loading...
Searching...
No Matches
vec3d Class Reference

#include <Vec3d.h>

Public Member Functions

 vec3d (double xx, double yy, double zz)
 
 vec3d (const vec3d &a)
 
 vec3d (const threed_point_type &a)
 
 vec3d (const double a[3])
 
 vec3d (const float a[3])
 
 vec3d (const std::vector< double > &a)
 
vec3doperator= (const vec3d &a)
 
vec3doperator= (const vec2d &a)
 
vec3doperator= (double a)
 
vec3doperator= (const threed_point_type &a)
 
double & operator[] (int i)
 
const double & operator[] (int i) const
 
vec2d as_vec2d_xy ()
 
vec3dset_xyz (double xx, double yy, double zz)
 
vec3dset_vec (const std::vector< double > &a)
 
vec3dset_arr (const double a[])
 
vec3dset_arr (const float a[])
 
vec3dset_x (double xx)
 
vec3dset_y (double yy)
 
vec3dset_z (double zz)
 
vec3dset_refx (const vec3d &a)
 
vec3dset_refy (const vec3d &a)
 
vec3dset_refz (const vec3d &a)
 
void get_pnt (double pnt[3]) const
 
void get_pnt (float pnt[3]) const
 
void get_pnt (threed_point_type &pnt) const
 
double x () const
 
double y () const
 
double z () const
 
double * data ()
 
void rotate_x (double cos_alpha, double sin_alpha)
 
void rotate_y (double cos_alpha, double sin_alpha)
 
void rotate_z (double cos_alpha, double sin_alpha)
 
void scale_x (double scale)
 
void scale_y (double scale)
 
void scale_z (double scale)
 
void offset_x (double offset)
 
void offset_y (double offset)
 
void offset_z (double offset)
 
void offset_i (double offset, int idir)
 
void rotate_z_zero_x (double cos_alpha, double sin_alpha)
 
void rotate_z_zero_y (double cos_alpha, double sin_alpha)
 
vec3d reflect_xy () const
 
vec3d reflect_xz () const
 
vec3d reflect_yz () const
 
vec3d swap_xy () const
 
vec3d swap_xz () const
 
vec3d swap_yz () const
 
vec3doperator+= (const vec3d &b)
 
vec3doperator-= (const vec3d &b)
 
vec3doperator*= (double b)
 
vec3doperator+= (double b[])
 
vec3doperator-= (double b[])
 
vec3doperator+= (float b[])
 
vec3doperator-= (float b[])
 
double mag () const
 
void normalize ()
 
int major_comp () const
 
int minor_comp () const
 
bool isnan () const
 
bool isinf () const
 
bool isfinite () const
 

Public Attributes

double v [3]
 

Friends

vec3d operator+ (const vec3d &a, const vec3d &b)
 
vec3d operator- (const vec3d &a, const vec3d &b)
 
vec3d operator* (const vec3d &a, double b)
 
vec3d operator* (double b, const vec3d &a)
 
vec3d operator* (const vec3d &a, const vec3d &b)
 
vec3d operator/ (const vec3d &a, double b)
 
vec3d operator- (const vec3d &in)
 
bool operator== (const vec3d &a, const vec3d &b)
 
bool operator!= (const vec3d &a, const vec3d &b)
 
double dist (const vec3d &a, const vec3d &b)
 
double dist_squared (const vec3d &a, const vec3d &b)
 
double dot (const vec3d &a, const vec3d &b)
 
vec3d cross (const vec3d &a, const vec3d &b)
 
double angle (const vec3d &a, const vec3d &b)
 
double signed_angle (const vec3d &a, const vec3d &b, const vec3d &ref)
 
double cos_angle (const vec3d &a, const vec3d &b)
 
double radius_of_circle (const vec3d &p1, const vec3d &p2, const vec3d &p3)
 
void center_of_circle (const vec3d &p1, const vec3d &p2, const vec3d &p3, vec3d &center)
 
double dist_pnt_2_plane (const vec3d &org, const vec3d &norm, const vec3d &pnt)
 
double dist_pnt_2_line (const vec3d &line_pt1, const vec3d &line_pt2, const vec3d &pnt)
 
vec3d proj_pnt_on_line_seg (const vec3d &line_pt1, const vec3d &line_pt2, const vec3d &pnt)
 
vec3d proj_pnt_on_ray (const vec3d &line_pt1, const vec3d &line_pt2, const vec3d &pnt)
 
vec3d proj_pnt_on_line (const vec3d &line_pt1, const vec3d &line_pt2, const vec3d &pnt)
 
vec3d proj_pnt_to_plane (const vec3d &org, const vec3d &plane_ln1, const vec3d &plane_ln2, const vec3d &pnt)
 
vec3d proj_vec_to_plane (const vec3d &vec, const vec3d &norm)
 
int tri_seg_intersect (const vec3d &A, const vec3d &B, const vec3d &C, const vec3d &D, const vec3d &E, double &u, double &w, double &t)
 
int tri_ray_intersect (const vec3d &A, const vec3d &B, const vec3d &C, const vec3d &D, const vec3d &E, double &u, double &w, double &t)
 
int plane_ray_intersect (const vec3d &A, const vec3d &B, const vec3d &C, const vec3d &D, const vec3d &E, double &t)
 
int plane_ray_intersect (const vec3d &orig, const vec3d &norm, const vec3d &D, const vec3d &E, double &t)
 
int ray_ray_intersect (const vec3d &A, const vec3d &B, const vec3d &C, const vec3d &D, vec3d &int_pnt1, vec3d &int_pnt2)
 
double tetra_volume (const vec3d &A, const vec3d &B, const vec3d &C)
 
double area (const vec3d &A, const vec3d &B, const vec3d &C)
 
double poly_area (const std::vector< vec3d > &pnt_vec)
 
double dist3D_Segment_to_Segment (const vec3d &S1P0, const vec3d &S1P1, const vec3d &S2P0, const vec3d &S2P1)
 
double dist3D_Segment_to_Segment (const vec3d &S1P0, const vec3d &S1P1, const vec3d &S2P0, const vec3d &S2P1, double *Lt, vec3d *Ln, double *St, vec3d *Sn)
 
double nearSegSeg (const vec3d &L0, const vec3d &L1, const vec3d &S0, const vec3d &S1, double *Lt, vec3d *Ln, double *St, vec3d *Sn)
 
double pointLineDistSquared (const vec3d &p, const vec3d &lp0, const vec3d &lp1, double *t)
 
double pointSegDistSquared (const vec3d &p, const vec3d &sp0, const vec3d &sp1, double *t)
 
vec3d point_on_line (const vec3d &lp0, const vec3d &lp1, const double &t)
 
vec2d MapToPlane (const vec3d &p, const vec3d &planeOrig, const vec3d &planeVec1, const vec3d &planeVec2)
 
vec3d MapFromPlane (const vec2d &uw, const vec3d &planeOrig, const vec3d &planeVec1, const vec3d &planeVec2)
 
int plane_half_space (const vec3d &planeOrig, const vec3d &planeNorm, const vec3d &pnt)
 
bool line_line_intersect (const vec3d &p1, const vec3d &p2, const vec3d &p3, const vec3d &p4, double *s, double *t)
 
vec3d RotateArbAxis (const vec3d &p, double theta, const vec3d &r)
 
bool PtInTri (const vec3d &v0, const vec3d &v1, const vec3d &v2, const vec3d &p)
 
vec3d BarycentricWeights (const vec3d &v0, const vec3d &v1, const vec3d &v2, const vec3d &p)
 
void BilinearWeights (const vec3d &p0, const vec3d &p1, const vec3d &p, std::vector< double > &weights)
 
double tri_tri_min_dist (const vec3d &v0, const vec3d &v1, const vec3d &v2, const vec3d &v3, const vec3d &v4, const vec3d &v5)
 
double pnt_tri_min_dist (const vec3d &v0, const vec3d &v1, const vec3d &v2, const vec3d &pnt)
 
vec3d slerp (const vec3d &a, const vec3d &b, const double &t)
 

Detailed Description

vec3d is typically used to describe coordinate points and vectors in 3D space. All 3 elements in the vector are of type double.

Definition at line 234 of file Vec3d.h.

Constructor & Destructor Documentation

◆ ~vec3d()

vec3d::~vec3d ( )
inline

Definition at line 244 of file Vec3d.h.

Member Function Documentation

◆ data()

double * vec3d::data ( )
inline

Definition at line 515 of file Vec3d.h.

◆ get_pnt() [1/3]

void vec3d::get_pnt ( double pnt[3]) const
inline

Definition at line 384 of file Vec3d.h.

◆ get_pnt() [2/3]

void vec3d::get_pnt ( float pnt[3]) const
inline

Definition at line 390 of file Vec3d.h.

◆ get_pnt() [3/3]

void vec3d::get_pnt ( threed_point_type & pnt) const
inline

Definition at line 396 of file Vec3d.h.

◆ mag()

double vec3d::mag ( ) const

Get the magnitude of a vec3d

//==== Test Vec3d ====//
vec3d a(); // Default Constructor
//==== Test Mag ====//
a.set_xyz( 1.0, 2.0, 3.0 );
if ( abs( a.mag() - sqrt( 14 ) ) > 1e-6 ) { Print( "---> Error: Vec3d Mag " ); }
Definition Vec3d.h:235
Returns
Magnitude

◆ normalize()

void vec3d::normalize ( )

Normalize the vec3d

//==== Test Vec3d ====//
vec3d a(), b(), c(); // Default Constructor
//==== Test Cross ====//
a.set_xyz( 4.0, 0.0, 0.0 );
b.set_xyz( 0.0, 3.0, 0.0 );
c = cross( a, b );
c.normalize();
friend vec3d cross(const vec3d &a, const vec3d &b)

◆ offset_i()

void vec3d::offset_i ( double offset,
int idir )
inline

Definition at line 839 of file Vec3d.h.

◆ offset_x()

void vec3d::offset_x ( double offset)
inline

Offset the X coordinate of the vec3d

//==== Test Vec3d ====//
vec3d a(); // Default Constructor
//===== Test Offset ====//
a.set_xyz( 2.0, 2.0, 2.0 );
a.offset_x( 10.0 );
Parameters
[in]offsetOffset for the X value

Definition at line 768 of file Vec3d.h.

◆ offset_y()

void vec3d::offset_y ( double offset)
inline

Offset the Y coordinate of the vec3d

//==== Test Vec3d ====//
vec3d a(); // Default Constructor
//===== Test Offset ====//
a.set_xyz( 2.0, 2.0, 2.0 );
a.offset_y( 10.0 );
Parameters
[in]offsetOffset for the Y value

Definition at line 801 of file Vec3d.h.

◆ offset_z()

void vec3d::offset_z ( double offset)
inline

Offset the Z coordinate of the vec3d

//==== Test Vec3d ====//
vec3d a(); // Default Constructor
//===== Test Offset ====//
a.set_xyz( 2.0, 2.0, 2.0 );
a.offset_z( 10.0 );
Parameters
[in]offsetOffset for the Z value

Definition at line 834 of file Vec3d.h.

◆ operator[]() [1/2]

double & vec3d::operator[] ( int i)
inline

Definition at line 261 of file Vec3d.h.

◆ operator[]() [2/2]

const double & vec3d::operator[] ( int i) const
inline

Definition at line 265 of file Vec3d.h.

◆ reflect_xy()

vec3d vec3d::reflect_xy ( ) const
inline

Reflect the vec3d across the XY plane

//==== Test Vec3d ====//
vec3d a(), b(); // Default Constructor
//===== Test Reflect ====//
a.set_xyz( 1.0, 2.0, 3.0 );
b = a.reflect_xy();
Returns
Reflected vec3d

Definition at line 901 of file Vec3d.h.

◆ reflect_xz()

vec3d vec3d::reflect_xz ( ) const
inline

Reflect the vec3d across the XZ plane

//==== Test Vec3d ====//
vec3d a(), b(); // Default Constructor
//===== Test Reflect ====//
a.set_xyz( 1.0, 2.0, 3.0 );
b = a.reflect_xz();
Returns
Reflected vec3d

Definition at line 934 of file Vec3d.h.

◆ reflect_yz()

vec3d vec3d::reflect_yz ( ) const
inline

Reflect the vec3d across the YZ plane

//==== Test Vec3d ====//
vec3d a(), b(); // Default Constructor
//===== Test Reflect ====//
a.set_xyz( 1.0, 2.0, 3.0 );
b = a.reflect_yz();
Returns
Reflected vec3d

Definition at line 967 of file Vec3d.h.

◆ rotate_x()

void vec3d::rotate_x ( double cos_alpha,
double sin_alpha )
inline

Rotate the vec3d about the X axis.

\begin{equation}x = cos \textunderscore alpha * x + sin \textunderscore alpha * z\end{equation}

\begin{equation}y = -sin \textunderscore alpha * old_y + cos \textunderscore alpha * z\end{equation}

//==== Test Vec3d ====//
vec3d a(); // Default Constructor
float PI = 3.14;
a.set_xyz( 1.0, 0.0, 0.0 );
a.rotate_x( cos( 0.5 * PI ), sin( 0.5 * PI ) );
Parameters
[in]cos_alphaCosine of rotation angle
[in]sin_alphaSine of rotation angle

Definition at line 553 of file Vec3d.h.

◆ rotate_y()

void vec3d::rotate_y ( double cos_alpha,
double sin_alpha )
inline

Rotate the vec3d about the Y axis.

\begin{equation}x = cos \textunderscore alpha * x - sin \textunderscore alpha * z\end{equation}

\begin{equation}z = sin \textunderscore alpha * old_x + cos \textunderscore alpha * z\end{equation}

//==== Test Vec3d ====//
vec3d a(); // Default Constructor
float PI = 3.14;
a.set_xyz( 1.0, 0.0, 0.0 );
a.rotate_y( cos( 0.5 * PI ), sin( 0.5 * PI ) );
Parameters
[in]cos_alphaCosine of rotation angle
[in]sin_alphaSine of rotation angle

Definition at line 592 of file Vec3d.h.

◆ rotate_z()

void vec3d::rotate_z ( double cos_alpha,
double sin_alpha )
inline

Rotate the vec3d about the Z axis.

\begin{equation}x = cos \textunderscore alpha * x + sin \textunderscore alpha * y\end{equation}

\begin{equation}y = -sin \textunderscore alpha * old_x + cos \textunderscore alpha * y\end{equation}

//==== Test Vec3d ====//
vec3d a(); // Default Constructor
float PI = 3.14;
a.set_xyz( 1.0, 0.0, 0.0 );
a.rotate_z( cos( 0.5 * PI ), sin( 0.5 * PI ) );
Parameters
[in]cos_alphaCosine of rotation angle
[in]sin_alphaSine of rotation angle

Definition at line 631 of file Vec3d.h.

◆ rotate_z_zero_x()

void vec3d::rotate_z_zero_x ( double cos_alpha,
double sin_alpha )
inline

Rotate the vec3d about the Z axis assuming zero X coordinate value

Parameters
[in]cos_alphaCosine of rotation angle
[in]sin_alphaSine of rotation angle

Definition at line 851 of file Vec3d.h.

◆ rotate_z_zero_y()

void vec3d::rotate_z_zero_y ( double cos_alpha,
double sin_alpha )
inline

Rotate the vec3d about the Z axis assuming zero Y coordinate value

Parameters
[in]cos_alphaCosine of rotation angle
[in]sin_alphaSine of rotation angle

Definition at line 863 of file Vec3d.h.

◆ scale_x()

void vec3d::scale_x ( double scale)
inline

Scale the X coordinate of the vec3d

//==== Test Vec3d ====//
vec3d a(); // Default Constructor
//===== Test Scale ====//
a.set_xyz( 2.0, 2.0, 2.0 );
a.scale_x( 2.0 );
Parameters
[in]scaleScaling factor for the X value

Definition at line 668 of file Vec3d.h.

◆ scale_y()

void vec3d::scale_y ( double scale)
inline

Scale the Y coordinate of the vec3d

//==== Test Vec3d ====//
vec3d a(); // Default Constructor
//===== Test Scale ====//
a.set_xyz( 2.0, 2.0, 2.0 );
a.scale_y( 2.0 );
Parameters
[in]scaleScaling factor for the Y value

Definition at line 701 of file Vec3d.h.

◆ scale_z()

void vec3d::scale_z ( double scale)
inline

Scale the Z coordinate of the vec3d

//==== Test Vec3d ====//
vec3d a(); // Default Constructor
//===== Test Scale ====//
a.set_xyz( 2.0, 2.0, 2.0 );
a.scale_z( 2.0 );
Parameters
[in]scaleScaling factor for the Z value

Definition at line 734 of file Vec3d.h.

◆ set_x()

vec3d & vec3d::set_x ( double xx)

Set the X coordinate (index 0) of the vec3d

//==== Test Vec3d ====//
vec3d a(); // Default Constructor
a.set_x( 2.0 );
Parameters
[in]xNew X value
Returns
Updated vec3d

◆ set_xyz()

vec3d & vec3d::set_xyz ( double xx,
double yy,
double zz )

Set all three elements of the vec3d vector

//==== Test Vec3d ====//
vec3d a(); // Default Constructor
a.set_xyz( 2.0, 4.0, 6.0 );
Parameters
[in]xNew X value
[in]yNew Y value
[in]zNew Z value
Returns
Updated vec3d

◆ set_y()

vec3d & vec3d::set_y ( double yy)

Set the Y coordinate (index 1) of the vec3d

//==== Test Vec3d ====//
vec3d a(); // Default Constructor
a.set_y( 4.0 );
Parameters
[in]yNew Y value
Returns
Updated vec3d

◆ set_z()

vec3d & vec3d::set_z ( double zz)

Set the z coordinate (index 2) of the vec3d

//==== Test Vec3d ====//
vec3d a(); // Default Constructor
a.set_z( 6.0 );
Parameters
[in]zin double new z value
Returns
vec3d result

◆ swap_xy()

vec3d vec3d::swap_xy ( ) const
inline

Definition at line 973 of file Vec3d.h.

◆ swap_xz()

vec3d vec3d::swap_xz ( ) const
inline

Definition at line 977 of file Vec3d.h.

◆ swap_yz()

vec3d vec3d::swap_yz ( ) const
inline

Definition at line 981 of file Vec3d.h.

◆ x()

double vec3d::x ( ) const
inline

Get the X coordinate (index 0) of the vec3d

vec3d a(); // Default Constructor
a.set_xyz( 2.0, 4.0, 6.0 );
Print( "a.x() = ", false );
Print( a.x() );
Print( "a[0]= ", false );
Print( a[0] );
Returns
X value

Definition at line 435 of file Vec3d.h.

◆ y()

double vec3d::y ( ) const
inline

Get the Y coordinate (index 1) of the vec3d

vec3d a(); // Default Constructor
a.set_xyz( 2.0, 4.0, 6.0 );
Print( "a.y() = ", false );
Print( a.y() );
Print( "a[1]= ", false );
Print( a[1] );
Returns
Y value

Definition at line 472 of file Vec3d.h.

◆ z()

double vec3d::z ( ) const
inline

Get the Z coordinate (index 2) of the vec3d

vec3d a(); // Default Constructor
a.set_xyz( 2.0, 4.0, 6.0 );
Print( "a.z() = ", false );
Print( a.z() );
Print( "a[2]= ", false );
Print( a[2] );
Returns
Z value

Definition at line 509 of file Vec3d.h.

Friends And Related Symbol Documentation

◆ angle

double angle ( const vec3d & a,
const vec3d & b )
friend

Calculate the angle between two vec3d inputs (dot product divided by their magnitudes multiplied)

//==== Test Vec3d ====//
vec3d a(), b(); // Default Constructor
float PI = 3.14159265359;
//==== Test Angle ====//
a.set_xyz( 1.0, 1.0, 0.0 );
b.set_xyz( 1.0, 0.0, 0.0 );
if ( abs( angle( a, b ) - PI / 4 ) > 1e-6 ) { Print( "---> Error: Vec3d Angle " ); }
friend double angle(const vec3d &a, const vec3d &b)
Parameters
[in]aFirst vec3d
[in]bSecond vec3d
Returns
Angle in Radians

◆ cos_angle

double cos_angle ( const vec3d & a,
const vec3d & b )
friend

Calculate the cosine of angle between two vec3d inputs

vec3d pnt = vec3d( 2, 4, 6);
vec3d line_pt1(), line_pt2();
line_pt1.set_z( 4 );
line_pt2.set_y( 3 );
vec3d p_ln1 = pnt - line_pt1;
vec3d ln2_ln1 = line_pt2 - line_pt1;
double numer = cos_angle( p_ln1, ln2_ln1 ) * p_ln1.mag();
double mag() const
friend double cos_angle(const vec3d &a, const vec3d &b)
See also
angle
Parameters
[in]aFirst vec3d
[in]bSecond vec3d
Returns
Angle in Radians

◆ cross

vec3d cross ( const vec3d & a,
const vec3d & b )
friend

Calculate the cross product between two vec3d inputs

//==== Test Vec3d ====//
vec3d a(), b(), c(); // Default Constructor
//==== Test Cross ====//
a.set_xyz( 4.0, 0.0, 0.0 );
b.set_xyz( 0.0, 3.0, 0.0 );
c = cross( a, b );
c.normalize();
Parameters
[in]aFirst vec3d
[in]bSecond vec3d
Returns
Cross product

◆ dist

double dist ( const vec3d & a,
const vec3d & b )
friend

Calculate the distance between two vec3d inputs

//==== Test Vec3d ====//
vec3d a(), b(); // Default Constructor
//==== Test Dist ====//
a.set_xyz( 2.0, 2.0, 2.0 );
b.set_xyz( 3.0, 4.0, 5.0 );
double d = dist( a, b );
if ( abs( d - sqrt( 14 ) ) > 1e-6 ) { Print( "---> Error: Vec3d Dist " ); }
friend double dist(const vec3d &a, const vec3d &b)
See also
dist_squared
Parameters
[in]aFirst vec3d
[in]bSecond vec3d
Returns
Distance

◆ dist_squared

double dist_squared ( const vec3d & a,
const vec3d & b )
friend

Calculate distance squared between two vec3d inputs

//==== Test Vec3d ====//
vec3d a(), b(); // Default Constructor
//==== Test Dist ====//
a.set_xyz( 2.0, 2.0, 2.0 );
b.set_xyz( 3.0, 4.0, 5.0 );
double d2 = dist_squared( a, b );
if ( abs( d2 - 14 ) > 1e-6 ) { Print( "---> Error: Vec3d Dist " ); }
friend double dist_squared(const vec3d &a, const vec3d &b)
See also
dist
Parameters
[in]aFirst vec3d
[in]bSecond vec3d
Returns
Distance squared

◆ dot

double dot ( const vec3d & a,
const vec3d & b )
friend

Calculate the dot product between two vec3d inputs

//==== Test Vec3d ====//
vec3d a(), b(); // Default Constructor
//==== Test Dot ====//
a.set_xyz( 1.0, 2.0, 3.0 );
b.set_xyz( 2.0, 3.0, 4.0 );
if ( abs( dot( a, b ) - 20 ) > 1e-6 ) { Print( "---> Error: Vec3d Dot " ); }
friend double dot(const vec3d &a, const vec3d &b)
Parameters
[in]aFirst vec3d
[in]bSecond vec3d
Returns
Dot product

◆ operator* [1/2]

vec3d operator* ( const vec3d & a,
const vec3d & b )
friend

Scalar multiplication operator for a vec3d, performed by the multiplication of each vec3d component and the scalar

vec3d a(); // Default Constructor
a.set_xyz( 1.0, 2.0, 3.0 );
double b = 1.5;
vec3d c = a * b;
Print( "a * b = ", false );
Print( c );

◆ operator* [2/2]

vec3d operator* ( const vec3d & a,
double b )
friend

Scalar multiplication operator for a vec3d, performed by the multiplication of each vec3d component and the scalar

vec3d a(); // Default Constructor
a.set_xyz( 1.0, 2.0, 3.0 );
double b = 1.5;
vec3d c = a * b;
Print( "a * b = ", false );
Print( c );

◆ operator+

vec3d operator+ ( const vec3d & a,
const vec3d & b )
friend

Addition operator for two vec3d objects, performed by the addition of each corresponding component

vec3d a(), b(); // Default Constructor
a.set_xyz( 1.0, 2.0, 3.0 );
b.set_xyz( 4.0, 5.0, 6.0 );
vec3d c = a + b;
Print( "a + b = ", false );
Print( c );

◆ operator-

vec3d operator- ( const vec3d & a,
const vec3d & b )
friend

Subtraction operator for two vec3d objects, performed by the subtraction of each corresponding component

\forcpponly
\code{.cpp}
vec3d a(), b(); // Default Constructor
a.set_xyz( 1.0, 2.0, 3.0 );
b.set_xyz( 4.0, 5.0, 6.0 );
vec3d c = a - b;
Print( "a - b = ", false );
Print( c );

◆ operator/

vec3d operator/ ( const vec3d & a,
double b )
friend

Scalar division operator for a vec3d, performed by the division of of each vec3d component by the scalar

vec3d a(); // Default Constructor
a.set_xyz( 1.0, 2.0, 3.0 );
double b = 1.5;
vec3d c = a / b;
Print( "a / b = ", false );
Print( c );

◆ RotateArbAxis

vec3d RotateArbAxis ( const vec3d & p,
double theta,
const vec3d & r )
friend

Rotate a input point by specified angle around an arbitrary axis. Assume right hand coordinate system

//==== Test Vec3d ====//
vec3d a(), b(), c(); // Default Constructor
float PI = 3.14;
//==== Test Rotate ====//
a.set_xyz( 1.0, 1.0, 0.0 );
b.set_xyz( 1.0, 0.0, 0.0 );
c.set_xyz( 0.0, 0.0, 1.0 );
c = RotateArbAxis( b, PI, a );
friend vec3d RotateArbAxis(const vec3d &p, double theta, const vec3d &r)
Parameters
[in]pCoordinate point to rotate
[in]thetaAngle of rotation in Radians
[in]axisReference axis for rotation
Returns
Coordinates of rotated point

◆ signed_angle

double signed_angle ( const vec3d & a,
const vec3d & b,
const vec3d & ref )
friend

Calculate the signed angle between two vec3d inputs (dot product divided by their magnitudes multiplied) and an input reference axis

//==== Test Vec3d ====//
vec3d a(), b(), c(); // Default Constructor
float PI = 3.14159265359;
//==== Test Angle ====//
a.set_xyz( 1.0, 1.0, 0.0 );
b.set_xyz( 1.0, 0.0, 0.0 );
c.set_xyz( 0.0, 0.0, 1.0 );
if ( abs( signed_angle( a, b, c ) - -PI / 4 ) > 1e-6 ) { Print( "---> Error: Vec3d SignedAngle " ); }
friend double signed_angle(const vec3d &a, const vec3d &b, const vec3d &ref)
Parameters
[in]aFirst vec3d
[in]bSecond vec3d
[in]refReference axis
Returns
Angle in Radians

Member Data Documentation

◆ v

double vec3d::v[3]

Definition at line 240 of file Vec3d.h.


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