OpenVSP API Documentation 3.51.3
Loading...
Searching...
No Matches
Geom Surface Query Functions

This group of API functions pertains to general surface queries for Geom surfaces, such as computing 3D location from surface coordinates, identifying curvature, and performing point projections. Click here to return to the main page. More...

Functions

vec3d vsp::CompPnt01 (const std::string &geom_id, const int &surf_indx, const double &u, const double &w)
vec3d vsp::CompNorm01 (const std::string &geom_id, const int &surf_indx, const double &u, const double &w)
vec3d vsp::CompTanU01 (const std::string &geom_id, const int &surf_indx, const double &u, const double &w)
vec3d vsp::CompTanW01 (const std::string &geom_id, const int &surf_indx, const double &u, const double &w)
void vsp::CompCurvature01 (const std::string &geom_id, const int &surf_indx, const double &u, const double &w, double &k1_out, double &k2_out, double &ka_out, double &kg_out)
double vsp::ProjPnt01 (const std::string &geom_id, const int &surf_indx, const vec3d &pt, double &u_out, double &w_out)
double vsp::ProjPnt01I (const std::string &geom_id, const vec3d &pt, int &surf_indx_out, double &u_out, double &w_out)
double vsp::ProjPnt01Guess (const std::string &geom_id, const int &surf_indx, const vec3d &pt, const double &u0, const double &w0, double &u_out, double &w_out)
double vsp::AxisProjPnt01 (const std::string &geom_id, const int &surf_indx, const int &iaxis, const vec3d &pt, double &u_out, double &w_out)
double vsp::AxisProjPnt01I (const std::string &geom_id, const int &iaxis, const vec3d &pt, int &surf_indx_out, double &u_out, double &w_out)
double vsp::AxisProjPnt01Guess (const std::string &geom_id, const int &surf_indx, const int &iaxis, const vec3d &pt, const double &u0, const double &w0, double &u_out, double &w_out)
bool vsp::InsideSurf (const std::string &geom_id, const int &surf_indx, const vec3d &pt)
vec3d vsp::CompPntRST (const std::string &geom_id, const int &surf_indx, const double &r, const double &s, const double &t)
double vsp::FindRST (const std::string &geom_id, const int &surf_indx, const vec3d &pt, double &r_out, double &s_out, double &t_out)
double vsp::FindRSTGuess (const std::string &geom_id, const int &surf_indx, const vec3d &pt, const double &r0, const double &s0, const double &t0, double &r_out, double &s_out, double &t_out)
void vsp::ConvertRSTtoLMN (const std::string &geom_id, const int &surf_indx, const double &r, const double &s, const double &t, double &l_out, double &m_out, double &n_out)
void vsp::ConvertRtoL (const std::string &geom_id, const int &surf_indx, const double &r, double &l_out)
void vsp::ConvertLMNtoRST (const std::string &geom_id, const int &surf_indx, const double &l, const double &m, const double &n, double &r_out, double &s_out, double &t_out)
void vsp::ConvertLtoR (const std::string &geom_id, const int &surf_indx, const double &l, double &r_out)
void vsp::ConvertUtoEta (const std::string &geom_id, const double &u, double &eta_out)
void vsp::ConvertEtatoU (const std::string &geom_id, const double &eta, double &u_out)
std::vector< vec3dvsp::CompVecPnt01 (const std::string &geom_id, const int &surf_indx, const std::vector< double > &u_in_vec, const std::vector< double > &w_in_vec)
std::vector< vec3dvsp::CompVecDegenPnt01 (const std::string &geom_id, const int &surf_indx, const int &degen_type, const std::vector< double > &u_in_vec, const std::vector< double > &w_in_vec)
std::vector< vec3dvsp::CompVecNorm01 (const std::string &geom_id, const int &surf_indx, const std::vector< double > &us, const std::vector< double > &ws)
void vsp::CompVecCurvature01 (const std::string &geom_id, const int &surf_indx, const std::vector< double > &us, const std::vector< double > &ws, std::vector< double > &k1_out_vec, std::vector< double > &k2_out_vec, std::vector< double > &ka_out_vec, std::vector< double > &kg_out_vec)
void vsp::ProjVecPnt01 (const std::string &geom_id, const int &surf_indx, const std::vector< vec3d > &pts, std::vector< double > &u_out_vec, std::vector< double > &w_out_vec, std::vector< double > &d_out_vec)
void vsp::ProjVecPnt01Guess (const std::string &geom_id, const int &surf_indx, const std::vector< vec3d > &pts, const std::vector< double > &u0s, const std::vector< double > &w0s, std::vector< double > &u_out_vec, std::vector< double > &w_out_vec, std::vector< double > &d_out_vec)
void vsp::AxisProjVecPnt01 (const std::string &geom_id, const int &surf_indx, const int &iaxis, const std::vector< vec3d > &pts, std::vector< double > &u_out_vec, std::vector< double > &w_out_vec, std::vector< double > &d_out_vec)
void vsp::AxisProjVecPnt01Guess (const std::string &geom_id, const int &surf_indx, const int &iaxis, const std::vector< vec3d > &pts, const std::vector< double > &u0s, const std::vector< double > &w0s, std::vector< double > &u_out_vec, std::vector< double > &w_out_vec, std::vector< double > &d_out_vec)
std::vector< bool > vsp::VecInsideSurf (const std::string &geom_id, const int &surf_indx, const std::vector< vec3d > &pts)
std::vector< vec3dvsp::CompVecPntRST (const std::string &geom_id, const int &surf_indx, const std::vector< double > &r_in_vec, const std::vector< double > &s_in_vec, const std::vector< double > &t_in_vec)
void vsp::FindRSTVec (const std::string &geom_id, const int &surf_indx, const std::vector< vec3d > &pts, std::vector< double > &r_out_vec, std::vector< double > &s_out_vec, std::vector< double > &t_out_vec, std::vector< double > &d_out_vec)
void vsp::FindRSTVecGuess (const std::string &geom_id, const int &surf_indx, const std::vector< vec3d > &pts, const std::vector< double > &r0s, const std::vector< double > &s0s, const std::vector< double > &t0s, std::vector< double > &r_out_vec, std::vector< double > &s_out_vec, std::vector< double > &t_out_vec, std::vector< double > &d_out_vec)
void vsp::ConvertRSTtoLMNVec (const std::string &geom_id, const int &surf_indx, const std::vector< double > &r_vec, const std::vector< double > &s_vec, const std::vector< double > &t_vec, std::vector< double > &l_out_vec, std::vector< double > &m_out_vec, std::vector< double > &n_out_vec)
void vsp::ConvertLMNtoRSTVec (const std::string &geom_id, const int &surf_indx, const std::vector< double > &l_vec, const std::vector< double > &m_vec, const std::vector< double > &n_vec, std::vector< double > &r_out_vec, std::vector< double > &s_out_vec, std::vector< double > &t_out_vec)
void vsp::GetUWTess01 (const std::string &geom_id, const int &surf_indx, std::vector< double > &u_out_vec, std::vector< double > &w_out_vec)

Detailed Description

Function Documentation

◆ AxisProjPnt01()

double vsp::AxisProjPnt01 ( const std::string & geom_id,
const int & surf_indx,
const int & iaxis,
const vec3d & pt,
double & u_out,
double & w_out )
extern

Project an input 3D coordinate point onto a surface along a specified axis. If the axis-aligned ray from the point intersects the surface multiple times, the nearest intersection is returned. If the axis-aligned ray from the point does not intersect the surface, the original point is returned and -1 is returned in the other output parameters.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
double u = 0.12345;
double w = 0.67890;
vec3d surf_pt = CompPnt01( geom_id, surf_indx, u, w );
vec3d pt = surf_pt;
pt.offset_y( -5.0 );
double u_out, w_out;
double idist = AxisProjPnt01( geom_id, surf_indx, Y_DIR, pt, u_out, w_out);
// pt is the surface point pushed off in -Y, so projecting back along Y
// has to land on the point it came from.
if ( ( surf_pt - CompPnt01( geom_id, surf_indx, u_out, w_out ) ).mag() > 1e-6 )
{
Print( "ERROR: AxisProjPnt01 did not recover the original point" );
__failure++;
}
Print( "iDist " + idist + " u_out " + u_out + " w_out " + w_out );
Print( "3D Offset ", false);
Definition Vec3d.h:243
void offset_y(double offset)
Definition Vec3d.h:784
std::string AddGeom(const std::string &type, const std::string &parent=std::string())
vec3d CompPnt01(const std::string &geom_id, const int &surf_indx, const double &u, const double &w)
double AxisProjPnt01(const std::string &geom_id, const int &surf_indx, const int &iaxis, const vec3d &pt, double &u_out, double &w_out)
See also
AxisProjPnt01Guess, AxisProjPnt01I, AxisProjVecPnt01, AxisProjVecPnt01Guess
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]iaxisint Axis direction to project point along (X_DIR, Y_DIR, or Z_DIR)
[in]ptvec3d Input 3D coordinate point
[out]u_outdouble Output closest U (0 - 1) surface coordinate
[out]w_outdouble Output closest W (0 - 1) surface coordinate
Returns
double Axis aligned distance between the 3D point and the projected point on the surface

◆ AxisProjPnt01Guess()

double vsp::AxisProjPnt01Guess ( const std::string & geom_id,
const int & surf_indx,
const int & iaxis,
const vec3d & pt,
const double & u0,
const double & w0,
double & u_out,
double & w_out )
extern

