OpenVSPAPI  3.20.0
Functions
Vec3D Functions

API functions that utilize the vec3d class are grouped here. For details of the class, including member functions, see vec3d.

Click here to return to the main page. More...

Functions

double dist (const vec3d &in a, const vec3d &in b)
 
double dist_squared (const vec3d &in a, const vec3d &in b)
 
double dot (const vec3d &in a, const vec3d &in b)
 
vec3d cross (const vec3d &in a, const vec3d &in b)
 
double angle (const vec3d &in a, const vec3d &in b)
 
double signed_angle (const vec3d &in a, const vec3d &in b, const vec3d &in ref)
 
vec3d RotateArbAxis (const vec3d &in p, double theta, const vec3d &in axis)
 

Detailed Description

Function Documentation

◆ angle()

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

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

//==== Test Vec3d ====//
vec3d a(), b(); // Default Constructor
//==== 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 " ); }
Parameters
[in]aFirst vec3d
[in]bSecond vec3d
Returns
Angle in Radians

◆ cross()

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

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 &in  a,
const vec3d &in  b 
)

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 " ); }
See also
dist_squared
Parameters
[in]aFirst vec3d
[in]bSecond vec3d
Returns
Distance

◆ dist_squared()

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

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 " ); }
See also
dist
Parameters
[in]aFirst vec3d
[in]bSecond vec3d
Returns
Distance squared

◆ dot()

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

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 " ); }
Parameters
[in]aFirst vec3d
[in]bSecond vec3d
Returns
Dot product

◆ RotateArbAxis()

vec3d RotateArbAxis ( const vec3d &in  p,
double  theta,
const vec3d &in  axis 
)
Calculate the cosine of angle between two vec3d inputs
\code{.cpp}
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();
\sa angle
\param [in] a First vec3d
\param [in] b Second vec3d
\return Angle in Radians

*/ double cos_angle(const vec3d&in a, const vec3d&in b);

/*!

*/

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

//==== Test Vec3d ====//
vec3d a(), b(), c(); // Default Constructor
//==== 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 );
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 &in  a,
const vec3d &in  b,
const vec3d &in  ref 
)

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
//==== 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 " ); }
Parameters
[in]aFirst vec3d
[in]bSecond vec3d
[in]refReference axis
Returns
Angle in Radians
RotateArbAxis
vec3d RotateArbAxis(const vec3d &in p, double theta, const vec3d &in axis)
dot
double dot(const vec3d &in a, const vec3d &in b)
signed_angle
double signed_angle(const vec3d &in a, const vec3d &in b, const vec3d &in ref)
dist
double dist(const vec3d &in a, const vec3d &in b)
vec3d
A class for representing 3D vectors.
Definition: openvsp_as.h:341
angle
double angle(const vec3d &in a, const vec3d &in b)
Print
void Print(const string &in data, bool new_line=true)
cross
vec3d cross(const vec3d &in a, const vec3d &in b)
dist_squared
double dist_squared(const vec3d &in a, const vec3d &in b)