Skip to content

Commit

Permalink
improved SBGATMassProperties and updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bbercovici committed Jan 29, 2019
1 parent bb41d03 commit 3717bdb
Show file tree
Hide file tree
Showing 17 changed files with 400 additions and 239 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ before reinstalling.

### Linux & Mac users

[Refer to the detailed installation instructions](https://github.com/bbercovici/SBGAT/wiki/2:-Compile-and-install-SBGAT-dependencies).
[Refer to the detailed installation instructions](https://github.com/bbercovici/SBGAT/wiki/2:-Compiling-and-installing-SBGAT-dependencies).

## Getting updates

Expand Down Expand Up @@ -75,6 +75,19 @@ to apply the update (if any).
## Changelog


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

#### New

- `SBGATMassProperties` now offers a method to save the computed mass properties to a JSON file (`SBGATMassProperties::SaveMassProperties`)
- A static method evaluating and saving the mass properties of the provided shape is now provided (`SBGATMassProperties::ComputeAndSaveMassProperties`)
- The `Measures` menu in `SbgatGUI` has been augmented with a `Save geometric measures` action

#### Improvements
- **The inertia tensor normalization has changed.** When computing the mass properties of a given small body, the following normalization is now applied to the inertia tensor: `I_norm = I / (mass * r_avg ^ 2)` where `r_avg = cbrt(3/4 *Volume/pi)`. `r_avg` is now computed along with the other properties within `SBGATMassProperties`.
- The parallel axis theorem is no-longer applied to the small body. That is, the inertia will always be expressed about (0,0,0).
- Several GUI minors bug fixes

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

### New:
Expand Down
5 changes: 3 additions & 2 deletions SbgatCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
#
#
################################################################################
cmake_minimum_required(VERSION 3.12.0)

cmake_minimum_required(VERSION 3.13.3)

# Building procedure
get_filename_component(dirName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
Expand Down Expand Up @@ -93,6 +93,7 @@ endif()

# Find VTK Package
find_package(VTK REQUIRED)

include(${VTK_USE_FILE})

# Find YORPLib
Expand Down
158 changes: 96 additions & 62 deletions SbgatCore/include/SbgatCore/SBGATMassProperties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Program: Small Body Geophysical Analysis
Module: SBGATMassProperties.hpp
Derived class from VTK's vtkPolyDataAlgorithm by Benjamin Bercovici
Class derived from VTK's vtkPolyDataAlgorithm by Benjamin Bercovici
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
Expand Down Expand Up @@ -48,7 +48,7 @@ class VTKFILTERSCORE_EXPORT SBGATMassProperties : public vtkPolyDataAlgorithm{
void PrintTrailer(std::ostream& os, vtkIndent indent) override;

/**
* Compute and return the volume.
* Compute and return the volume (m or km^3)
*/
double GetVolume() {this->Update(); return this->Volume;}

Expand Down Expand Up @@ -80,17 +80,20 @@ class VTKFILTERSCORE_EXPORT SBGATMassProperties : public vtkPolyDataAlgorithm{
/**
* Compute and return the area.
*/
double GetSurfaceArea() {this->Update(); return this->SurfaceArea;}
double GetSurfaceArea() {this->Update(); return this->SurfaceArea;
}

/**
* Compute and return the min cell area.
*/
double GetMinCellArea() {this->Update(); return this->MinCellArea;}
double GetMinCellArea() {this->Update(); return this->MinCellArea;
}

/**
* Compute and return the max cell area.
*/
double GetMaxCellArea() {this->Update(); return this->MaxCellArea;}
double GetMaxCellArea() {this->Update(); return this->MaxCellArea;
}


/**
Expand All @@ -105,92 +108,123 @@ class VTKFILTERSCORE_EXPORT SBGATMassProperties : public vtkPolyDataAlgorithm{
* is one. This number is always >= 1.0.
*/
double GetNormalizedShapeIndex()
{this->Update(); return this->NormalizedShapeIndex;}
{this->Update(); return this->NormalizedShapeIndex;
}


/**
* Compute and return the coordinates of the center of mass
* evaluated in the frame of origin assuming a constant density distribution
* across the shape
*/
arma::vec::fixed<3> GetCenterOfMass(){
this -> Update(); return this -> center_of_mass;}
const arma::vec::fixed<3> & GetCenterOfMass(){
this -> Update(); return this -> center_of_mass;
}

/**
/**
* Compute and return the coordinates of the center of mass
* evaluated in the frame of origin assuming a constant density distribution
* across the shape
*/
void GetCenterOfMass(double * com){
this -> Update();
com[0] = this -> center_of_mass(0);
com[1] = this -> center_of_mass(1);
com[2] = this -> center_of_mass(2);
}

void GetCenterOfMass(double * com){
this -> Update();
com[0] = this -> center_of_mass(0);
com[1] = this -> center_of_mass(1);
com[2] = this -> center_of_mass(2);
}

/**
* Compute and return the inertia tensor
* Compute and return the dimensionless inertia tensor
* at the barycenter, evaluated in the frame of origin assuming a constant density distribution
* across the shape
* across the shape. The normalization applied to the inertia tensor is I_norm = I / (mass * r_avg ^ 2) where r_avg = cbrt(3/4*Volume/pi)
*/
arma::mat::fixed<3,3> GetInertiaTensor(){
this -> Update(); return this -> inertia_tensor;}
arma::mat::fixed<3,3> GetInertiaTensor(){
this -> Update(); return this -> inertia_tensor;
}

/**
* Compute and return the principal axes of the inertia tensor
*/
arma::mat::fixed<3,3> GetPrincipalAxes(){
this -> Update(); return this -> principal_axes;}
arma::mat::fixed<3,3> GetPrincipalAxes(){
this -> Update(); return this -> principal_axes;
}


/**
* Compute and return the inertia moments assuming uniform density distribution
* across the shape
* Compute and return the dimensionless inertia moments assuming uniform density distribution
* across the shape. The normalization applied to the inertia tensor is I_norm = I / (mass * r_avg ^ 2) where r_avg = cbrt(3/4*Volume/pi)
*/
arma::vec::fixed<3> GetInertiaMoments(){
this -> Update(); return arma::eig_sym(this -> inertia_tensor);}
arma::vec::fixed<3> GetInertiaMoments(){
this -> Update(); return arma::eig_sym(this -> inertia_tensor);
}

/**
Computes the average radius of the shape (that is, the radius of a sphere occupying the same volume) (m or km)
*/

double GetAverageRadius(){
this -> Update(); return this -> r_avg;
}


/**
* Compute and return the bounding box (xmin,xmax,ymin,ymax,zmin,zmax)
*/
double * GetBoundingBox(){
this -> Update(); return this -> bounds;
}

protected:
SBGATMassProperties();
~SBGATMassProperties() override;

int RequestData(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector) override;


arma::vec::fixed<3> center_of_mass;
arma::mat::fixed<3,3> inertia_tensor;
arma::mat::fixed<3,3> principal_axes;

double SurfaceArea;
double MinCellArea;
double MaxCellArea;
double Volume;
double VolumeProjected;
double VolumeX;
double VolumeY;
double VolumeZ;
double Kx;
double Ky;
double Kz;
double NormalizedShapeIndex;
double bounds[6];
bool IsClosed;

private:
SBGATMassProperties(const SBGATMassProperties&) = delete;
void operator=(const SBGATMassProperties&) = delete;
};
double * GetBoundingBox(){
this -> Update(); return this -> bounds;
}


/**
Computes the mass properties of the provided shape and saves the results to a JSON file
@param shape point to considered shape
@param path savepath (ex: "mass_properties.json")
@param is_in_meters true if the shape coordinates are expressed in meters, false otherwise
*/
static void ComputeAndSaveMassProperties(vtkSmartPointer<vtkPolyData> shape,std::string path,bool is_in_meters);


/**
Save the computed mass properties to a JSON file
@param path savepath (ex: "mass_properties.json")
@param is_in_meters true if the shape coordinates are expressed in meters, false otherwise
*/
void SaveMassProperties(std::string path,bool is_in_meters) const ;


protected:
SBGATMassProperties();
~SBGATMassProperties() override;

int RequestData(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector) override;

arma::vec::fixed<3> center_of_mass;
arma::mat::fixed<3,3> inertia_tensor;
arma::mat::fixed<3,3> principal_axes;

double SurfaceArea;
double MinCellArea;
double MaxCellArea;
double Volume;
double VolumeProjected;
double VolumeX;
double VolumeY;
double VolumeZ;
double Kx;
double Ky;
double Kz;
double NormalizedShapeIndex;
double bounds[6];
double r_avg;
bool IsClosed;

private:
SBGATMassProperties(const SBGATMassProperties&) = delete;
void operator=(const SBGATMassProperties&) = delete;
};

#endif

Expand Down
2 changes: 1 addition & 1 deletion SbgatCore/include/SbgatCore/SBGATObsLightcurve.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Program: Small Body Geophysical Analysis
Module: SBGATObsLightcurve.hpp
Derived class from VTK's vtkPolyDataAlgorithm by Benjamin Bercovici
Class derived from VTK's vtkPolyDataAlgorithm by Benjamin Bercovici
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion SbgatCore/include/SbgatCore/SBGATObsRadar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Program: Small Body Geophysical Analysis
Module: SBGATObsRadar.hpp
Derived class from VTK's vtkPolyDataAlgorithm by Benjamin Bercovici
Class derived from VTK's vtkPolyDataAlgorithm by Benjamin Bercovici
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Program: Small Body Geophysical Analysis
Module: SBGATPolyhedronGravityModel.hpp
Derived class from VTK's vtkPolyDataAlgorithm by Benjamin Bercovici
Class derived from VTK's vtkPolyDataAlgorithm by Benjamin Bercovici
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion SbgatCore/include/SbgatCore/SBGATSphericalHarmo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Program: Small Body Geophysical Analysis
Module: SBGATSphericalHarmo.hpp
Derived class from VTK's vtkPolyDataAlgorithm by Benjamin Bercovici
Class derived from VTK's vtkPolyDataAlgorithm by Benjamin Bercovici
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
Expand Down
5 changes: 1 addition & 4 deletions SbgatCore/include/SbgatCore/SBGATSrpYorp.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@

/*=========================================================================
Program: Small Body Geophysical Analysis
Module: SBGATSrpYorp.hpp
Derived class from VTK's vtkPolyDataAlgorithm by Benjamin Bercovici
Class derived from VTK's vtkPolyDataAlgorithm by Benjamin Bercovici
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
Expand Down
Loading

0 comments on commit 3717bdb

Please sign in to comment.