Project an input 3D coordinate point onto a surface along a specified axis given an initial guess of surface parameter. If the axis-aligned ray from the point intersects the surface multiple times, the nearest intersection is returned. If the axis-aligned ray from the point does not intersect the surface, the original point is returned and -1 is returned in the other output parameters. The surface parameter guess should allow this call to be faster than calling AxisProjPnt01 without a guess.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
double u = 0.12345;
double w = 0.67890;
vec3d surf_pt = CompPnt01( geom_id, surf_indx, u, w );
vec3d pt = surf_pt;
pt.offset_y( -5.0 );
// Construct initial guesses near actual parameters
double u0 = u + 0.01234;
double w0 = w - 0.05678;
double uout, wout;
double d = AxisProjPnt01Guess( geom_id, surf_indx, Y_DIR, pt, u0, w0, uout, wout);
Print( "Dist " + d + " u " + uout + " w " + wout );
// The test point sits five units away along Y from a known surface point,
// so projecting back along Y has to recover that point and that distance.
if ( !closeTo( uout, u, 1e-6 ) || !closeTo( wout, w, 1e-6 ) )
{
Print( "ERROR: AxisProjPnt01Guess did not recover the surface point" );
__failure++;
}
if ( !closeTo( d, 5.0, 1e-6 ) )
{
Print( "ERROR: AxisProjPnt01Guess reported the wrong distance" );
__failure++;
}
// Starting from a guess must not change the answer.
double uout_ng, wout_ng;
double d_ng = AxisProjPnt01( geom_id, surf_indx, Y_DIR, pt, uout_ng, wout_ng );
if ( !closeTo( uout_ng, uout, 1e-6 ) || !closeTo( wout_ng, wout, 1e-6 ) || !closeTo( d_ng, d, 1e-6 ) )
{
Print( "ERROR: the guess changed the answer" );
__failure++;
}
double AxisProjPnt01Guess(const std::string &geom_id, const int &surf_indx, const int &iaxis, const vec3d &pt, const double &u0, const double &w0, double &u_out, double &w_out)
See also
AxisProjPnt01, AxisProjPnt01I, AxisProjVecPnt01, AxisProjVecPnt01Guess
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]iaxisint Axis direction to project point along (X_DIR, Y_DIR, or Z_DIR)
[in]ptvec3d Input 3D coordinate point
[in]u0double Input U (0 - 1) surface coordinate guess
[in]w0double Input W (0 - 1) surface coordinate guess
[out]u_outdouble Output closest U (0 - 1) surface coordinate
[out]w_outdouble Output closest W (0 - 1) surface coordinate
Returns
double Distance between the 3D point and the closest point of the surface

◆ AxisProjPnt01I()

double vsp::AxisProjPnt01I ( const std::string & geom_id,
const int & iaxis,
const vec3d & pt,
int & surf_indx_out,
double & u_out,
double & w_out )
extern

Project an input 3D coordinate point onto a Geom along a specified axis. The intersecting surface index is also returned. If the axis-aligned ray from the point intersects the Geom multiple times, the nearest intersection is returned. If the axis-aligned ray from the point does not intersect the Geom, the original point is returned and -1 is returned in the other output parameters.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
double u = 0.12345;
double w = 0.67890;
vec3d surf_pt = CompPnt01( geom_id, surf_indx, u, w );
vec3d pt = surf_pt;
pt.offset_y( -5.0 );
double u_out, w_out;
int surf_indx_out;
double idist = AxisProjPnt01I( geom_id, Y_DIR, pt, surf_indx_out, u_out, w_out);
// pt is the surface point pushed off in -Y, so projecting back along Y
// has to land on the point it came from.
if ( ( surf_pt - CompPnt01( geom_id, surf_indx, u_out, w_out ) ).mag() > 1e-6 )
{
Print( "ERROR: AxisProjPnt01I did not recover the original point" );
__failure++;
}
Print( "iDist " + idist + " u_out " + u_out + " w_out " + w_out + " surf_index " + surf_indx_out );
Print( "3D Offset ", false);
double AxisProjPnt01I(const std::string &geom_id, const int &iaxis, const vec3d &pt, int &surf_indx_out, double &u_out, double &w_out)
See also
AxisProjPnt01, AxisProjPnt01Guess, AxisProjVecPnt01, AxisProjVecPnt01Guess
Parameters
[in]geom_idstring Parent Geom ID
[in]iaxisint Axis direction to project point along (X_DIR, Y_DIR, or Z_DIR)
[in]ptvec3d Input 3D coordinate point
[out]surf_indx_outint Output main surface index from the parent Geom
[out]u_outdouble Output closest U (0 - 1) surface coordinate
[out]w_outdouble Output closest W (0 - 1) surface coordinate
Returns
double Axis aligned distance between the 3D point and the projected point on the surface

◆ AxisProjVecPnt01()

void vsp::AxisProjVecPnt01 ( const std::string & geom_id,
const int & surf_indx,
const int & iaxis,
const std::vector< vec3d > & pts,
std::vector< double > & u_out_vec,
std::vector< double > & w_out_vec,
std::vector< double > & d_out_vec )
extern

Project an input array of 3D coordinate points onto a surface along a specified axis. If the axis-aligned ray from the point intersects the surface multiple times, the nearest intersection is returned. If the axis-aligned ray from the point does not intersect the surface, the original point is returned and -1 is returned in the other output parameters.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
int n = 5;
array<double> uvec, wvec;
uvec.resize( n );
wvec.resize( n );
for( int i = 0 ; i < n ; i++ )
{
uvec[i] = (i+1)*1.0/(n+1);
wvec[i] = (n-i)*1.0/(n+1);
}
array< vec3d > ptvec = CompVecPnt01( geom_id, surf_indx, uvec, wvec );
for( int i = 0 ; i < n ; i++ )
{
ptvec[i].offset_y( -5.0 );
}
array<double> uoutv, woutv, doutv;
AxisProjVecPnt01( geom_id, surf_indx, Y_DIR, ptvec, uoutv, woutv, doutv );
// Some of these outputs are expected to be non-zero because the projected point is on the opposite side of
// the pod from the originally computed point. I.e. there were multiple solutions and the original point
// is not the closest intersection point. We could offset those points in the +Y direction instead of -Y.
for( int i = 0 ; i < n ; i++ )
{
Print( i, false );
Print( "U delta ", false );
Print( uvec[i] - uoutv[i], false );
Print( "W delta ", false );
Print( wvec[i] - woutv[i] );
}
// Whichever intersection was found, it has to be a real one: the reported
// coordinates have to name a point on the surface, and that point has to
// sit on the same Y ray the test point was offset along.
for( int i = 0 ; i < n ; i++ )
{
if ( uoutv[i] < 0.0 || woutv[i] < 0.0 )
{
Print( "ERROR: no intersection was found for point " + i );
__failure++;
}
else
{
vec3d hit = CompPnt01( geom_id, surf_indx, uoutv[i], woutv[i] );
if ( !closeTo( hit.x(), ptvec[i].x(), 1e-6 ) || !closeTo( hit.z(), ptvec[i].z(), 1e-6 ) )
{
Print( "ERROR: the intersection left the Y ray at point " + i );
__failure++;
}
if ( !closeTo( doutv[i], abs( hit.y() - ptvec[i].y() ), 1e-6 ) )
{
Print( "ERROR: the wrong distance was reported at point " + i );
__failure++;
}
}
}
double y() const
Definition Vec3d.h:477
double x() const
Definition Vec3d.h:440
double z() const
Definition Vec3d.h:514
void AxisProjVecPnt01(const std::string &geom_id, const int &surf_indx, const int &iaxis, const std::vector< vec3d > &pts, std::vector< double > &u_out_vec, std::vector< double > &w_out_vec, std::vector< double > &d_out_vec)
std::vector< vec3d > CompVecPnt01(const std::string &geom_id, const int &surf_indx, const std::vector< double > &u_in_vec, const std::vector< double > &w_in_vec)
See also
AxisProjPnt01, AxisProjPnt01Guess, AxisProjPnt01I, AxisProjVecPnt01Guess
Parameters
[in]geom_idstring Geom ID
[in]surf_indxint Main surface index from the Geom
[in]iaxisint Axis direction to project point along (X_DIR, Y_DIR, or Z_DIR)
[in]ptsvector<vec3d> Input vector of 3D coordinate points
[out]u_out_vecvector<double> Output vector of the closest U (0 - 1) surface coordinate for each 3D input point
[out]w_out_vecvector<double> Output vector of the closest W (0 - 1) surface coordinate for each 3D input point
[out]d_out_vecvector<double> Output vector of axis distances for each 3D point and the projected point of the surface

◆ AxisProjVecPnt01Guess()

void vsp::AxisProjVecPnt01Guess ( const std::string & geom_id,
const int & surf_indx,
const int & iaxis,
const std::vector< vec3d > & pts,
const std::vector< double > & u0s,
const std::vector< double > & w0s,
std::vector< double > & u_out_vec,
std::vector< double > & w_out_vec,
std::vector< double > & d_out_vec )
extern

Project an input array of 3D coordinate points onto a surface along a specified axis given initial guess arrays of surface parameter. If the axis-aligned ray from the point intersects the surface multiple times, the nearest intersection is returned. If the axis-aligned ray from the point does not intersect the surface, the original point is returned and -1 is returned in the other output parameters. The surface parameter guess should allow this call to be faster than calling AxisProjVecPnt01 without a guess.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
int n = 5;
array<double> uvec, wvec;
uvec.resize( n );
wvec.resize( n );
for( int i = 0 ; i < n ; i++ )
{
uvec[i] = (i+1)*1.0/(n+1);
wvec[i] = (n-i)*1.0/(n+1);
}
array< vec3d > ptvec = CompVecPnt01( geom_id, surf_indx, uvec, wvec );
for( int i = 0 ; i < n ; i++ )
{
ptvec[i].offset_y( -5.0 );
}
array<double> uoutv, woutv, doutv, u0v, w0v;
u0v.resize( n );
w0v.resize( n );
for( int i = 0 ; i < n ; i++ )
{
u0v[i] = uvec[i] + 0.01234;
w0v[i] = wvec[i] - 0.05678;
}
AxisProjVecPnt01Guess( geom_id, surf_indx, Y_DIR, ptvec, u0v, w0v, uoutv, woutv, doutv );
for( int i = 0 ; i < n ; i++ )
{
Print( i, false );
Print( "U delta ", false );
Print( uvec[i] - uoutv[i], false );
Print( "W delta ", false );
Print( wvec[i] - woutv[i] );
}
// Whichever intersection was found, it has to be a real one: the reported
// coordinates have to name a point on the surface, and that point has to
// sit on the same Y ray the test point was offset along.
for( int i = 0 ; i < n ; i++ )
{
if ( uoutv[i] < 0.0 || woutv[i] < 0.0 )
{
Print( "ERROR: no intersection was found for point " + i );
__failure++;
}
else
{
vec3d hit = CompPnt01( geom_id, surf_indx, uoutv[i], woutv[i] );
if ( !closeTo( hit.x(), ptvec[i].x(), 1e-6 ) || !closeTo( hit.z(), ptvec[i].z(), 1e-6 ) )
{
Print( "ERROR: the intersection left the Y ray at point " + i );
__failure++;
}
if ( !closeTo( doutv[i], abs( hit.y() - ptvec[i].y() ), 1e-6 ) )
{
Print( "ERROR: the wrong distance was reported at point " + i );
__failure++;
}
}
}
void AxisProjVecPnt01Guess(const std::string &geom_id, const int &surf_indx, const int &iaxis, const std::vector< vec3d > &pts, const std::vector< double > &u0s, const std::vector< double > &w0s, std::vector< double > &u_out_vec, std::vector< double > &w_out_vec, std::vector< double > &d_out_vec)
See also
AxisProjPnt01, AxisProjPnt01Guess, AxisProjPnt01I, AxisProjVecPnt01
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]iaxisint Axis direction to project point along (X_DIR, Y_DIR, or Z_DIR)
[in]ptsvector<vec3d> Input vector of 3D coordinate points
[in]u0svector<double> Input vector of U (0 - 1) surface coordinate guesses
[in]w0svector<double> Input vector of W (0 - 1) surface coordinate guesses
[out]u_out_vecvector<double> Output vector of the closest U (0 - 1) surface coordinate for each 3D input point
[out]w_out_vecvector<double> Output vector of the closest W (0 - 1) surface coordinate for each 3D input point
[out]d_out_vecvector<double> Output vector of axis distances for each 3D point and the projected point of the surface

◆ CompCurvature01()

void vsp::CompCurvature01 ( const std::string & geom_id,
const int & surf_indx,
const double & u,
const double & w,
double & k1_out,
double & k2_out,
double & ka_out,
double & kg_out )
extern

Determine the curvature of a specified surface at the input surface coordinate point

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
double k1, k2, ka, kg;
double u, w;
u = 0.25;
w = 0.75;
CompCurvature01( geom_id, surf_indx, u, w, k1, k2, ka, kg );
Print( "Curvature : k1 " + k1 + " k2 " + k2 + " ka " + ka + " kg " + kg );
// The mean curvature is the average of the principal curvatures, and the
// Gaussian curvature is their product.
if ( !closeTo( ka, 0.5 * ( k1 + k2 ), 1e-9 ) )
{
Print( "ERROR: the mean curvature does not match the principal curvatures" );
__failure++;
}
if ( !closeTo( kg, k1 * k2, 1e-9 ) )
{
Print( "ERROR: the Gaussian curvature does not match the principal curvatures" );
__failure++;
}
// A Pod is convex everywhere, so the Gaussian curvature is positive.
if ( kg <= 0.0 )
{
Print( "ERROR: a Pod should be convex here" );
__failure++;
}
void CompCurvature01(const std::string &geom_id, const int &surf_indx, const double &u, const double &w, double &k1_out, double &k2_out, double &ka_out, double &kg_out)
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]udouble U (0 - 1) surface coordinate
[in]wdouble W (0 - 1) surface coordinate
[out]k1_outdouble Output value of maximum principal curvature
[out]k2_outdouble Output value of minimum principal curvature
[out]ka_outdouble Output value of mean curvature
[out]kg_outdouble Output value of Gaussian curvature

◆ CompNorm01()

vec3d vsp::CompNorm01 ( const std::string & geom_id,
const int & surf_indx,
const double & u,
const double & w )
extern

Calculate the normal vector on the specified surface at input surface coordinate

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
double u = 0.12345;
double w = 0.67890;
vec3d norm = CompNorm01( geom_id, surf_indx, u, w );
if ( !closeTo( norm.mag(), 1.0, 1e-9 ) )
{
Print( "ERROR: CompNorm01 is not a unit vector" );
__failure++;
}
Print( "Point: ( " + norm.x() + ', ' + norm.y() + ', ' + norm.z() + ' )' );
double mag() const
vec3d CompNorm01(const std::string &geom_id, const int &surf_indx, const double &u, const double &w)
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]udouble U (0 - 1) surface coordinate
[in]wdouble W (0 - 1) surface coordinate
Returns
vec3d Normal vector

◆ CompPnt01()

vec3d vsp::CompPnt01 ( const std::string & geom_id,
const int & surf_indx,
const double & u,
const double & w )
extern

Calculate the 3D coordinate equivalent for the input surface coordinate point

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
double u = 0.12345;
double w = 0.67890;
vec3d pnt = CompPnt01( geom_id, surf_indx, u, w );
Print( "Point: ( " + pnt.x() + ', ' + pnt.y() + ', ' + pnt.z() + ' )' );
// The point is on the surface, so projecting it back has to land on it and
// recover the coordinates it came from.
double u_out, w_out;
double d = ProjPnt01( geom_id, surf_indx, pnt, u_out, w_out );
if ( d > 1e-6 )
{
Print( "ERROR: CompPnt01 returned a point off the surface" );
__failure++;
}
if ( !closeTo( u_out, u, 1e-6 ) || !closeTo( w_out, w, 1e-6 ) )
{
Print( "ERROR: CompPnt01 does not round trip through ProjPnt01" );
__failure++;
}
// W wraps around the section, so 0 and 1 are the same place.
if ( dist( CompPnt01( geom_id, surf_indx, u, 0.0 ), CompPnt01( geom_id, surf_indx, u, 1.0 ) ) > 1e-6 )
{
Print( "ERROR: the surface does not close in W" );
__failure++;
}
double ProjPnt01(const std::string &geom_id, const int &surf_indx, const vec3d &pt, double &u_out, double &w_out)
double dist(const vec3d &a, const vec3d &b)
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]udouble U (0 - 1) surface coordinate
[in]wdouble W (0 - 1) surface coordinate
Returns
vec3d Normal vector3D coordinate point

◆ CompPntRST()

vec3d vsp::CompPntRST ( const std::string & geom_id,
const int & surf_indx,
const double & r,
const double & s,
const double & t )
extern

Calculate the (X, Y, Z) coordinate for the input volume (R, S, T) coordinate point

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
double r = 0.12;
double s = 0.68;
double t = 0.56;
vec3d pnt = CompPntRST( geom_id, surf_indx, r, s, t );
Print( "Point: ( " + pnt.x() + ', ' + pnt.y() + ', ' + pnt.z() + ' )' );
// T runs from the interior out to the skin, so t = 1 lands on the surface
// and anything short of that lands inside it.
double u_out, w_out;
if ( ProjPnt01( geom_id, surf_indx, CompPntRST( geom_id, surf_indx, r, s, 1.0 ), u_out, w_out ) > 1e-6 )
{
Print( "ERROR: CompPntRST at t = 1 is not on the surface" );
__failure++;
}
if ( !InsideSurf( geom_id, surf_indx, pnt ) )
{
Print( "ERROR: CompPntRST at t < 1 is not inside the surface" );
__failure++;
}
// The point has to round trip back through the coordinates it came from.
double r_out, s_out, t_out;
FindRST( geom_id, surf_indx, pnt, r_out, s_out, t_out );
if ( dist( CompPntRST( geom_id, surf_indx, r_out, s_out, t_out ), pnt ) > 1e-6 )
{
Print( "ERROR: CompPntRST does not round trip through FindRST" );
__failure++;
}
vec3d CompPntRST(const std::string &geom_id, const int &surf_indx, const double &r, const double &s, const double &t)
bool InsideSurf(const std::string &geom_id, const int &surf_indx, const vec3d &pt)
double FindRST(const std::string &geom_id, const int &surf_indx, const vec3d &pt, double &r_out, double &s_out, double &t_out)
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]rdouble R (0 - 1) volume coordinate
[in]sdouble S (0 - 1) volume coordinate
[in]tdouble T (0 - 1) volume coordinate
Returns
vec3d coordinate point

◆ CompTanU01()

vec3d vsp::CompTanU01 ( const std::string & geom_id,
const int & surf_indx,
const double & u,
const double & w )
extern

Calculate the vector tangent to the specified surface at input surface coordinate in the U direction

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
double u = 0.12345;
double w = 0.67890;
vec3d tanu = CompTanU01( geom_id, surf_indx, u, w );
if ( tanu.mag() <= 0.0 )
{
Print( "ERROR: CompTanU01 is degenerate" );
__failure++;
}
Print( "Point: ( " + tanu.x() + ', ' + tanu.y() + ', ' + tanu.z() + ' )' );
vec3d CompTanU01(const std::string &geom_id, const int &surf_indx, const double &u, const double &w)
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]udouble U (0 - 1) surface coordinate
[in]wdouble W (0 - 1) surface coordinate
Returns
vec3d Tangent vector in U direction

◆ CompTanW01()

vec3d vsp::CompTanW01 ( const std::string & geom_id,
const int & surf_indx,
const double & u,
const double & w )
extern

Calculate the vector tangent to the specified surface at input surface coordinate in the W direction

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
double u = 0.12345;
double w = 0.67890;
vec3d tanw = CompTanW01( geom_id, surf_indx, u, w );
if ( tanw.mag() <= 0.0 )
{
Print( "ERROR: CompTanW01 is degenerate" );
__failure++;
}
Print( "Point: ( " + tanw.x() + ', ' + tanw.y() + ', ' + tanw.z() + ' )' );
vec3d CompTanW01(const std::string &geom_id, const int &surf_indx, const double &u, const double &w)
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]udouble U (0 - 1) surface coordinate
[in]wdouble W (0 - 1) surface coordinate
Returns
vec3d Tangent vector in W direction

◆ CompVecCurvature01()

void vsp::CompVecCurvature01 ( const std::string & geom_id,
const int & surf_indx,
const std::vector< double > & us,
const std::vector< double > & ws,
std::vector< double > & k1_out_vec,
std::vector< double > & k2_out_vec,
std::vector< double > & ka_out_vec,
std::vector< double > & kg_out_vec )
extern

Determine the curvature of a specified surface at each surface coordinate point in the input arrays

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int n = 5;
array<double> uvec, wvec;
uvec.resize( n );
wvec.resize( n );
for( int i = 0 ; i < n ; i++ )
{
uvec[i] = (i+1)*1.0/(n+1);
wvec[i] = (n-i)*1.0/(n+1);
}
array<double> k1vec, k2vec, kavec, kgvec;
CompVecCurvature01( geom_id, 0, uvec, wvec, k1vec, k2vec, kavec, kgvec );
// One value per coordinate pair, matching what the scalar form gives, and
// holding the same relationships between the four curvatures.
if ( int( k1vec.size() ) != n || int( k2vec.size() ) != n ||
int( kavec.size() ) != n || int( kgvec.size() ) != n )
{
Print( "ERROR: CompVecCurvature01 returned the wrong number of values" );
__failure++;
}
else
{
for ( int i = 0 ; i < n ; i++ )
{
double k1, k2, ka, kg;
CompCurvature01( geom_id, 0, uvec[i], wvec[i], k1, k2, ka, kg );
if ( !closeTo( k1vec[i], k1, 1e-9 ) || !closeTo( k2vec[i], k2, 1e-9 ) ||
!closeTo( kavec[i], ka, 1e-9 ) || !closeTo( kgvec[i], kg, 1e-9 ) )
{
Print( "ERROR: CompVecCurvature01 disagrees with CompCurvature01 at " + i );
__failure++;
}
if ( !closeTo( kavec[i], 0.5 * ( k1vec[i] + k2vec[i] ), 1e-9 ) ||
!closeTo( kgvec[i], k1vec[i] * k2vec[i], 1e-9 ) )
{
Print( "ERROR: the curvatures are inconsistent at " + i );
__failure++;
}
}
}
void CompVecCurvature01(const std::string &geom_id, const int &surf_indx, const std::vector< double > &us, const std::vector< double > &ws, std::vector< double > &k1_out_vec, std::vector< double > &k2_out_vec, std::vector< double > &ka_out_vec, std::vector< double > &kg_out_vec)
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]usvector<double> Input vector of U (0 - 1) surface coordinates
[in]wsvector<double> Input vector of W (0 - 1) surface coordinates
[out]k1_out_vecvector<double> Output vector of maximum principal curvatures
[out]k2_out_vecvector<double> Output vector of minimum principal curvatures
[out]ka_out_vecvector<double> Output vector of mean curvatures
[out]kg_out_vecvector<double> Output vector of Gaussian curvatures

◆ CompVecDegenPnt01()

std::vector< vec3d > vsp::CompVecDegenPnt01 ( const std::string & geom_id,
const int & surf_indx,
const int & degen_type,
const std::vector< double > & u_in_vec,
const std::vector< double > & w_in_vec )
extern

Determine 3D coordinate for each degen surface coordinate point in the input arrays

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int n = 5;
array<double> uvec, wvec;
uvec.resize( n );
wvec.resize( n );
for( int i = 0 ; i < n ; i++ )
{
uvec[i] = (i+1)*1.0/(n+1);
wvec[i] = (n-i)*1.0/(n+1);
}
array< vec3d > ptvec = CompVecDegenPnt01( geom_id, 0, 0, uvec, wvec );
// One point per coordinate pair. Degen type 0 is the surface itself, so
// those points are the ones the surface form gives.
if ( int( ptvec.size() ) != n )
{
Print( "ERROR: CompVecDegenPnt01 returned the wrong number of points" );
__failure++;
}
else
{
array< vec3d > surfvec = CompVecPnt01( geom_id, 0, uvec, wvec );
for ( int i = 0 ; i < n ; i++ )
{
if ( dist( ptvec[i], surfvec[i] ) > 1e-6 )
{
Print( "ERROR: the degen surface does not follow the surface at " + i );
__failure++;
}
}
}
std::vector< vec3d > CompVecDegenPnt01(const std::string &geom_id, const int &surf_indx, const int &degen_type, const std::vector< double > &u_in_vec, const std::vector< double > &w_in_vec)
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]degen_typeint Type of degen surface (0-S, 1-V, 2-H, 3-C)
[in]u_in_vecvector<double> Input vector of U (0 - 1) surface coordinates
[in]w_in_vecvector<double> Input vector of W (0 - 1) surface coordinates
Returns
vector<vec3d> Vector of 3D coordinate points

◆ CompVecNorm01()

std::vector< vec3d > vsp::CompVecNorm01 ( const std::string & geom_id,
const int & surf_indx,
const std::vector< double > & us,
const std::vector< double > & ws )
extern

Determine the normal vector on a surface for each surface coordinate point in the input arrays

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int n = 5;
array<double> uvec, wvec;
uvec.resize( n );
wvec.resize( n );
for( int i = 0 ; i < n ; i++ )
{
uvec[i] = (i+1)*1.0/(n+1);
wvec[i] = (n-i)*1.0/(n+1);
}
array< vec3d > normvec = CompVecNorm01( geom_id, 0, uvec, wvec );
for( int i = 0 ; i < int( normvec.length() ) ; i++ )
{
if ( !closeTo( normvec[i].mag(), 1.0, 1e-9 ) )
{
Print( "ERROR: CompVecNorm01 entry " + i + " is not a unit vector" );
__failure++;
}
}
std::vector< vec3d > CompVecNorm01(const std::string &geom_id, const int &surf_indx, const std::vector< double > &us, const std::vector< double > &ws)
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]usvector<double> Input vector of U (0 - 1) surface coordinates
[in]wsvector<double> Input vector of W (0 - 1) surface coordinates
Returns
vector<vec3d> Vector of 3D normal vectors

◆ CompVecPnt01()

std::vector< vec3d > vsp::CompVecPnt01 ( const std::string & geom_id,
const int & surf_indx,
const std::vector< double > & u_in_vec,
const std::vector< double > & w_in_vec )
extern

Determine 3D coordinate for each surface coordinate point in the input arrays

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int n = 5;
array<double> uvec, wvec;
uvec.resize( n );
wvec.resize( n );
for( int i = 0 ; i < n ; i++ )
{
uvec[i] = (i+1)*1.0/(n+1);
wvec[i] = (n-i)*1.0/(n+1);
}
array< vec3d > ptvec = CompVecPnt01( geom_id, 0, uvec, wvec );
// One point per coordinate pair, each the same point the scalar form gives.
if ( int( ptvec.size() ) != n )
{
Print( "ERROR: CompVecPnt01 returned the wrong number of points" );
__failure++;
}
else
{
for ( int i = 0 ; i < n ; i++ )
{
if ( dist( ptvec[i], CompPnt01( geom_id, 0, uvec[i], wvec[i] ) ) > 1e-9 )
{
Print( "ERROR: CompVecPnt01 disagrees with CompPnt01 at " + i );
__failure++;
}
}
}
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]u_in_vecvector<double> Input vector of U (0 - 1) surface coordinates
[in]w_in_vecvector<double> Input vector of W (0 - 1) surface coordinates
Returns
vector<vec3d> Vector of 3D coordinate points

◆ CompVecPntRST()

std::vector< vec3d > vsp::CompVecPntRST ( const std::string & geom_id,
const int & surf_indx,
const std::vector< double > & r_in_vec,
const std::vector< double > & s_in_vec,
const std::vector< double > & t_in_vec )
extern

