NetDEM v1.0
Loading...
Searching...
No Matches
netdem::PolySuperQuadrics Class Reference

A class representing a poly superquadric with three different axes and orders. More...

#include <shape_poly_super_quadrics.hpp>

Inheritance diagram for netdem::PolySuperQuadrics:
netdem::Shape

Public Member Functions

 PolySuperQuadrics ()
 Default constructor.
 
 PolySuperQuadrics (double am, double ap, double bm, double bp, double cm, double cp, double nam, double nap, double nbm, double nbp, double ncm, double ncp)
 Constructor that sets the size and order parameters of the PolySuperQuadrics object.
 
ShapeClone () const override
 Clone the PolySuperQuadrics object.
 
nlohmann::json PackJson () override
 Pack the PolySuperQuadrics object into a JSON structure.
 
void InitFromJson (nlohmann::json const &js) override
 Initialize the PolySuperQuadrics object from a JSON structure.
 
void Init ()
 Initialize the PolySuperQuadrics object.
 
void UpdateSurfaceNodes () override
 Update surface nodes of the PolySuperQuadrics object.
 
void UpdateShapeProperties () override
 Update the shape properties of the PolySuperQuadrics object.
 
void SetSize (double d) override
 Set the size of the PolySuperQuadrics object.
 
STLModel GetSTLModel (int num_nodes=200) override
 Generate an STL model for the PolySuperQuadrics object.
 
Vec3d SupportPoint (Vec3d const &dir) override
 Compute the support point of the PolySuperQuadrics object in a given direction.
 
VecXT< Vec3dSupportPoints (Vec3d const &dir) override
 Compute the support points of the PolySuperQuadrics object in a given direction.
 
double SignedDistance (Vec3d const &pos) const override
 Compute the signed distance from a given position to the surface of the PolySuperQuadrics object.
 
Vec3d SurfacePoint (Vec3d const &pos) override
 Compute the surface point on the PolySuperQuadrics object closest to a given position.
 
Vec3d ParametrizationPoint (Vec3d const &dir)
 Compute the parameterization point on the PolySuperQuadrics object in a given direction.
 
void Print () override
 Print information about the PolySuperQuadrics object.
 
- Public Member Functions inherited from netdem::Shape
virtual void InitFromJsonFile (std::string const &js_file)
 Initializes the shape instance from a JSON file.
 
virtual double GetSize () const
 Return shape size, which is defined as the diameter of equal-volume sphere.
 
virtual double GetVolume () const
 Return the volume of the shape.
 
virtual Mat3d const & GetInertia () const
 Return the inertia of the shape.
 
Vec3d GetInertiaPrincipal () const
 Return the principal inertia of the shape.
 
virtual double GetBoundSphereRadius () const
 Return the inertia of the shape.
 
virtual std::tuple< Vec3d, Vec3dGetBoundAABB () const
 Gets the boundary AABB of the shape instance.
 
virtual std::tuple< Vec3d, Vec3dGetBoundAABB (Vec3d const &pos, Vec4d const &quat) const
 Gets the boundary AABB of the shape instance.
 
virtual double GetSkin () const
 Return skin size of the shape.
 
virtual double GetSkinFactor () const
 Return skin factor of the shape.
 
virtual double GetSurfaceNodeNum () const
 Return number of surface nodes of the shape.
 
virtual VecXT< Vec3d > const & GetSurfaceNodes () const
 Return surface nodes of the shape.
 
virtual VecXT< double > const & GetSurfaceNodeAreas () const
 Return surface area associated with each surface node.
 
virtual double GetSurfaceNodeSpacing () const
 Return spacing of surface nodes.
 
const STLModelGetRenderMesh () const
 Return the surface mesh for rendering.
 
bool CheckConvexity ()
 Return the convexity of the shape.
 
virtual void Translate (Vec3d const &pos)
 Translates the shape instance to a new position.
 
virtual void UpdateRenderMesh (int num_nodes=200)
 Initializes the surface mesh for rendering.
 
virtual void SetSkin (double sk)
 Set skin size of the shape.
 
virtual void SetSkinFactor (double sk_factor)
 Set skin size factor (skin = size by skin size factor) of the shape.
 
