Skip to content

Commit

Permalink
added pgm export functionalities and shape centering
Browse files Browse the repository at this point in the history
  • Loading branch information
bbercovici committed Dec 10, 2018
1 parent 194f551 commit cc34992
Show file tree
Hide file tree
Showing 8 changed files with 590 additions and 154 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ to apply the update (if any).

## Changelog

### [SBGAT 1.12.1](https://github.com/bbercovici/SBGAT/releases/tag/1.12.1)

### New:
- The gravity-gradient matrix deriving from the polyhedron gravity model can now be evaluated
- The evaluation of the surface polyhedron gravity model can now be saved to a JSON file through `SBGATPolyhedronGravityModel::SaveSurfacePGM`
- This static method is available in `SbgatGUI` as the evaluation of the PGM will now require the specification of an output file

#### Improvements
- Stronger typing of inputs in `SBGATPolyhedronGravityModel`
- `SbgatGui` will now ask users whethers a loaded shape should be barycentered/principal-axis aligned, and apply the corresponding transform if answered `yes`


### [SBGAT 1.11.1](https://github.com/bbercovici/SBGAT/releases/tag/1.11.1)

#### New:
Expand Down
118 changes: 97 additions & 21 deletions SbgatCore/include/SbgatCore/SBGATPolyhedronGravityModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class VTKFILTERSCORE_EXPORT SBGATPolyhedronGravityModel : public vtkPolyDataAlgo
the polydata
@return PGM potential evaluated at the queried point (L ^ 2/ s ^2)
*/
double GetPotential(double const * point);
double GetPotential(double const * point) const;

/**
Evaluates the Polyhedron Gravity Model potential at the specified point assuming
Expand All @@ -78,30 +78,61 @@ class VTKFILTERSCORE_EXPORT SBGATPolyhedronGravityModel : public vtkPolyDataAlgo
the polydata
@return PGM potential evaluated at the queried point (L ^ 2 / s ^2)
*/
double GetPotential(const arma::vec & point);
double GetPotential(const arma::vec::fixed<3> & point) const;

/**
Evaluates the Polyhedron Gravity Model potential and acceleration at the specified point assuming
a constant density
@param point coordinates of queried point, expressed in the same frame/unit L as
the polydata used to construct the PGM
@param PGM potential evaluated at the queried point (L ^ 2 / s ^2)
@param PGM acceleration evaluated at the queried point (L / s ^2)
@param[out] PGM potential evaluated at the queried point (L ^ 2 / s ^2)
@param[out] PGM acceleration evaluated at the queried point (L / s ^2)
*/
void GetPotentialAcceleration(double const * point,double & potential,
arma::vec & acc);
arma::vec::fixed<3> & acc) const;


/**
Evaluates the Polyhedron Gravity Model potential and acceleration at the specified point assuming
a constant density
@param point coordinates of queried point, expressed in the same frame/unit L as
the polydata used to construct the PGM
@param PGM potential evaluated at the queried point (L ^ 2 / s ^2)
@param PGM acceleration evaluated at the queried point (L / s ^2)
@param[out] PGM potential evaluated at the queried point (L ^ 2 / s ^2)
@param[out] PGM acceleration evaluated at the queried point (L / s ^2)
*/
void GetPotentialAcceleration(const arma::vec & point,double & potential,
arma::vec & acc);
void GetPotentialAcceleration(const arma::vec::fixed<3> & point,double & potential,
arma::vec::fixed<3> & acc) const;




/**
Evaluates the Polyhedron Gravity Model potential, acceleration and gravity gradient matrix at the specified point assuming
a constant density
@param point coordinates of queried point, expressed in the same frame/unit L as
the polydata used to construct the PGM
@param[out] PGM potential evaluated at the queried point (L ^ 2 / s ^2)
@param[out] PGM acceleration evaluated at the queried point (L / s ^2)
@param[out] PGM gravity gradient matrix evaluated at the queried point (1 / s ^2)
*/
void GetPotentialAccelerationGravityGradient(double const * point,double & potential,
arma::vec::fixed<3> & acc,arma::mat::fixed<3,3> & gravity_gradient_mat) const ;



/**
Evaluates the Polyhedron Gravity Model potential, acceleration and gravity gradient matrix at the specified point assuming
a constant density
@param point coordinates of queried point, expressed in the same frame/unit L as
the polydata used to construct the PGM
@param[out] PGM potential evaluated at the queried point (L ^ 2 / s ^2)
@param[out] PGM acceleration evaluated at the queried point (L / s ^2)
@param[out] PGM gravity gradient matrix evaluated at the queried point (1 / s ^2)
*/
void GetPotentialAccelerationGravityGradient(const arma::vec::fixed<3> & point,double & potential,
arma::vec::fixed<3> & acc,arma::mat::fixed<3,3> & gravity_gradient_mat) const ;




/**
Expand All @@ -111,7 +142,7 @@ class VTKFILTERSCORE_EXPORT SBGATPolyhedronGravityModel : public vtkPolyDataAlgo
the polydata used to construct the PGM
@return PGM acceleration evaluated at the queried point (L / s ^2)
*/
arma::vec GetAcceleration(const arma::vec & point);
arma::vec::fixed<3> GetAcceleration(const arma::vec::fixed<3> & point) const;

/**
Evaluates the Polyhedron Gravity Model acceleration at the specified point assuming
Expand All @@ -120,7 +151,7 @@ class VTKFILTERSCORE_EXPORT SBGATPolyhedronGravityModel : public vtkPolyDataAlgo
the input polydata
@return PGM acceleration evaluated at the queried point (L / s ^2)
*/
arma::vec GetAcceleration(double const * point);
arma::vec::fixed<3> GetAcceleration(double const * point) const;

/**
Determines whether the provided point lies inside or outside the shape
Expand All @@ -129,7 +160,7 @@ class VTKFILTERSCORE_EXPORT SBGATPolyhedronGravityModel : public vtkPolyDataAlgo
@param tolerance
@return true if the polydata contains the point, false otherwise
*/
bool Contains(double const * point, double tol = 1e-8);
bool Contains(double const * point, double tol = 1e-8) const;

/**
Sets the scale factor to 1, indicative that the polydata has its coordinates expressed in meters
Expand All @@ -141,6 +172,7 @@ class VTKFILTERSCORE_EXPORT SBGATPolyhedronGravityModel : public vtkPolyDataAlgo
*/
void SetScaleKiloMeters() { this -> scaleFactor = 1000; this -> scaleFactorSet = true;}


/**
Sets polyhedron density
@param density bulk density of polyhedron (kg/m^3)
Expand All @@ -150,6 +182,23 @@ class VTKFILTERSCORE_EXPORT SBGATPolyhedronGravityModel : public vtkPolyDataAlgo
this -> densitySet = true;
}


/**
Get polyhedron density
@return density bulk density of polyhedron (kg/m^3)
*/
double GetDensity() const{
return this -> density ;
}

/**
Get polyhedron mass. Must have set the density and call
@return mass (kg)
*/
double GetMass() const{
return this -> density * this -> mass_properties -> GetVolume() * std::pow(this -> scaleFactor,3);
}

/**
Evaluates the Polyhedron Gravity Model at the surface of the specified surface elements in the provided shape
@param[in] selected_shape shape for which the surface polyhedron gravity model must be computed
Expand All @@ -163,15 +212,42 @@ class VTKFILTERSCORE_EXPORT SBGATPolyhedronGravityModel : public vtkPolyDataAlgo
@param[out] acc_body_fixed_magnitudes vector storing the body-fixed gravitational acceleration magnitudes (m/s^2) evaluated at the center of each queried element
*/
static void ComputeSurfacePGM(
vtkSmartPointer<vtkPolyData> selected_shape,
const std::vector<unsigned int> & queried_elements,
bool is_in_meters,
double density,
const arma::vec::fixed<3> & omega,
std::vector<double> & slopes,
std::vector<double> & potentials,
std::vector<double> & acc_magnitudes,
std::vector<double> & acc_body_fixed_magnitudes);
vtkSmartPointer<vtkPolyData> selected_shape,
const std::vector<unsigned int> & queried_elements,
bool is_in_meters,
double density,
const arma::vec::fixed<3> & omega,
std::vector<double> & slopes,
std::vector<double> & potentials,
std::vector<double> & acc_magnitudes,
std::vector<double> & acc_body_fixed_magnitudes);




/**
Saves the provided Polyhedron Gravity Model to a file
@param[in] selected_shape shape for which the surface polyhedron gravity model must be computed
@param[in] queried_elements shape indices of elements where the polyhedron gravity model should be evaluated
@param[in] is_in_meters true if the shape coordinates were expressed in meters, false if they were expressed in kilometers
@param[in] mass mass of shape model (kg)
@param[in] omega fixed angular velocity of shape (rad/s)
@param[in] slopes vector storing the gravitational slopes (degrees) evaluated at the center of each queried element
@param[in] potentials vector storing the inertial gravitational potentials (m^2/s^2) evaluated at the center of each queried element
@param[in] acc_magnitudes vector storing the inertial gravitational acceleration magnitudes (m/s^2) evaluated at the center of each queried element
@param[in] acc_body_fixed_magnitudes vector storing the body-fixed gravitational acceleration magnitudes (m/s^2) evaluated at the center of each queried element
@param[in] path save path (ex: "pgm_surface.json")
*/
static void SaveSurfacePGM(vtkSmartPointer<vtkPolyData> selected_shape,
const std::vector<unsigned int> & queried_elements,
bool is_in_meters,
const double & mass,
const arma::vec::fixed<3> & omega,
const std::vector<double> & slopes,
const std::vector<double> & potentials,
const std::vector<double> & acc_magnitudes,
const std::vector<double> & acc_body_fixed_magnitudes,
std::string path);



Expand Down
Loading

0 comments on commit cc34992

Please sign in to comment.