Determine 3D coordinate for each volume coordinate point in the input arrays

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int n = 5;
array<double> rvec, svec, tvec;
rvec.resize( n );
svec.resize( n );
tvec.resize( n );
for( int i = 0 ; i < n ; i++ )
{
rvec[i] = (i+1)*1.0/(n+1);
svec[i] = (n-i)*1.0/(n+1);
tvec[i] = (i+1)*1.0/(n+1);
}
array< vec3d > ptvec = CompVecPntRST( geom_id, 0, rvec, svec, tvec );
// One point per coordinate triple, each the same point the scalar form
// gives, and every one of them inside the surface.
if ( int( ptvec.size() ) != n )
{
Print( "ERROR: CompVecPntRST returned the wrong number of points" );
__failure++;
}
else
{
for( int i = 0 ; i < n ; i++ )
{
if ( dist( ptvec[i], CompPntRST( geom_id, 0, rvec[i], svec[i], tvec[i] ) ) > 1e-9 )
{
Print( "ERROR: CompVecPntRST disagrees with CompPntRST at " + i );
__failure++;
}
if ( !InsideSurf( geom_id, 0, ptvec[i] ) )
{
Print( "ERROR: CompVecPntRST returned a point outside the surface at " + i );
__failure++;
}
}
}
std::vector< vec3d > CompVecPntRST(const std::string &geom_id, const int &surf_indx, const std::vector< double > &r_in_vec, const std::vector< double > &s_in_vec, const std::vector< double > &t_in_vec)
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]r_in_vecvector<double> Input vector of R (0 - 1.0) volume coordinates
[in]s_in_vecvector<double> Input vector of S (0 - 1.0) volume coordinates
[in]t_in_vecvector<double> Input vector of T (0 - 1.0) volume coordinates
Returns
vector<vec3d> Vector of 3D coordinate points

◆ ConvertEtatoU()

void vsp::ConvertEtatoU ( const std::string & geom_id,
const double & eta,
double & u_out )
extern

Convert eta wing coordinate to u coordinate.

// Add Wing Geom
string geom_id = AddGeom( "WING", "" );
int surf_indx = 0;
double eta= 0.25;
double u_out;
ConvertEtatoU( geom_id, eta, u_out );
// Converting back has to return the coordinate we started from.
double eta_back;
ConvertUtoEta( geom_id, u_out, eta_back );
if ( !closeTo( eta_back, eta, 1e-6 ) )
{
Print( "ERROR: ConvertEtatoU does not round trip" );
__failure++;
}
void ConvertUtoEta(const std::string &geom_id, const double &u, double &eta_out)
void ConvertEtatoU(const std::string &geom_id, const double &eta, double &u_out)
Parameters
[in]geom_idstring Parent Geom ID
[in]etadouble Eta (0 - 1) wing spanwise coordinate
[out]u_outdouble U (0 - 1) surface coordinate

◆ ConvertLMNtoRST()

void vsp::ConvertLMNtoRST ( const std::string & geom_id,
const int & surf_indx,
const double & l,
const double & m,
const double & n,
double & r_out,
double & s_out,
double & t_out )
extern

Convert LMN volumetric coordinates to RST coordinates.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
double l = 0.12;
double m = 0.34;
double n = 0.56;
double r_out, s_out, t_out;
ConvertLMNtoRST( geom_id, surf_indx, l, m, n, r_out, s_out, t_out );
// The conversion is invertible, so going back has to return the input.
double l_out, m_out, n_out;
ConvertRSTtoLMN( geom_id, surf_indx, r_out, s_out, t_out, l_out, m_out, n_out );
if ( !closeTo( l_out, l, 1e-6 ) || !closeTo( m_out, m, 1e-6 ) || !closeTo( n_out, n, 1e-6 ) )
{
Print( "ERROR: ConvertLMNtoRST does not invert" );
__failure++;
}
// Both coordinate systems run over the unit cube.
if ( r_out < 0.0 || r_out > 1.0 || s_out < 0.0 || s_out > 1.0 || t_out < 0.0 || t_out > 1.0 )
{
Print( "ERROR: ConvertLMNtoRST left the unit cube" );
__failure++;
}
// The coordinates name a point in the volume, so evaluating them has to
// land inside the surface.
if ( !InsideSurf( geom_id, surf_indx, CompPntRST( geom_id, surf_indx, r_out, s_out, t_out ) ) )
{
Print( "ERROR: ConvertLMNtoRST did not name a point in the volume" );
__failure++;
}
void ConvertLMNtoRST(const std::string &geom_id, const int &surf_indx, const double &l, const double &m, const double &n, double &r_out, double &s_out, double &t_out)
void ConvertRSTtoLMN(const std::string &geom_id, const int &surf_indx, const double &r, const double &s, const double &t, double &l_out, double &m_out, double &n_out)
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]ldouble L (0 - 1) linear volume coordinate
[in]mdouble M (0 - 1) linear volume coordinate
[in]ndouble N (0 - 1) linear volume coordinate
[out]r_outdouble R (0 - 1) volume coordinate
[out]s_outdouble S (0 - 1) volume coordinate
[out]t_outdouble T (0 - 1) volume coordinate

◆ ConvertLMNtoRSTVec()

void vsp::ConvertLMNtoRSTVec ( const std::string & geom_id,
const int & surf_indx,
const std::vector< double > & l_vec,
const std::vector< double > & m_vec,
const std::vector< double > & n_vec,
std::vector< double > & r_out_vec,
std::vector< double > & s_out_vec,
std::vector< double > & t_out_vec )
extern

Convert vector of LMN volumetric coordinates to RST coordinates.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int n = 5;
array<double> lvec, mvec, nvec;
lvec.resize( n );
mvec.resize( n );
nvec.resize( n );
for( int i = 0 ; i < n ; i++ )
{
lvec[i] = (i+1)*1.0/(n+1);
mvec[i] = (n-i)*1.0/(n+1);
nvec[i] = (i+1)*1.0/(n+1);
}
array<double> rvec, svec, tvec;
ConvertLMNtoRSTVec( geom_id, 0, lvec, mvec, nvec, rvec, svec, tvec );
// One triple out per triple in, each matching the scalar form, and the whole
// conversion invertible.
array<double> lback, mback, nback;
ConvertRSTtoLMNVec( geom_id, 0, rvec, svec, tvec, lback, mback, nback );
if ( int( rvec.size() ) != n || int( svec.size() ) != n || int( tvec.size() ) != n )
{
Print( "ERROR: ConvertLMNtoRSTVec returned the wrong number of values" );
__failure++;
}
else
{
for( int i = 0 ; i < n ; i++ )
{
double r_one, s_one, t_one;
ConvertLMNtoRST( geom_id, 0, lvec[i], mvec[i], nvec[i], r_one, s_one, t_one );
if ( !closeTo( rvec[i], r_one, 1e-9 ) || !closeTo( svec[i], s_one, 1e-9 ) || !closeTo( tvec[i], t_one, 1e-9 ) )
{
Print( "ERROR: ConvertLMNtoRSTVec disagrees with ConvertLMNtoRST at " + i );
__failure++;
}
if ( !closeTo( lback[i], lvec[i], 1e-6 ) || !closeTo( mback[i], mvec[i], 1e-6 ) || !closeTo( nback[i], nvec[i], 1e-6 ) )
{
Print( "ERROR: ConvertLMNtoRSTVec does not invert at " + i );
__failure++;
}
}
}
void ConvertLMNtoRSTVec(const std::string &geom_id, const int &surf_indx, const std::vector< double > &l_vec, const std::vector< double > &m_vec, const std::vector< double > &n_vec, std::vector< double > &r_out_vec, std::vector< double > &s_out_vec, std::vector< double > &t_out_vec)
void ConvertRSTtoLMNVec(const std::string &geom_id, const int &surf_indx, const std::vector< double > &r_vec, const std::vector< double > &s_vec, const std::vector< double > &t_vec, std::vector< double > &l_out_vec, std::vector< double > &m_out_vec, std::vector< double > &n_out_vec)
See also
ConvertRSTtoLMNVec, ConvertRSTtoLMN, ConvertLMNtoRST
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]l_vecvector<double> Input vector of L (0 - 1) linear volumetric coordinate
[in]m_vecvector<double> Input vector of M (0 - 1) linear volumetric coordinate
[in]n_vecvector<double> Input vector of N (0 - 1) linear volumetric coordinate
[out]r_out_vecvector<double> Output vector of R (0 - 1) volumetric coordinate
[out]s_out_vecvector<double> Output vector of S (0 - 1) volumetric coordinate
[out]t_out_vecvector<double> Output vector of T (0 - 1) volumetric coordinate

◆ ConvertLtoR()

void vsp::ConvertLtoR ( const std::string & geom_id,
const int & surf_indx,
const double & l,
double & r_out )
extern

Convert L volumetric coordinate to R coordinate.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
double l = 0.12;
double r_out;
ConvertLtoR( geom_id, surf_indx, l, r_out );
// The conversion is invertible, so going back has to return the input.
double l_out;
ConvertRtoL( geom_id, surf_indx, r_out, l_out );
if ( !closeTo( l_out, l, 1e-6 ) )
{
Print( "ERROR: ConvertLtoR does not invert" );
__failure++;
}
if ( r_out < 0.0 || r_out > 1.0 )
{
Print( "ERROR: ConvertLtoR left the unit interval" );
__failure++;
}
// Both coordinates run nose to tail, so the mapping is increasing.
double r_more;
ConvertLtoR( geom_id, surf_indx, l + 0.1, r_more );
if ( r_more <= r_out )
{
Print( "ERROR: ConvertLtoR is not increasing" );
__failure++;
}
void ConvertRtoL(const std::string &geom_id, const int &surf_indx, const double &r, double &l_out)
void ConvertLtoR(const std::string &geom_id, const int &surf_indx, const double &l, double &r_out)
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]ldouble L (0 - 1) volume coordinate
[out]r_outdouble R (0 - 1) linear volume coordinate

◆ ConvertRSTtoLMN()

void vsp::ConvertRSTtoLMN ( const std::string & geom_id,
const int & surf_indx,
const double & r,
const double & s,
const double & t,
double & l_out,
double & m_out,
double & n_out )
extern

