Group Modification Functions

The functions in this group allow for sets to be scaled, rotated, and translated.

ScaleSet(set_index, scale)

Apply a scale factor to a set

RotateSet(set_index, x_rot_deg, y_rot_deg, ...)

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

TranslateSet(set_index, translation_vec)

Translate a set along a given vector

TransformSet(set_index, translation_vec, ...)

Apply translation, rotation, and scale transformations to a set

Details

openvsp.ScaleSet(set_index, scale)[source]

Apply a scale factor to a set

# Add Fuselage Geom
fuseid = AddGeom( "FUSELAGE" )

SetSetFlag( fuseid, 3, True )

# Scale by a factor of 2
Update()

before_max = GetGeomBBoxMax( fuseid, 0, False )
before_min = GetGeomBBoxMin( fuseid, 0, False )

ScaleSet( 3, 2.0 )

Update()

after_max = GetGeomBBoxMax( fuseid, 0, False )
after_min = GetGeomBBoxMin( fuseid, 0, False )

assert abs( ( after_max.x() - after_min.x() ) - 2.0 * ( before_max.x() - before_min.x() ) ) < 1e-6, "ScaleSet did not double the extent"
Parameters:
  • [in] – set_index int Set index

  • [in] – scale double Scale factor

openvsp.RotateSet(set_index, x_rot_deg, y_rot_deg, z_rot_deg)[source]

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

# Add Fuselage Geom
fuseid = AddGeom( "FUSELAGE" )

SetSetFlag( fuseid, 3, True )

Update()

before_max = GetGeomBBoxMax( fuseid, 0, True )
before_min = GetGeomBBoxMin( fuseid, 0, True )

# Rotate 90 degrees about Y
RotateSet( 3, 0, 90, 0 )

Update()

after_max = GetGeomBBoxMax( fuseid, 0, True )
after_min = GetGeomBBoxMin( fuseid, 0, True )

# Turning the Geom on its nose trades the X extent for the Z extent.
assert abs( ( after_max.z() - after_min.z() ) - ( before_max.x() - before_min.x() ) ) < 1e-6, "RotateSet did not rotate the geometry"
assert abs( ( after_max.x() - after_min.x() ) - ( before_max.z() - before_min.z() ) ) < 1e-6, "RotateSet did not rotate the geometry"
Parameters:
  • [in] – set_index int Set index

  • [in] – x_rot_deg double Rotation about the X axis (degrees)

  • [in] – y_rot_deg double Rotation about the Y axis (degrees)

  • [in] – z_rot_deg double Rotation about the Z axis (degrees)

openvsp.TranslateSet(set_index, translation_vec)[source]

Translate a set along a given vector

# Add Fuselage Geom
fuseid = AddGeom( "FUSELAGE" )

SetSetFlag( fuseid, 3, True )

# Translate 2 units in X and 3 units in Y
Update()

# 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.
before_min = GetGeomBBoxMin( fuseid, 0, True )

TranslateSet( 3, vec3d( 2, 3, 0 ) )

Update()

after_min = GetGeomBBoxMin( fuseid, 0, True )

assert abs( ( after_min.x() - before_min.x() ) - 2.0 ) < 1e-6 and abs( ( after_min.y() - before_min.y() ) - 3.0 ) < 1e-6, "TranslateSet did not move the geometry"
Parameters:
  • [in] – set_index int Set index

  • [in] – translation_vec vec3d Translation vector

openvsp.TransformSet(set_index, translation_vec, x_rot_deg, y_rot_deg, z_rot_deg, scale, scale_translations_flag)[source]

Apply translation, rotation, and scale transformations to a set

# Add Fuselage Geom
fuseid = AddGeom( "FUSELAGE" )

SetSetFlag( fuseid, 3, True )

Update()

before_max = GetGeomBBoxMax( fuseid, 0, True )
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 )

Update()

after_max = GetGeomBBoxMax( fuseid, 0, True )
after_min = GetGeomBBoxMin( fuseid, 0, True )

# Turning the Geom on its nose trades the X extent for the Z, and the scale
# doubles both.
assert abs( ( after_max.z() - after_min.z() ) - 2.0 * ( before_max.x() - before_min.x() ) ) < 1e-6, "TransformSet did not rotate and scale the geometry"
assert abs( ( after_max.x() - after_min.x() ) - 2.0 * ( before_max.z() - before_min.z() ) ) < 1e-6, "TransformSet did not rotate and scale the geometry"

# The Y extent only scales.
assert abs( ( after_max.y() - after_min.y() ) - 2.0 * ( before_max.y() - before_min.y() ) ) < 1e-6, "TransformSet did not scale the geometry in Y"

See also: TranslateSet, RotateSet, ScaleSet :param [in]: set_index int Set index :param [in]: translation_vec vec3d Translation vector :param [in]: x_rot_deg double Rotation about the X axis (degrees) :param [in]: y_rot_deg double Rotation about the Y axis (degrees) :param [in]: z_rot_deg double Rotation about the Z axis (degrees) :param [in]: scale double Scale factor :param [in]: scale_translations_flag bool Flag to apply the scale factor to translations