Workspace 6.21.5
Public Types | Public Member Functions | List of all members
SuperquadricMesher Class Reference

Creates a mesh for a superquadric. More...

#include <Rendering/SceneComponents/Models/superquadricmesher.h>

Public Types

enum  TextureCoords { NoTextureCoords , Natural , Spherical }
 

Public Member Functions

 SuperquadricMesher (const QString &sStateName="textureS", const QString &tStateName="textureT")
 
 ~SuperquadricMesher ()
 
void meshSuperquadric (double e, double n, int subdivisions, const Mesh::Vector3d &radius, TextureCoords textureCoordType, Mesh::MeshModel &model)
 

Detailed Description

Create a mesh of a supequadric satisyfing the implicit equation

[(x/r.x)^(2/e) + (y/r.y)^(2/e)]^(e/n) + (z/r.z)^(2/n) = 1

where (r.x,r.y,r.z) is the radius of the superquadric and the values 0 < e and 0 < n are the east-west and north-south shape parameters respectively. This range of shape parameters describes star-like shapes (for e,n > 1), a sphere (for e = n = 1) and convex shapes (for e,n < 1) such as those used in DEM simulations.

The algorithm is such that the vertices of the resultant mesh are automatically concentrated near regions of high curvature.

Member Enumeration Documentation

◆ TextureCoords

Specifies the method to use for assigning texture co-ordinates to the superquadric mesh nodes.

Enumerator
NoTextureCoords 

Don't generate texture co-ordinates.

Natural 

Texture co-ordinates follow the theta/phi angles used to generate the mesh nodes. This preserves the parallel property of horizontal and vertical lines but distorts the texture image to be contracted in areas of higher curvature and stretch in flatter areas.

Spherical 

Texture co-ordinates are obtained using a spherical projection for each of the points. When the superquadric powers are such that the superquadric degenerates to a sphere, this will yield the same texture co-ordinates as the Natural method. Otherwise, vertical and horizontal parallel lines will lose their parallel property, but distortions will be more evenly distributed across the image rather than being concentrated at areas of high and low curvature.

Constructor & Destructor Documentation

◆ SuperquadricMesher()

SuperquadricMesher ( const QString &  sStateName = "textureS",
const QString &  tStateName = "textureT" 
)
Parameters
sStateNameThe name of the node state for the s texture co-ordinate.
tStateNameThe name of the node state for the t texture co-ordinate.

◆ ~SuperquadricMesher()

Member Function Documentation

◆ meshSuperquadric()

void meshSuperquadric ( double  e,
double  n,
int  subdivisions,
const Mesh::Vector3d radius,
TextureCoords  textureCoordType,
Mesh::MeshModel model 
)
Parameters
eThe superquadric power parameter related to the co-ordinate around the equator (which we refer to as theta in some parts of this documentation).
nThe superquadric power parameter related to the vertical co-ordinate (which we refer to as phi in some parts of this documentation).
subdivisionsThe number of rows/columns of elements in one quadrant, which is the same meaning as used for the sphere glypher.
radiusThe scaling in each of the three axis directions.
textureCoordTypeThis specifies how the texture co-ordinates are to be computed. Using a value of Spherical will result in more evenly spaced texture co-ordinates at the expense of slight distortion of horizontal and vertical lines that originally appeared parallel in the texture image. On the other hand, if this parameter is Natural, then the texture co-ordinates will be the same as the theta/phi co-ordinates used to generate the superquadric. This will preserve parallel horizontal and vertical lines, but the texture image will still suffer distortion. Texture co-ordinates will be more closely spaced in regions of higher curvature using Natural.
modelThis will hold the superquadric model upon exit. Any previous contents will be discarded and all existing node and element states will be removed. Upon exit, node states for the texture co-ordinates will have been set. The names of these node states are set in the constructor.

Superquadric formulae used:

x(theta,phi) = radius.x (cos phi)^n (cos theta)^e y(theta,phi) = radius.y (cos phi)^n (sin theta)^e z(theta,phi) = radius.z (sin phi)^n

where the powers are understood as a^p = sign(a) |a|^p and the parameters have the following ranges:

  0 <= theta <= 2*pi

-pi/2 <= phi <= pi/2

For reference, the POVray documentation specifies the full superquadric formula as a superellipsoid and at time of writing this can be found at:

http://www.povray.org/documentation/view/3.6.1/285/