Convert RST volumetric coordinates to LMN coordinates.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
double r = 0.12;
double s = 0.68;
double t = 0.56;
double l_out, m_out, n_out;
ConvertRSTtoLMN( geom_id, surf_indx, r, s, t, l_out, m_out, n_out );
// Converting back has to return the coordinates we started from.
double r_back, s_back, t_back;
ConvertLMNtoRST( geom_id, surf_indx, l_out, m_out, n_out, r_back, s_back, t_back );
if ( !closeTo( r_back, r, 1e-6 ) || !closeTo( s_back, s, 1e-6 ) || !closeTo( t_back, t, 1e-6 ) )
{
Print( "ERROR: ConvertRSTtoLMN does not round trip" );
__failure++;
}
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]rdouble R (0 - 1) volume coordinate
[in]sdouble S (0 - 1) volume coordinate
[in]tdouble T (0 - 1) volume coordinate
[out]l_outdouble L (0 - 1) linear volume coordinate
[out]m_outdouble M (0 - 1) linear volume coordinate
[out]n_outdouble N (0 - 1) linear volume coordinate

◆ ConvertRSTtoLMNVec()

void vsp::ConvertRSTtoLMNVec ( const std::string & geom_id,
const int & surf_indx,
const std::vector< double > & r_vec,
const std::vector< double > & s_vec,
const std::vector< double > & t_vec,
std::vector< double > & l_out_vec,
std::vector< double > & m_out_vec,
std::vector< double > & n_out_vec )
extern

Convert vector of RST volumetric coordinates to LMN coordinates.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int n = 5;
array<double> rvec, svec, tvec;
rvec.resize( n );
svec.resize( n );
tvec.resize( n );
for( int i = 0 ; i < n ; i++ )
{
rvec[i] = (i+1)*1.0/(n+1);
svec[i] = (n-i)*1.0/(n+1);
tvec[i] = (i+1)*1.0/(n+1);
}
array<double> lvec, mvec, nvec;
ConvertRSTtoLMNVec( geom_id, 0, rvec, svec, tvec, lvec, mvec, nvec );
// Converting back has to return the coordinates we started from.
array<double> rback, sback, tback;
ConvertLMNtoRSTVec( geom_id, 0, lvec, mvec, nvec, rback, sback, tback );
for( int i = 0 ; i < n ; i++ )
{
if ( !closeTo( rback[i], rvec[i], 1e-6 ) || !closeTo( sback[i], svec[i], 1e-6 ) || !closeTo( tback[i], tvec[i], 1e-6 ) )
{
Print( "ERROR: ConvertRSTtoLMNVec does not round trip at " + i );
__failure++;
}
}
See also
ConvertLMNtoRSTVec, ConvertRSTtoLMN, ConvertLMNtoRST
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]r_vecvector<double> Input vector of R (0 - 1) volumetric coordinate
[in]s_vecvector<double> Input vector of S (0 - 1) volumetric coordinate
[in]t_vecvector<double> Input vector of T (0 - 1) volumetric coordinate
[out]l_out_vecvector<double> Output vector of L (0 - 1) linear volumetric coordinate
[out]m_out_vecvector<double> Output vector of M (0 - 1) linear volumetric coordinate
[out]n_out_vecvector<double> Output vector of N (0 - 1) linear volumetric coordinate

◆ ConvertRtoL()

void vsp::ConvertRtoL ( const std::string & geom_id,
const int & surf_indx,
const double & r,
double & l_out )
extern

Convert R volumetric coordinate to L coordinate.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
double r = 0.12;
double l_out;
ConvertRtoL( geom_id, surf_indx, r, l_out );
// Converting back has to return the coordinate we started from.
double r_back;
ConvertLtoR( geom_id, surf_indx, l_out, r_back );
if ( !closeTo( r_back, r, 1e-6 ) )
{
Print( "ERROR: ConvertRtoL does not round trip" );
__failure++;
}
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]rdouble R (0 - 1) volume coordinate
[out]l_outdouble L (0 - 1) linear volume coordinate

◆ ConvertUtoEta()

void vsp::ConvertUtoEta ( const std::string & geom_id,
const double & u,
double & eta_out )
extern

Convert U coordinate to eta wing coordinate.

// Add Wing Geom
string geom_id = AddGeom( "WING", "" );
int surf_indx = 0;
// U runs from 1 to N+1 over an N section wing when the root end cap is on,
// so a U below 1 sits in the cap and does not map to a span station.
double u = 1.25;
double eta_out;
ConvertUtoEta( geom_id, u, eta_out );
// Converting back has to return the coordinate we started from.
double u_back;
ConvertEtatoU( geom_id, eta_out, u_back );
if ( !closeTo( u_back, u, 1e-6 ) )
{
Print( "ERROR: ConvertUtoEta does not round trip" );
__failure++;
}
Parameters
[in]geom_idstring Parent Geom ID
[in]udouble U (0 - 1) surface coordinate
[out]eta_outdouble Eta (0 - 1) wing spanwise coordinate

◆ FindRST()

double vsp::FindRST ( const std::string & geom_id,
const int & surf_indx,
const vec3d & pt,
double & r_out,
double & s_out,
double & t_out )
extern

Determine the nearest (R, S, T) volume coordinate for an input (X, Y, Z) 3D coordinate point and calculate the distance between the 3D point and the found volume point.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
double r = 0.12;
double s = 0.68;
double t = 0.56;
vec3d pnt = CompPntRST( geom_id, surf_indx, r, s, t );
double rout, sout, tout;
double d = FindRST( geom_id, surf_indx, pnt, rout, sout, tout );
Print( "Dist " + d + " r " + rout + " s " + sout + " t " + tout );
// pnt came from CompPntRST at r, s, t, so the search has to land back on it.
if ( !closeTo( d, 0.0, 1e-6 ) || !closeTo( rout, r, 1e-6 ) || !closeTo( sout, s, 1e-6 ) || !closeTo( tout, t, 1e-6 ) )
{
Print( "ERROR: FindRST did not recover the original r, s, t" );
__failure++;
}
See also
FindRSTGuess
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]ptvec3d Input 3D coordinate point
[out]r_outdouble Output closest R (0 - 1.0) volume coordinate
[out]s_outdouble Output closest S (0 - 1.0) volume coordinate
[out]t_outdouble Output closest T (0 - 1.0) volume coordinate
Returns
double Distance between the 3D point and the closest point of the volume

◆ FindRSTGuess()

double vsp::FindRSTGuess ( const std::string & geom_id,
const int & surf_indx,
const vec3d & pt,
const double & r0,
const double & s0,
const double & t0,
double & r_out,
double & s_out,
double & t_out )
extern

Determine the nearest (R, S, T) volume coordinate for an input (X, Y, Z) 3D coordinate point given an initial guess of volume coordinates. Also calculate the distance between the 3D point and the found volume point.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
double r = 0.12;
double s = 0.68;
double t = 0.56;
vec3d pnt = CompPntRST( geom_id, surf_indx, r, s, t );
double rout, sout, tout;
double r0 = 0.1;
double s0 = 0.6;
double t0 = 0.5;
double d = FindRSTGuess( geom_id, surf_indx, pnt, r0, s0, t0, rout, sout, tout );
Print( "Dist " + d + " r " + rout + " s " + sout + " t " + tout );
// pnt came from CompPntRST at r, s, t, so the search has to land back on it.
if ( !closeTo( d, 0.0, 1e-6 ) || !closeTo( rout, r, 1e-6 ) || !closeTo( sout, s, 1e-6 ) || !closeTo( tout, t, 1e-6 ) )
{
Print( "ERROR: FindRSTGuess did not recover the original r, s, t" );
__failure++;
}
double FindRSTGuess(const std::string &geom_id, const int &surf_indx, const vec3d &pt, const double &r0, const double &s0, const double &t0, double &r_out, double &s_out, double &t_out)
See also
FindRST
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]ptvec3d Input 3D coordinate point
[in]r0double Input R (0 - 1.0) volume coordinate guess
[in]s0double Input S (0 - 1.0) volume coordinate guess
[in]t0double Input T (0 - 1.0) volume coordinate guess
[out]r_outdouble Output closest R (0 - 1.0) volume coordinate
[out]s_outdouble Output closest S (0 - 1.0) volume coordinate
[out]t_outdouble Output closest T (0 - 1.0) volume coordinate
Returns
double Distance between the 3D point and the closest point of the volume

◆ FindRSTVec()

void vsp::FindRSTVec ( const std::string & geom_id,
const int & surf_indx,
const std::vector< vec3d > & pts,
std::vector< double > & r_out_vec,
std::vector< double > & s_out_vec,
std::vector< double > & t_out_vec,
std::vector< double > & d_out_vec )
extern

Determine the nearest volume coordinates for an input array of 3D coordinate points and calculate the distance between each 3D point and the found point in the volume.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int n = 5;
array<double> rvec, svec, tvec;
rvec.resize( n );
svec.resize( n );
tvec.resize( n );
for( int i = 0 ; i < n ; i++ )
{
rvec[i] = (i+1)*1.0/(n+1);
svec[i] = (n-i)*1.0/(n+1);
tvec[i] = (i+1)*1.0/(n+1);
}
array< vec3d > ptvec = CompVecPntRST( geom_id, 0, rvec, svec, tvec );
array<double> routv, soutv, toutv, doutv;
FindRSTVec( geom_id, 0, ptvec, routv, soutv, toutv, doutv );
// Every point came from CompVecPntRST, so each search lands back on its own.
for( int i = 0 ; i < n ; i++ )
{
if ( !closeTo( doutv[i], 0.0, 1e-6 ) || !closeTo( routv[i], rvec[i], 1e-6 ) ||
!closeTo( soutv[i], svec[i], 1e-6 ) || !closeTo( toutv[i], tvec[i], 1e-6 ) )
{
Print( "ERROR: FindRSTVec did not recover point " + i );
__failure++;
}
}
void FindRSTVec(const std::string &geom_id, const int &surf_indx, const std::vector< vec3d > &pts, std::vector< double > &r_out_vec, std::vector< double > &s_out_vec, std::vector< double > &t_out_vec, std::vector< double > &d_out_vec)
See also
FindRSTVecGuess
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]ptsvector<vec3d> Input vector of 3D coordinate points
[out]r_out_vecvector<double> Output vector of the closest R (0 - 1.0) volume coordinate for each 3D input point
[out]s_out_vecvector<double> Output vector of the closest S (0 - 1.0) volume coordinate for each 3D input point
[out]t_out_vecvector<double> Output vector of the closest T (0 - 1.0) volume coordinate for each 3D input point
[out]d_out_vecvector<double> Output vector of distances for each 3D point and the closest point of the volume

◆ FindRSTVecGuess()

void vsp::FindRSTVecGuess ( const std::string & geom_id,
const int & surf_indx,
const std::vector< vec3d > & pts,
const std::vector< double > & r0s,
const std::vector< double > & s0s,
const std::vector< double > & t0s,
std::vector< double > & r_out_vec,
std::vector< double > & s_out_vec,
std::vector< double > & t_out_vec,
std::vector< double > & d_out_vec )
extern

Determine the nearest volume coordinates for an input array of 3D coordinate points and calculate the distance between each 3D point and the closest point of the volume. This function takes an input array of volume coordinate guesses for each 3D coordinate, offering a potential decrease in computation time compared to FindRSTVec.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int n = 5;
array<double> rvec, svec, tvec;
rvec.resize( n );
svec.resize( n );
tvec.resize( n );
for( int i = 0 ; i < n ; i++ )
{
rvec[i] = (i+1)*1.0/(n+1);
svec[i] = (n-i)*1.0/(n+1);
tvec[i] = (i+1)*1.0/(n+1);
}
array< vec3d > ptvec = CompVecPntRST( geom_id, 0, rvec, svec, tvec );
array<double> routv, soutv, toutv, doutv;
for( int i = 0 ; i < n ; i++ )
{
ptvec[i] = ptvec[i] * 0.9;
}
FindRSTVecGuess( geom_id, 0, ptvec, rvec, svec, tvec, routv, soutv, toutv, doutv );
// The points above were scaled off the surface on purpose, so the search
// does not return to the original r, s, t. What must hold is that every
// point got an answer and that the reported distances are real.
if ( int( routv.length() ) != n || int( soutv.length() ) != n ||
int( toutv.length() ) != n || int( doutv.length() ) != n )
{
Print( "ERROR: FindRSTVecGuess returned the wrong number of results" );
__failure++;
}
for( int i = 0 ; i < int( doutv.length() ) ; i++ )
{
if ( doutv[i] < 0.0 )
{
Print( "ERROR: FindRSTVecGuess distance " + i + " is negative" );
__failure++;
}
}
void FindRSTVecGuess(const std::string &geom_id, const int &surf_indx, const std::vector< vec3d > &pts, const std::vector< double > &r0s, const std::vector< double > &s0s, const std::vector< double > &t0s, std::vector< double > &r_out_vec, std::vector< double > &s_out_vec, std::vector< double > &t_out_vec, std::vector< double > &d_out_vec)
See also
FindRSTVec,
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]ptsvector<vec3d> Input vector of 3D coordinate points
[in]r0svector<double> Input vector of U (0 - 1.0) volume coordinate guesses
[in]s0svector<double> Input vector of S (0 - 1.0) volume coordinate guesses
[in]t0svector<double> Input vector of T (0 - 1.0) volume coordinate guesses
[out]r_out_vecvector<double> Output vector of the closest R (0 - 1.0) volume coordinate for each 3D input point
[out]s_out_vecvector<double> Output vector of the closest S (0 - 1.0) volume coordinate for each 3D input point
[out]t_out_vecvector<double> Output vector of the closest T (0 - 1.0) volume coordinate for each 3D input point
[out]d_out_vecvector<double> Output vector of distances for each 3D point and the closest point of the volume

◆ GetUWTess01()

void vsp::GetUWTess01 ( const std::string & geom_id,
const int & surf_indx,
std::vector< double > & u_out_vec,
std::vector< double > & w_out_vec )
extern

Get the surface coordinate point of each intersection of the tessellated wireframe for a particular surface

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
array<double> utess, wtess;
GetUWTess01( geom_id, surf_indx, utess, wtess );
// The wireframe spans the whole surface and never runs backwards.
if ( utess.size() < 2 || wtess.size() < 2 )
{
Print( "ERROR: GetUWTess01 returned too few stations" );
__failure++;
}
else
{
if ( !closeTo( utess[0], 0.0, 1e-9 ) || !closeTo( utess[utess.size() - 1], 1.0, 1e-9 ) ||
!closeTo( wtess[0], 0.0, 1e-9 ) || !closeTo( wtess[wtess.size() - 1], 1.0, 1e-9 ) )
{
Print( "ERROR: GetUWTess01 does not span the surface" );
__failure++;
}
for ( int i = 1; i < int( utess.size() ); i++ )
{
if ( utess[i] <= utess[i - 1] )
{
Print( "ERROR: the U stations are not increasing at " + i );
__failure++;
}
}
for ( int i = 1; i < int( wtess.size() ); i++ )
{
if ( wtess[i] <= wtess[i - 1] )
{
Print( "ERROR: the W stations are not increasing at " + i );
__failure++;
}
}
}
void GetUWTess01(const std::string &geom_id, const int &surf_indx, std::vector< double > &u_out_vec, std::vector< double > &w_out_vec)
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[out]u_out_vecvector<double> Output vector of U (0 - 1) surface coordinates
[out]w_out_vecvector<double> Output vector of W (0 - 1) surface coordinates

◆ InsideSurf()

bool vsp::InsideSurf ( const std::string & geom_id,
const int & surf_indx,
const vec3d & pt )
extern

Test whether a given point is inside a specified surface.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
double r = 0.12;
double s = 0.68;
double t = 0.56;
vec3d pnt = CompPntRST( geom_id, surf_indx, r, s, t );
bool res = InsideSurf( geom_id, surf_indx, pnt );
// pnt was built by CompPntRST at r = 0.12, which is inside the surface.
if ( !res )
{
Print( "ERROR: InsideSurf says an interior point is outside" );
__failure++;
}
if ( res )
{
Print( "Inside" );
}
else
{
Print( "Outside" );
}
See also
VecInsideSurf
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]ptvec3d Input 3D coordinate point
Returns
bool Boolean true if the point is inside the surface, false otherwise.

◆ ProjPnt01()

double vsp::ProjPnt01 ( const std::string & geom_id,
const int & surf_indx,
const vec3d & pt,
double & u_out,
double & w_out )
extern

Determine the nearest surface coordinate for an input 3D coordinate point and calculate the distance between the 3D point and the closest point of the surface.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
double u = 0.12345;
double w = 0.67890;
vec3d pnt = CompPnt01( geom_id, surf_indx, u, w );
vec3d norm = CompNorm01( geom_id, surf_indx, u, w );
double uout, wout;
// Offset point from surface
pnt = pnt + norm;
double d = ProjPnt01( geom_id, surf_indx, pnt, uout, wout );
// pnt sits one unit off the surface along its own normal, so the
// projection comes back to where it started at a distance of one.
if ( !closeTo( d, 1.0, 1e-6 ) || !closeTo( uout, u, 1e-6 ) || !closeTo( wout, w, 1e-6 ) )
{
Print( "ERROR: ProjPnt01" );
__failure++;
}
Print( "Dist " + d + " u " + uout + " w " + wout );
See also
ProjPnt01Guess, ProjPnt01I
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]ptvec3d Input 3D coordinate point
[out]u_outdouble Output closest U (0 - 1) surface coordinate
[out]w_outdouble Output closest W (0 - 1) surface coordinate
Returns
double Distance between the 3D point and the closest point of the surface

◆ ProjPnt01Guess()

double vsp::ProjPnt01Guess ( const std::string & geom_id,
const int & surf_indx,
const vec3d & pt,
const double & u0,
const double & w0,
double & u_out,
double & w_out )
extern

Determine the nearest surface coordinate for an input 3D coordinate point and calculate the distance between the 3D point and the closest point of the surface. This function takes an input surface coordinate guess for, offering a potential decrease in computation time compared to ProjPnt01.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
double u = 0.12345;
double w = 0.67890;
double d = 0;
vec3d pnt = CompPnt01( geom_id, surf_indx, u, w );
vec3d norm = CompNorm01( geom_id, surf_indx, u, w );
double uout, wout;
// Offset point from surface
pnt = pnt + norm;
d = ProjPnt01Guess( geom_id, surf_indx, pnt, u + 0.1, w + 0.1, uout, wout );
// pnt sits one unit off the surface along its own normal, so the
// projection comes back to where it started at a distance of one.
if ( !closeTo( d, 1.0, 1e-6 ) || !closeTo( uout, u, 1e-6 ) || !closeTo( wout, w, 1e-6 ) )
{
Print( "ERROR: ProjPnt01Guess" );
__failure++;
}
Print( "Dist " + d + " u " + uout + " w " + wout );
double ProjPnt01Guess(const std::string &geom_id, const int &surf_indx, const vec3d &pt, const double &u0, const double &w0, double &u_out, double &w_out)
See also
ProjPnt01, ProjPnt01I
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]ptvec3d Input 3D coordinate point
[in]u0double Input U (0 - 1) surface coordinate guess
[in]w0double Input W (0 - 1) surface coordinate guess
[out]u_outdouble Output closest U (0 - 1) surface coordinate
[out]w_outdouble Output closest W (0 - 1) surface coordinate
Returns
double Distance between the 3D point and the closest point of the surface