virtual void EnableSurfaceNodes ()
 Enable the use of surface nodes.
 
virtual void DisableSurfaceNodes ()
 Disable the use of surface nodes.
 
virtual bool IsSurfaceNodesEnabled ()
 Check if the use of surface nodes is enabled.
 
virtual void SetSurfaceNodeNum (int num)
 Set number of surface nodes of the shape.
 
virtual void SetSurfaceNodes (VecXT< Vec3d > const &nodes)
 Set the surface nodes of the shape.
 
virtual void SetSurfaceNodes (STLModel const &surf_stl)
 Set the surface nodes of the shape.
 
virtual void SaveAsVTK (std::string const &filename)
 Saves the shape instance as a VTK file.
 
virtual void SaveAsSTL (std::string const &filename)
 Saves the shape instance as an STL file.
 
virtual bool CheckEnclose (Vec3d const &pos) const
 Determines whether a given point is enclosed within the shape instance.
 
virtual bool CheckPrincipal () const
 Determines whether the shape is in principal configuration.
 
virtual ~Shape ()
 Destructor for the Shape class.
 

Public Attributes

Vec2d axis_a {0.5, 0.5}
 
Vec2d axis_b {0.5, 0.5}
 
Vec2d axis_c {0.5, 0.5}
 
Vec2d order_a {1.0, 1.0}
 
Vec2d order_b {1.0, 1.0}
 
Vec2d order_c {1.0, 1.0}
 
Vec3d pos_ref {0, 0, 0}
 
Vec4d quat_ref {1, 0, 0, 0}
 
Vec4d quat_conj {1, 0, 0, 0}
 
- Public Attributes inherited from netdem::Shape
int id {0}
 ID of the shape instance.
 
std::string label {"default"}
 Label of the shape instance.
 
Type shape_type {Type::none}
 Type of the shape instance.
 
std::string shape_name {"shape"}
 Name of the shape instance.
 
bool use_customized_solver {false}
 Determines whether to use a customized contact solver or not.
 
STLModel render_mesh
 Surface mesh for rendering.
 

Additional Inherited Members

- Public Types inherited from netdem::Shape
enum  Type {
  none , point_sphere , sphere , spherical_harmonics ,
  trimesh , trimesh_convex , ellipsoid , polybezier ,
  triangle , plane , cylinder , poly_super_ellipsoid ,
  poly_super_quadrics , level_set , netsdf , coded_netsdf ,
  num_shapes
}
 Enumeration for different types of shapes. More...
 
- Static Public Member Functions inherited from netdem::Shape
static MatNd< 8, 3 > VerticesOfAABB (Vec3d const &bmin, Vec3d const &bmax)
 Gets the vertices of the boundary AABB of the shape instance.
 
- Protected Attributes inherited from netdem::Shape
double size {1.0}
 Size and volume of the shape instance.
 
double volume {0.5236}
 Volume of the shape instance.
 
Mat3d inertia {{{0.05236, 0, 0}, {0, 0.05236, 0}, {0, 0, 0.05236}}}
 Inertia tensor of the shape instance.
 
double bound_sphere_radius {0.5}
 Radius of the bounding sphere used for broad-phase contact detection.
 
double skin {0.025}
 Skin thickness used for broad-phase contact detection.
 
double skin_factor {0.05}
 Factor used to adjust the skin thickness.
 
Vec3d bound_aabb_min {-0.5, -0.5, -0.5}
 Minimum bounds of the AABB used for broad-phase contact detection.
 
Vec3d bound_aabb_max {0.5, 0.5, 0.5}
 Maximum bounds of the AABB used for broad-phase contact detection.
 
bool is_convex {true}
 Determines whether the shape instance is convex or not.
 
bool use_surface_nodes {false}
 Determines whether to use nodes for the contact solver.
 
int surface_node_num {1000}
 Number of nodes used for the contact solver.
 
double surface_node_spacing {std::sqrt(Math::PI / 1000.0)}
 Spacing between nodes used for the contact solver.
 
VecXT< Vec3dsurface_nodes
 Surface nodes of the shape instance used for the contact solver.
 
VecXT< double > surface_node_areas
 Area associated with each surface node.
 

