9#include "sfh/math/math.h" 
   14typedef Eigen::Matrix<double,6,6>   mat6;
 
   15typedef Eigen::Matrix<double,6,1>   vec6;
 
   16typedef Eigen::Matrix<double,3,3>   mat3;
 
   17typedef Eigen::Matrix<double,2,1>   vec2;
 
   18typedef Eigen::Matrix<int,2,1>      vec2i;
 
   19typedef Eigen::Matrix<double,3,1>   vec3;
 
   20typedef Eigen::Matrix<int,3,1>      vec3i;
 
   21typedef Eigen::Matrix<double,13,1>  vec13;
 
   22typedef Eigen::Quaternion<double>   quat;
 
   25typedef double iCoordinate;         
 
   26typedef double oCoordinate;         
 
   30int rayTri(
const vec3 &V1, 
const vec3 &V2, 
const vec3 &V3, 
const vec3 &O, 
const vec3 &D, 
double &out);
 
   34int SegmentPlane(
const vec3 &S0, 
const vec3 &S1, 
const vec3 &P0, 
const vec3 &PN, vec3 &SPI);
 
   40    bool operator <(
const Point &p)
 const {
 
   41        return x < p.x || (x == p.x && y < p.y);
 
   46inline oCoordinate Cross2D(
const Point &O, 
const Point &A, 
const Point &B)
 
   48    return (A.x - O.x) * (B.y - O.y) - (A.y - O.y) * (B.x - O.x);
 
   52std::vector<Point> ConvexHull(std::vector<Point> P);
 
   56inline double TriangleArea2D(
const vec2 &V0, 
const vec2 &V1, 
const vec2 &V2)
 
   61    return 0.5*std::abs(V01(0)*V02(1)-V02(0)*V01(1));
 
   66inline double TriangleArea3D(
const vec3 &V0, 
const vec3 &V1, 
const vec3 &V2)
 
   71    vec3 V012 = V01.cross(V02);
 
   73    return 0.5*sqrt(V012(0)*V012(0)+V012(1)*V012(1)+V012(2)*V012(2));
 
   78inline double PointDistance3D(
const vec3 &PA, 
const vec3 &PB)
 
   80    return sqrt((PA(0)-PB(0))*(PA(0)-PB(0))+(PA(1)-PB(1))*(PA(1)-PB(1))+(PA(2)-PB(2))*(PA(2)-PB(2)));
 
   85inline double PointPlaneDis(
const vec3 &V0, 
const vec3 &P0, 
const vec3 &PN)
 
   88    return VP.dot(PN.normalized());
 
   96    PolyplateSpec(
int &nPolyPoints, std::vector<double> &xPoints, std::vector<double> &yPoints, 
double &mThickness, 
double &mDensity);
 
   99    void setPolyplate(
int &nPolyPoints, std::vector<double> &xPoints, std::vector<double> &yPoints, 
double &mThickness, 
double &mDensity);
 
  103    std::vector<double> xCoords;        
 
  104    std::vector<double> yCoords;        
 
  111    double projectedArea;
 
  122mat3 GetRotation(
const vec3& angle);
 
  123mat6 ReorientInertiaTranslateRotate(
const mat6& Inertia, 
const vec6& orientation);
 
  124mat3 MakeDyadic(
const vec3& vector);
 
  149        minloc(0) = minloc(1) = minloc(2) = std::numeric_limits<double>::max();         
 
  150        maxloc(0) = maxloc(1) = maxloc(2) = -std::numeric_limits<double>::max();
 
  154        minloc = aabb.minloc;
 
  155        maxloc = aabb.maxloc;
 
  160    void add(
const vec3 &v) {
 
  161        if (v(0) < minloc(0)) minloc(0) = v(0);
 
  162        if (v(1) < minloc(1)) minloc(1) = v(1);
 
  163        if (v(2) < minloc(2)) minloc(2) = v(2);
 
  164        if (v(0) > maxloc(0)) maxloc(0) = v(0);
 
  165        if (v(1) > maxloc(1)) maxloc(1) = v(1);
 
  166        if (v(2) > maxloc(2)) maxloc(2) = v(2);
 
  170        minloc(0) = minloc(1) = minloc(2) = std::numeric_limits<double>::max();
 
  171        maxloc(0) = maxloc(1) = maxloc(2) = -std::numeric_limits<double>::max();
 
  174    int overlap(
const AABB &aabb)
 
  176        if(maxloc(0) < aabb.minloc(0) || minloc(0) > aabb.maxloc(0)) 
return 0;
 
  177        if(maxloc(1) < aabb.minloc(1) || minloc(1) > aabb.maxloc(1)) 
return 0;
 
  178        if(maxloc(2) < aabb.minloc(2) || minloc(2) > aabb.maxloc(2)) 
return 0;
 
  183    double overlapvolume(
const AABB &aabb, vec3 &minol, vec3 &maxol)
 
  185        minol(0) = std::max(minloc(0),aabb.minloc(0));
 
  186        maxol(0) = std::min(maxloc(0),aabb.maxloc(0));      
 
  187        minol(1) = std::max(minloc(1),aabb.minloc(1));
 
  188        maxol(1) = std::min(maxloc(1),aabb.maxloc(1));
 
  189        minol(2) = std::max(minloc(2),aabb.minloc(2));
 
  190        maxol(2) = std::min(maxloc(2),aabb.maxloc(2));
 
  192        double volume = std::abs((maxol(0)-minol(0))*(maxol(1)-minol(1))*(maxol(2)-minol(2)));
 
  197    int border(
const AABB &aabb, 
double &tol)
 
  199        if(PointDistance3D(minloc,aabb.minloc)>tol) 
return 0;
 
  200        if(PointDistance3D(maxloc,aabb.maxloc)>tol) 
return 0;
 
  223        minloc(0) = minloc(1) = std::numeric_limits<double>::max();         
 
  224        maxloc(0) = maxloc(1) = -std::numeric_limits<double>::max();
 
  228        minloc = aabb.minloc;
 
  229        maxloc = aabb.maxloc;
 
  234    void add(
const vec2 &v) {
 
  235        if (v(0) < minloc(0)) minloc(0) = v(0);
 
  236        if (v(1) < minloc(1)) minloc(1) = v(1);
 
  237        if (v(0) > maxloc(0)) maxloc(0) = v(0);
 
  238        if (v(1) > maxloc(1)) maxloc(1) = v(1);
 
  242        minloc(0) = minloc(1) = std::numeric_limits<double>::max();
 
  243        maxloc(0) = maxloc(1) = -std::numeric_limits<double>::max();
 
  246    int overlap(
const AABB2D &aabb)
 
  248        if(maxloc(0) < aabb.minloc(0) || minloc(0) > aabb.maxloc(0)) 
return 0;
 
  249        if(maxloc(1) < aabb.minloc(1) || minloc(1) > aabb.maxloc(1)) 
return 0;
 
  254    double overlaparea(
const AABB2D &aabb, vec2 &minol, vec2 &maxol)
 
  256        minol(0) = std::max(minloc(0),aabb.minloc(0));
 
  257        maxol(0) = std::min(maxloc(0),aabb.maxloc(0));      
 
  258        minol(1) = std::max(minloc(1),aabb.minloc(1));
 
  259        maxol(1) = std::min(maxloc(1),aabb.maxloc(1));
 
  261        double area = std::abs((maxol(0)-minol(0))*(maxol(1)-minol(1)));
 
  301    void newConvexhull(
int &nVertices, std::vector<vec3> &xVertices, 
int &nFaces, std::vector<vec3i> &iFaces);
 
  302    void newPolyplate(
int &nPolyPoints, 
int topF, 
int botF);
 
  303    void setPolyplate(
int &nPolyPoints, 
const PolyplateSpec &iPolyplate, vec3 &iCT, quat &iQuatL2G);
 
  304    vec2i ClosestV(
const Particle &PB, 
double &dAB);
 
  305    double DistancePL(
const vec3 &P0, 
const vec3 &PN, 
int &numCV, std::vector<int> &indexCV);
 
  306    double DistancePL1V(
const vec3 &P0, 
const vec3 &PN);
 
  307    int IntersectionPL(
const vec3 &P0, 
const vec3 &PN, 
int &numInt, std::vector<vec3> &xyzInt, 
double &IND);
 
  320    int CalCommonPlane(
Particle &PA, 
Particle &PB, 
const double &TOL, 
const double &TRAN, 
const vec3 &P0, 
const vec3 &PN, vec3 &CP0, vec3 &CPN);
 
  322    int ChkCommonPlane(
Particle &PA, 
Particle &PB, 
const double &TOL, 
const vec3 &P0, 
const vec3 &PN);
 
  327double ContactAreaAABB(
Particle &PA, 
Particle &PB, 
const vec3 &P0, 
const vec3 &PN, 
double &IND, vec3 &CONP);
 
  328double ContactAreaMesh(
Particle &PA, 
Particle &PB, 
const vec3 &P0, 
const vec3 &PN, 
double &IND, vec3 &CONP);
 
Definition: Subroutines.h:218
 
Definition: Subroutines.h:144
 
Definition: Subroutines.h:312
 
Definition: Subroutines.h:277
 
Definition: Subroutines.h:269
 
Definition: Subroutines.h:208
 
Definition: Subroutines.h:128
 
Definition: Subroutines.h:38
 
Definition: Subroutines.h:93