◆ ProjPnt01I()

double vsp::ProjPnt01I ( const std::string & geom_id,
const vec3d & pt,
int & surf_indx_out,
double & u_out,
double & w_out )
extern

Determine the nearest surface coordinate and corresponding parent Geom main surface index for an input 3D coordinate point. Return the distance between the closest point and the input.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
double u = 0.12345;
double w = 0.67890;
double d = 0;
vec3d pnt = CompPnt01( geom_id, surf_indx, u, w );
vec3d norm = CompNorm01( geom_id, surf_indx, u, w );
double uout, wout;
int surf_indx_out;
// Offset point from surface
pnt = pnt + norm;
d = ProjPnt01I( geom_id, pnt, surf_indx_out, uout, wout );
// pnt sits one unit off the surface along its own normal, so the
// projection comes back to where it started at a distance of one.
if ( !closeTo( d, 1.0, 1e-6 ) || !closeTo( uout, u, 1e-6 ) || !closeTo( wout, w, 1e-6 ) )
{
Print( "ERROR: ProjPnt01I" );
__failure++;
}
Print( "Dist " + d + " u " + uout + " w " + wout + " surf_index " + surf_indx_out );
double ProjPnt01I(const std::string &geom_id, const vec3d &pt, int &surf_indx_out, double &u_out, double &w_out)
See also
ProjPnt01, ProjPnt01Guess
Parameters
[in]geom_idstring Parent Geom ID
[in]ptvec3d Input 3D coordinate point
[out]surf_indx_outint Output main surface index from the parent Geom
[out]u_outdouble Output closest U (0 - 1) surface coordinat
[out]w_outdouble Output closest W (0 - 1) surface coordinat
Returns
double Distance between the 3D point and the closest point of the surface

◆ ProjVecPnt01()

void vsp::ProjVecPnt01 ( const std::string & geom_id,
const int & surf_indx,
const std::vector< vec3d > & pts,
std::vector< double > & u_out_vec,
std::vector< double > & w_out_vec,
std::vector< double > & d_out_vec )
extern

Determine the nearest surface coordinates for an input array of 3D coordinate points and calculate the distance between each 3D point and the closest point of the surface.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int n = 5;
array<double> uvec, wvec;
uvec.resize( n );
wvec.resize( n );
for( int i = 0 ; i < n ; i++ )
{
uvec[i] = (i+1)*1.0/(n+1);
wvec[i] = (n-i)*1.0/(n+1);
}
array< vec3d > ptvec = CompVecPnt01( geom_id, 0, uvec, wvec );
array< vec3d > normvec = CompVecNorm01( geom_id, 0, uvec, wvec );
for( int i = 0 ; i < n ; i++ )
{
ptvec[i] = ptvec[i] + normvec[i];
}
array<double> uoutv, woutv, doutv;
ProjVecPnt01( geom_id, 0, ptvec, uoutv, woutv, doutv );
// Each point was pushed one unit along its own normal, so each projects
// back to where it came from at a distance of one.
for( int i = 0 ; i < n ; i++ )
{
if ( !closeTo( doutv[i], 1.0, 1e-6 ) || !closeTo( uoutv[i], uvec[i], 1e-6 ) || !closeTo( woutv[i], wvec[i], 1e-6 ) )
{
Print( "ERROR: ProjVecPnt01 did not recover point " + i );
__failure++;
}
}
void ProjVecPnt01(const std::string &geom_id, const int &surf_indx, const std::vector< vec3d > &pts, std::vector< double > &u_out_vec, std::vector< double > &w_out_vec, std::vector< double > &d_out_vec)
See also
ProjVecPnt01Guess
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]ptsvector<vec3d> Input vector of 3D coordinate points
[out]u_out_vecvector<double> Output vector of the closest U (0 - 1) surface coordinate for each 3D input point
[out]w_out_vecvector<double> Output vector of the closest W (0 - 1) surface coordinate for each 3D input point
[out]d_out_vecvector<double> Output vector of distances for each 3D point and the closest point of the surface

◆ ProjVecPnt01Guess()

void vsp::ProjVecPnt01Guess ( const std::string & geom_id,
const int & surf_indx,
const std::vector< vec3d > & pts,
const std::vector< double > & u0s,
const std::vector< double > & w0s,
std::vector< double > & u_out_vec,
std::vector< double > & w_out_vec,
std::vector< double > & d_out_vec )
extern

Determine the nearest surface coordinates for an input array of 3D coordinate points and calculate the distance between each 3D point and the closest point of the surface. This function takes an input array of surface coordinate guesses for each 3D coordinate, offering a potential decrease in computation time compared to ProjVecPnt01.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int n = 5;
array<double> uvec, wvec;
uvec.resize( n );
wvec.resize( n );
for( int i = 0 ; i < n ; i++ )
{
uvec[i] = (i+1)*1.0/(n+1);
wvec[i] = (n-i)*1.0/(n+1);
}
array< vec3d > ptvec = CompVecPnt01( geom_id, 0, uvec, wvec );
array< vec3d > normvec = CompVecNorm01( geom_id, 0, uvec, wvec );
for( int i = 0 ; i < n ; i++ )
{
ptvec[i] = ptvec[i] + normvec[i];
}
array<double> uoutv, woutv, doutv, u0v, w0v;
u0v.resize( n );
w0v.resize( n );
for( int i = 0 ; i < n ; i++ )
{
u0v[i] = uvec[i] + 0.01234;
w0v[i] = wvec[i] - 0.05678;
}
ProjVecPnt01Guess( geom_id, 0, ptvec, u0v, w0v, uoutv, woutv, doutv );
// Each point was pushed one unit along its own normal, so each projects back
// to where it came from at a distance of one. Starting from a guess must
// not change that.
array<double> uv_ng, wv_ng, dv_ng;
ProjVecPnt01( geom_id, 0, ptvec, uv_ng, wv_ng, dv_ng );
for( int i = 0 ; i < n ; i++ )
{
if ( !closeTo( doutv[i], 1.0, 1e-6 ) ||
!closeTo( uoutv[i], uvec[i], 1e-6 ) ||
!closeTo( woutv[i], wvec[i], 1e-6 ) )
{
Print( "ERROR: ProjVecPnt01Guess did not recover point " + i );
__failure++;
}
if ( !closeTo( uoutv[i], uv_ng[i], 1e-6 ) ||
!closeTo( woutv[i], wv_ng[i], 1e-6 ) ||
!closeTo( doutv[i], dv_ng[i], 1e-6 ) )
{
Print( "ERROR: the guess changed the answer at " + i );
__failure++;
}
}
void ProjVecPnt01Guess(const std::string &geom_id, const int &surf_indx, const std::vector< vec3d > &pts, const std::vector< double > &u0s, const std::vector< double > &w0s, std::vector< double > &u_out_vec, std::vector< double > &w_out_vec, std::vector< double > &d_out_vec)
See also
ProjVecPnt01,
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]ptsvector<vec3d> Input vector of 3D coordinate points
[in]u0svector<double> Input vector of U (0 - 1) surface coordinate guesses
[in]w0svector<double> Input vector of W (0 - 1) surface coordinate guesses
[out]u_out_vecvector<double> Output vector of the closest U (0 - 1) surface coordinate for each 3D input point
[out]w_out_vecvector<double> Output vector of the closest W (0 - 1) surface coordinate for each 3D input point
[out]d_out_vecvector<double> Output array of distances for each 3D point and the closest point of the surface

◆ VecInsideSurf()

std::vector< bool > vsp::VecInsideSurf ( const std::string & geom_id,
const int & surf_indx,
const std::vector< vec3d > & pts )
extern

Test whether a vector of points are inside a specified surface.

// Add Pod Geom
string geom_id = AddGeom( "POD", "" );
int surf_indx = 0;
int n = 5;
array<double> rvec, svec, tvec;
rvec.resize( n );
svec.resize( n );
tvec.resize( n );
for( int i = 0 ; i < n ; i++ )
{
rvec[i] = (i+1)*1.0/(n+1);
svec[i] = (n-i)*1.0/(n+1);
tvec[i] = (i+1)*1.0/(n+1);
}
array< vec3d > ptvec = CompVecPntRST( geom_id, 0, rvec, svec, tvec );
array<bool> res;
res = VecInsideSurf( geom_id, surf_indx, ptvec );
// Every point came from CompVecPntRST with r below one, so all are inside.
for( int i = 0 ; i < int( res.length() ) ; i++ )
{
if ( !res[i] )
{
Print( "ERROR: VecInsideSurf says interior point " + i + " is outside" );
__failure++;
}
}
std::vector< bool > VecInsideSurf(const std::string &geom_id, const int &surf_indx, const std::vector< vec3d > &pts)
See also
VecInsideSurf
Parameters
[in]geom_idstring Parent Geom ID
[in]surf_indxint Main surface index from the parent Geom
[in]ptsvector<vec3d> Input vector of 3D coordinate points
Returns
vector <bool> Boolean vector for each point. True if it is inside the surface, false otherwise.