Detailed Description

A class representing a poly superquadric with three different axes and orders.

This class provides methods for setting and updating the position of the PolySuperQuadrics object, computing its surface properties, generating STL models for visualization, and calculating signed distances and surface points.

Additionally, the PolySuperQuadrics class is a subclass of the Shape class, which allows it to be used in combination with other shapes in compound objects.

The poly superquadric is defined by the following equation:

( x / axis_a )^( 2 / order_a ) + ( y / axis_b )^( 2 / order_b ) + ( z / axis_c )^( 2 / order_c ) = 1

where m and p indicate minus and plus to guarantee convexity. The order should be in (0, 2).

Examples
00_sdf_demo.cpp, 1_gjk_solver.cpp, 2_sdf_solver.cpp, and 90_packing_demo.cpp.

Constructor & Destructor Documentation

◆ PolySuperQuadrics() [1/2]

PolySuperQuadrics::PolySuperQuadrics ( )

Default constructor.

◆ PolySuperQuadrics() [2/2]

PolySuperQuadrics::PolySuperQuadrics ( double am,
double ap,
double bm,
double bp,
double cm,
double cp,
double nam,
double nap,
double nbm,
double nbp,
double ncm,
double ncp )

Constructor that sets the size and order parameters of the PolySuperQuadrics object.

Parameters
amThe minus value of the x-axis scaling factor.
apThe plus value of the x-axis scaling factor.
bmThe minus value of the y-axis scaling factor.
bpThe plus value of the y-axis scaling factor.
cmThe minus value of the z-axis scaling factor.
cpThe plus value of the z-axis scaling factor.
namThe minus value of the x-axis order parameter.
napThe plus value of the x-axis order parameter.
nbmThe minus value of the y-axis order parameter.
nbpThe plus value of the y-axis order parameter.
ncmThe minus value of the z-axis order parameter.
ncpThe plus value of the z-axis order parameter.

Member Function Documentation

◆ Clone()

Shape * PolySuperQuadrics::Clone ( ) const
overridevirtual

Clone the PolySuperQuadrics object.

This method creates a copy of the PolySuperQuadrics object.

Returns
A pointer to the cloned PolySuperQuadrics object.

Reimplemented from netdem::Shape.

◆ GetSTLModel()

STLModel PolySuperQuadrics::GetSTLModel ( int num_nodes = 200)
overridevirtual

Generate an STL model for the PolySuperQuadrics object.

This method generates an STLModel object representing the PolySuperQuadrics object with the specified number of nodes for each surface triangle.

Parameters
num_nodesThe number of nodes to use for each surface triangle (default: 200).
Returns
An STLModel object representing the PolySuperQuadrics object.

Reimplemented from netdem::Shape.

◆ Init()

void PolySuperQuadrics::Init ( )

Initialize the PolySuperQuadrics object.

This method initializes the PolySuperQuadrics object by updating its nodes and shape properties.

◆ InitFromJson()

void PolySuperQuadrics::InitFromJson ( nlohmann::json const & js)
overridevirtual

Initialize the PolySuperQuadrics object from a JSON structure.

This method initializes the PolySuperQuadrics object from a JSON structure previously generated by PackJson().

Parameters
jsThe JSON structure to load.

Reimplemented from netdem::Shape.

◆ PackJson()

nlohmann::json PolySuperQuadrics::PackJson ( )
overridevirtual

Pack the PolySuperQuadrics object into a JSON structure.

This method packs the PolySuperQuadrics object into a JSON structure for serialization and storage.

Returns
The packed JSON structure.

Reimplemented from netdem::Shape.

◆ ParametrizationPoint()

Vec3d PolySuperQuadrics::ParametrizationPoint ( Vec3d const & dir)

Compute the parameterization point on the PolySuperQuadrics object in a given direction.

This method computes the parameterization point on the PolySuperQuadrics object in a given direction.

Parameters
dirThe direction in which to compute the parameterization point.
Returns
The parameterization point on the PolySuperQuadrics object in the specified direction.

◆ Print()

void PolySuperQuadrics::Print ( )
overridevirtual

Print information about the PolySuperQuadrics object.

This method prints basic information about the PolySuperQuadrics object, including its position, rotation, size, volume, and surface area.

