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

A class for representing a plane with a center point and normal vector. More...

#include <shape_plane.hpp>

Inheritance diagram for netdem::Plane:
netdem::Shape

Public Member Functions

 Plane ()
 Default constructor.
 
 Plane (Vec3d const &c, Vec3d const &n)
 Constructor that sets the center and normal vector of the plane.
 
 Plane (double c_x, double c_y, double c_z, double n_x, double n_y, double n_z)
 Constructor that sets the center and normal vector of the plane using coordinates.
 
void UpdateSurfaceNodes () override
 Update the surface nodes of the Plane object.
 
void UpdateShapeProperties () override
 Update the shape properties of the Plane object.
 
ShapeClone () const override
 Clone the Plane object.
 
nlohmann::json PackJson () override
 Pack the Plane object into a JSON structure.
 
void InitFromJson (nlohmann::json const &js) override
 Initialize the Plane object from a JSON structure.
 
void Init ()
 Initialize the Plane object.
 
void SetExtent (double e)
 Set the extent of the Plane object.
 
void SetCenter (double c_x, double c_y, double c_z)
 Set the center point of the Plane object.
 
void SetNormal (double n_x, double n_y, double n_z)
 Set the normal vector of the Plane object.
 
std::tuple< Vec3d, Vec3dGetBoundAABB (Vec3d const &pos, Vec4d const &quat) const override
 Get the axis-aligned bounding box (AABB) of the Plane object.
 
STLModel GetSTLModel (int num_nodes=400) override
 Generate an STL model of the Plane object.
 
Vec3d SupportPoint (Vec3d const &dir) override
 Compute the support point of the Plane object in a given direction.
 
VecXT< Vec3dSupportPoints (Vec3d const &dir) override
 Compute the support points of the Plane 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 Plane object.
 
Vec3d SurfacePoint (Vec3d const &pos) override
 Compute the surface point on the Plane object closest to a given position.
 
void Print () override
 Print information about the Plane 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 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 SetSize (double d)
 Sets the size of the shape instance.
 
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

Vec3d center {0, 0, 0}
 
Vec3d dir_n {0, 0, 1}
 
double extent {5}
 
- 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 for representing a plane with a center point and normal vector.

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

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

Examples
00_hertz_contact.cpp, 1_membrane_case.cpp, 20_gen_dataset_ellipsoid_plane.cpp, 21_test_dataset_ellipsoid_plane.cpp, 26_test_ann_vs_geom_ellipsoid_plane.cpp, 81_golf_ball_impact.cpp, 92_angle_repose_trimesh.cpp, and 94_angle_repose_trimesh.cpp.

Constructor & Destructor Documentation

◆ Plane() [1/3]

Plane::Plane ( )

Default constructor.

◆ Plane() [2/3]

Plane::Plane ( Vec3d const & c,
Vec3d const & n )

Constructor that sets the center and normal vector of the plane.

Parameters
cThe center point of the plane.
nThe normal vector of the plane.

◆ Plane() [3/3]

Plane::Plane ( double c_x,
double c_y,
double c_z,
double n_x,
double n_y,
double n_z )

Constructor that sets the center and normal vector of the plane using coordinates.

Parameters
c_xThe x-coordinate of the center point of the plane.
c_yThe y-coordinate of the center point of the plane.
c_zThe z-coordinate of the center point of the plane.
n_xThe x-component of the normal vector of the plane.
n_yThe y-component of the normal vector of the plane.
n_zThe z-component of the normal vector of the plane.

Member Function Documentation

◆ Clone()

Shape * Plane::Clone ( ) const
overridevirtual

Clone the Plane object.

This method creates a copy of the Plane object.

Returns
A pointer to the cloned Plane object.

Reimplemented from netdem::Shape.

◆ GetBoundAABB()

tuple< Vec3d, Vec3d > Plane::GetBoundAABB ( Vec3d const & pos,
Vec4d const & quat ) const
overridevirtual

Get the axis-aligned bounding box (AABB) of the Plane object.

This method computes the AABB of the Plane object at a given position and orientation.

Parameters
posThe position of the Plane object.
quatThe quaternion representing the orientation of the Plane object.
Returns
A tuple containing the minimum and maximum points of the AABB.

Reimplemented from netdem::Shape.

◆ GetSTLModel()

STLModel Plane::GetSTLModel ( int num_nodes = 400)
overridevirtual

Generate an STL model of the Plane object.

This method generates an STL model of the Plane object using 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 Plane object.

Reimplemented from netdem::Shape.

◆ Init()

void Plane::Init ( )

Initialize the Plane object.

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

◆ InitFromJson()

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

Initialize the Plane object from a JSON structure.

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

Parameters
jsThe JSON structure to load.

Reimplemented from netdem::Shape.

◆ PackJson()

nlohmann::json Plane::PackJson ( )
overridevirtual

Pack the Plane object into a JSON structure.

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

Returns
The packed JSON structure.

Reimplemented from netdem::Shape.

◆ Print()

void Plane::Print ( )
overridevirtual

Print information about the Plane object.

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

Reimplemented from netdem::Shape.

◆ SetCenter()

void Plane::SetCenter ( double c_x,
double c_y,
double c_z )

Set the center point of the Plane object.

This method sets the center point of the Plane object.

Parameters
c_xThe x-coordinate of the new center point.
c_yThe y-coordinate of the new center point.
c_zThe z-coordinate of the new center point.

◆ SetExtent()

void Plane::SetExtent ( double e)

Set the extent of the Plane object.

This method sets the extent of the Plane object, which determines its size.

Parameters
eThe new extent of the Plane object.
Examples
92_angle_repose_trimesh.cpp, and 94_angle_repose_trimesh.cpp.

◆ SetNormal()

void Plane::SetNormal ( double n_x,
double n_y,
double n_z )

Set the normal vector of the Plane object.

This method sets the normal vector of the Plane object.

Parameters
n_xThe x-component of the new normal vector.
n_yThe y-component of the new normal vector.
n_zThe z-component of the new normal vector.

◆ SignedDistance()

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

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

This method computes the signed distance from a given position to the surface of the Plane object using its center point and normal vector.

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

Reimplemented from netdem::Shape.

◆ SupportPoint()

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

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

This method computes the support point of the Plane object in a given direction, which is the point on the plane that is farthest in the specified direction.

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

Reimplemented from netdem::Shape.

◆ SupportPoints()

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

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

This method computes the support points of the Plane object in a given direction, which are the two points on the plane that are farthest in opposite directions along the specified direction.

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

Reimplemented from netdem::Shape.

◆ SurfacePoint()

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

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

This method computes the surface point on the Plane object closest to a given position by finding the intersection of a line passing through the specified position and perpendicular to the plane with the plane.

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

Reimplemented from netdem::Shape.

◆ UpdateShapeProperties()

void Plane::UpdateShapeProperties ( )
overridevirtual

Update the shape properties of the Plane object.

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

Reimplemented from netdem::Shape.

◆ UpdateSurfaceNodes()

void Plane::UpdateSurfaceNodes ( )
overridevirtual

Update the surface nodes of the Plane object.

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

Reimplemented from netdem::Shape.

Member Data Documentation

◆ center

Vec3d netdem::Plane::center {0, 0, 0}

◆ dir_n

Vec3d netdem::Plane::dir_n {0, 0, 1}

◆ extent

double netdem::Plane::extent {5}

the default extent is deemed large enough to cover the computing domain; otherwise, enlarge it. Note that the gjk algorithm would encounter precision issue for two elements with large size difference (e.g., >1e4 times of size difference)


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