OpenVSP API Documentation 3.51.3
Loading...
Searching...
No Matches
Group Modification Functions

The functions in this group allow for sets to be scaled, rotated, and translated. Click here to return to the main page. More...

Functions

void vsp::ScaleSet (int set_index, double scale)
void vsp::RotateSet (int set_index, double x_rot_deg, double y_rot_deg, double z_rot_deg)
void vsp::TranslateSet (int set_index, const vec3d &translation_vec)
void vsp::TransformSet (int set_index, const vec3d &translation_vec, double x_rot_deg, double y_rot_deg, double z_rot_deg, double scale, bool scale_translations_flag)

Detailed Description

Function Documentation

◆ RotateSet()

void vsp::RotateSet ( int set_index,
double x_rot_deg,
double y_rot_deg,
double z_rot_deg )
extern

Rotate a set about the global X, Y, and Z axes

// Add Fuselage Geom
string fuseid = AddGeom( "FUSELAGE" );
SetSetFlag( fuseid, 3, true );
vec3d before_max = GetGeomBBoxMax( fuseid, 0, true );
vec3d before_min = GetGeomBBoxMin( fuseid, 0, true );
// Rotate 90 degrees about Y
RotateSet( 3, 0, 90, 0 );
vec3d after_max = GetGeomBBoxMax( fuseid, 0, true );
vec3d after_min = GetGeomBBoxMin( fuseid, 0, true );
// Turning the Geom on its nose trades the X extent for the Z extent.
if ( !closeTo( after_max.z() - after_min.z(), before_max.x() - before_min.x(), 1e-6 ) ||
!closeTo( after_max.x() - after_min.x(), before_max.z() - before_min.z(), 1e-6 ) )
{
Print( "ERROR: RotateSet did not rotate the geometry" );
__failure++;
}
Definition Vec3d.h:243
double x() const
Definition Vec3d.h:440
double z() const
Definition Vec3d.h:514
vec3d GetGeomBBoxMax(const std::string &geom_id, int main_surf_ind=0, bool ref_frame_is_absolute=true)
std::string AddGeom(const std::string &type, const std::string &parent=std::string())
vec3d GetGeomBBoxMin(const std::string &geom_id, int main_surf_ind=0, bool ref_frame_is_absolute=true)
void RotateSet(int set_index, double x_rot_deg, double y_rot_deg, double z_rot_deg)
void SetSetFlag(const std::string &geom_id, int set_index, bool flag)
void Update(bool update_managers=true)
Parameters
[in]set_indexint Set index
[in]x_rot_degdouble Rotation about the X axis (degrees)
[in]y_rot_degdouble Rotation about the Y axis (degrees)
[in]z_rot_degdouble Rotation about the Z axis (degrees)

◆ ScaleSet()

void vsp::ScaleSet ( int set_index,
double scale )
extern

Apply a scale factor to a set

// Add Fuselage Geom
string fuseid = AddGeom( "FUSELAGE" );
SetSetFlag( fuseid, 3, true );
// Scale by a factor of 2
vec3d before_max = GetGeomBBoxMax( fuseid, 0, false );
vec3d before_min = GetGeomBBoxMin( fuseid, 0, false );
ScaleSet( 3, 2.0 );
vec3d after_max = GetGeomBBoxMax( fuseid, 0, false );
vec3d after_min = GetGeomBBoxMin( fuseid, 0, false );
if ( !closeTo( after_max.x() - after_min.x(), 2.0 * ( before_max.x() - before_min.x() ), 1e-6 ) )
{
Print( "ERROR: ScaleSet did not double the extent" );
__failure++;
}
void ScaleSet(int set_index, double scale)
Parameters
[in]set_indexint Set index
[in]scaledouble Scale factor

◆ TransformSet()

void vsp::TransformSet ( int set_index,
const vec3d & translation_vec,
double x_rot_deg,
double y_rot_deg,
double z_rot_deg,
double scale,
bool scale_translations_flag )
extern

Apply translation, rotation, and scale transformations to a set

// Add Fuselage Geom
string fuseid = AddGeom( "FUSELAGE" );
SetSetFlag( fuseid, 3, true );
vec3d before_max = GetGeomBBoxMax( fuseid, 0, true );
vec3d before_min = GetGeomBBoxMin( fuseid, 0, true );
// Translate 2 units in X and 3 units in Y, rotate 90 degrees about Y, and scale by a factor of 2
TransformSet( 3, vec3d( 2, 3, 0 ), 0, 90, 0, 2.0, true );
vec3d after_max = GetGeomBBoxMax( fuseid, 0, true );
vec3d after_min = GetGeomBBoxMin( fuseid, 0, true );
// Turning the Geom on its nose trades the X extent for the Z, and the scale
// doubles both.
if ( !closeTo( after_max.z() - after_min.z(), 2.0 * ( before_max.x() - before_min.x() ), 1e-6 ) ||
!closeTo( after_max.x() - after_min.x(), 2.0 * ( before_max.z() - before_min.z() ), 1e-6 ) )
{
Print( "ERROR: TransformSet did not rotate and scale the geometry" );
__failure++;
}
// The Y extent only scales, and the whole thing moves three units out in Y.
if ( !closeTo( after_max.y() - after_min.y(), 2.0 * ( before_max.y() - before_min.y() ), 1e-6 ) )
{
Print( "ERROR: TransformSet did not scale the geometry in Y" );
__failure++;
}
double y() const
Definition Vec3d.h:477
void TransformSet(int set_index, const vec3d &translation_vec, double x_rot_deg, double y_rot_deg, double z_rot_deg, double scale, bool scale_translations_flag)
See also
TranslateSet, RotateSet, ScaleSet
Parameters
[in]set_indexint Set index
[in]translation_vecvec3d Translation vector
[in]x_rot_degdouble Rotation about the X axis (degrees)
[in]y_rot_degdouble Rotation about the Y axis (degrees)
[in]z_rot_degdouble Rotation about the Z axis (degrees)
[in]scaledouble Scale factor
[in]scale_translations_flagbool Flag to apply the scale factor to translations

◆ TranslateSet()

void vsp::TranslateSet ( int set_index,
const vec3d & translation_vec )
extern

Translate a set along a given vector

// Add Fuselage Geom
string fuseid = AddGeom( "FUSELAGE" );
SetSetFlag( fuseid, 3, true );
// Translate 2 units in X and 3 units in Y
// The bounding box has to be asked for in the absolute frame. A body frame
// box travels with the Geom, so it would not see the translation at all.
vec3d before_min = GetGeomBBoxMin( fuseid, 0, true );
TranslateSet( 3, vec3d( 2, 3, 0 ) );
vec3d after_min = GetGeomBBoxMin( fuseid, 0, true );
if ( !closeTo( after_min.x() - before_min.x(), 2.0, 1e-6 ) || !closeTo( after_min.y() - before_min.y(), 3.0, 1e-6 ) )
{
Print( "ERROR: TranslateSet did not move the geometry" );
__failure++;
}
void TranslateSet(int set_index, const vec3d &translation_vec)
Parameters
[in]set_indexint Set index
[in]translation_vecvec3d Translation vector