OpenVSP API Documentation 3.41.0
 
Loading...
Searching...
No Matches
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

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* (const vec3d &a, const vec3d &b)
 
vec3d operator/ (const vec3d &a, double 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)
 
vec3d RotateArbAxis (const vec3d &p, double theta, const vec3d &r)
 

Detailed Description

Function Documentation

◆ angle()

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

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 " ); }
Definition Vec3d.h:235
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 )

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
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 )

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();
vec3d cross(const vec3d &a, const vec3d &b)
Parameters
[in]aFirst vec3d
[in]bSecond vec3d
Returns
Cross product

◆ dist()

double dist ( const vec3d & a,
const vec3d & 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 " ); }
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 )

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 " ); }
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 )

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 " ); }
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 )

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 )

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 )

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 )

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 )

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 )

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 );
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 )

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 " ); }
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