Reimplemented from netdem::Shape.

◆ SetSize()

void PolySuperQuadrics::SetSize ( double d)
overridevirtual

Set the size of the PolySuperQuadrics object.

This method sets the size of the PolySuperQuadrics object by updating its axis and order parameters.

Parameters
dThe new size for the PolySuperQuadrics object.

Reimplemented from netdem::Shape.

Examples
1_gjk_solver.cpp, 2_sdf_solver.cpp, and 90_packing_demo.cpp.

◆ SignedDistance()

double PolySuperQuadrics::SignedDistance ( Vec3d const & pos) const
overridevirtual

Compute the signed distance from a given position to the surface of the PolySuperQuadrics object.

This method computes the signed distance from a given position to the surface of the PolySuperQuadrics object using its center point and scaling factors.

Parameters
posThe position for which to compute the signed distance.
Returns
The signed distance from the specified position to the surface of the PolySuperQuadrics object.

Reimplemented from netdem::Shape.

◆ SupportPoint()

Vec3d PolySuperQuadrics::SupportPoint ( Vec3d const & dir)
overridevirtual

Compute the support point of the PolySuperQuadrics object in a given direction.

This method computes the support point of the PolySuperQuadrics object in a given direction, which is the point on the surface farthest in the specified direction.

Parameters
dirThe direction in which to compute the support point.
Returns
The support point of the PolySuperQuadrics object in the specified direction.

Reimplemented from netdem::Shape.

◆ SupportPoints()

VecXT< Vec3d > PolySuperQuadrics::SupportPoints ( Vec3d const & dir)
overridevirtual

Compute the support points of the PolySuperQuadrics object in a given direction.

This method computes the support points of the PolySuperQuadrics object in a given direction, which are two opposite points on the surface farthest along the specified direction.

Parameters
dirThe direction in which to compute the support points.
Returns
A vector containing the two support points of the PolySuperQuadrics object in the specified direction.

Reimplemented from netdem::Shape.

◆ SurfacePoint()

Vec3d PolySuperQuadrics::SurfacePoint ( Vec3d const & pos)
overridevirtual

Compute the surface point on the PolySuperQuadrics object closest to a given position.

This method computes the surface point on the PolySuperQuadrics object closest to a given position by finding the point on the surface that has the minimum distance to the specified position.

Parameters
posThe position for which to compute the closest surface point.
Returns
The surface point on the PolySuperQuadrics object closest to the specified position.

Reimplemented from netdem::Shape.

◆ UpdateShapeProperties()

void PolySuperQuadrics::UpdateShapeProperties ( )
overridevirtual

Update the shape properties of the PolySuperQuadrics object.

This method updates the shape properties of the PolySuperQuadrics object, such as its volume and surface area.

Reimplemented from netdem::Shape.

◆ UpdateSurfaceNodes()

void PolySuperQuadrics::UpdateSurfaceNodes ( )
overridevirtual

Update surface nodes of the PolySuperQuadrics object.

This method updates the surface nodes of the PolySuperQuadrics object based on its current position and rotation.

Reimplemented from netdem::Shape.

Member Data Documentation

◆ axis_a

Vec2d netdem::PolySuperQuadrics::axis_a {0.5, 0.5}

◆ axis_b

Vec2d netdem::PolySuperQuadrics::axis_b {0.5, 0.5}

◆ axis_c

Vec2d netdem::PolySuperQuadrics::axis_c {0.5, 0.5}

◆ order_a

Vec2d netdem::PolySuperQuadrics::order_a {1.0, 1.0}

◆ order_b

Vec2d netdem::PolySuperQuadrics::order_b {1.0, 1.0}

◆ order_c

Vec2d netdem::PolySuperQuadrics::order_c {1.0, 1.0}

◆ pos_ref

Vec3d netdem::PolySuperQuadrics::pos_ref {0, 0, 0}

◆ quat_conj

Vec4d netdem::PolySuperQuadrics::quat_conj {1, 0, 0, 0}

◆ quat_ref

Vec4d netdem::PolySuperQuadrics::quat_ref {1, 0, 0, 0}

The documentation for this class was generated from the following files: