PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
geom::anonymous_namespace{geomObjects.cpp} Namespace Reference

Functions

bool ellipseMetricInside (double u, double v, double a, double b)
 
void ellipseLocal (const Ellipse &e, const util::Point &x, double &u, double &v)
 
static void quatMul (double aw, double ax, double ay, double az, double bw, double bx, double by, double bz, double &cw, double &cx, double &cy, double &cz)
 
static void axisAngleToQuatSafe (const util::Point &axisIn, double theta, double &w, double &x, double &y, double &z)
 
static void quatToAxisAngle (double qw, double qx, double qy, double qz, util::Point &axis, double &theta)
 
void ellipsoidBodyCoords (const Ellipsoid &e, const util::Point &p, double R[9], double &v0, double &v1, double &v2)
 
double ellipsoidMetric (const Ellipsoid &e, const util::Point &x, double R[9], const double &ra, const double &rb, const double &rc)
 

Function Documentation

◆ axisAngleToQuatSafe()

static void geom::anonymous_namespace{geomObjects.cpp}::axisAngleToQuatSafe ( const util::Point axisIn,
double  theta,
double &  w,
double &  x,
double &  y,
double &  z 
)
static

Definition at line 2018 of file geomObjects.cpp.

2019 {
2020 if (std::abs(theta) < 1.0e-30) {
2021 w = 1.;
2022 x = y = z = 0.;
2023 return;
2024 }
2025 const double L = axisIn.length();
2026 if (L < 1.0e-30) {
2027 w = 1.;
2028 x = y = z = 0.;
2029 return;
2030 }
2031 const util::Point k = axisIn / L;
2032 const double half = 0.5 * theta;
2033 w = std::cos(half);
2034 const double s = std::sin(half);
2035 x = s * k.d_x;
2036 y = s * k.d_y;
2037 z = s * k.d_z;
2038 }
A structure to represent 3d vectors.
Definition point.h:30
double d_y
the y coordinate
Definition point.h:36
double d_z
the z coordinate
Definition point.h:39
double length() const
Computes the Euclidean length of the vector.
Definition point.h:124
double d_x
the x coordinate
Definition point.h:33

References axisAngleToQuatSafe(), util::Point::d_x, util::Point::d_y, util::Point::d_z, and util::Point::length().

Referenced by axisAngleToQuatSafe().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ellipseLocal()

void geom::anonymous_namespace{geomObjects.cpp}::ellipseLocal ( const Ellipse e,
const util::Point x,
double &  u,
double &  v 
)

Definition at line 1515 of file geomObjects.cpp.

1515 {
1516 const double dx = x.d_x - e.d_x.d_x;
1517 const double dy = x.d_y - e.d_x.d_y;
1518 const double c = std::cos(e.d_theta);
1519 const double s = std::sin(e.d_theta);
1520 u = c * dx + s * dy;
1521 v = -s * dx + c * dy;
1522 }
util::Point d_x
Center.
double d_theta
Counter-clockwise rotation about +z through the center (radians)

References geom::Ellipse::d_theta, geom::Ellipse::d_x, util::Point::d_x, util::Point::d_y, and ellipseLocal().

Referenced by ellipseLocal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ellipseMetricInside()

bool geom::anonymous_namespace{geomObjects.cpp}::ellipseMetricInside ( double  u,
double  v,
double  a,
double  b 
)

Definition at line 1509 of file geomObjects.cpp.

1509 {
1510 if (a <= 0. || b <= 0.)
1511 return false;
1512 return util::isLess(u * u / (a * a) + v * v / (b * b), 1. + 1.0E-12);
1513 }
bool isLess(const double &a, const double &b)
Returns true if a < b.
Definition function.cpp:20

References ellipseMetricInside(), and util::isLess().

Referenced by ellipseMetricInside().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ellipsoidBodyCoords()

void geom::anonymous_namespace{geomObjects.cpp}::ellipsoidBodyCoords ( const Ellipsoid e,
const util::Point p,
double  R[9],
double &  v0,
double &  v1,
double &  v2 
)

Definition at line 2069 of file geomObjects.cpp.

2070 {
2072 v0 = R[0] * p.d_x + R[3] * p.d_y + R[6] * p.d_z;
2073 v1 = R[1] * p.d_x + R[4] * p.d_y + R[7] * p.d_z;
2074 v2 = R[2] * p.d_x + R[5] * p.d_y + R[8] * p.d_z;
2075 }
void ellipsoidRotationMatrix(const Ellipsoid &e, double R[9])
Row-major 3×3 rotation from ellipsoid axis–angle (identity if ).

References util::Point::d_x, util::Point::d_y, util::Point::d_z, ellipsoidBodyCoords(), and geom::ellipsoidRotationMatrix().

Referenced by ellipsoidBodyCoords(), and ellipsoidMetric().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ellipsoidMetric()

double geom::anonymous_namespace{geomObjects.cpp}::ellipsoidMetric ( const Ellipsoid e,
const util::Point x,
double  R[9],
const double &  ra,
const double &  rb,
const double &  rc 
)

Definition at line 2077 of file geomObjects.cpp.

2078 {
2079 const util::Point p{x.d_x - e.d_x.d_x, x.d_y - e.d_x.d_y, x.d_z - e.d_x.d_z};
2080 double v0, v1, v2;
2081 ellipsoidBodyCoords(e, p, R, v0, v1, v2);
2082 const double dx = v0 / ra;
2083 const double dy = v1 / rb;
2084 const double dz = v2 / rc;
2085 return dx * dx + dy * dy + dz * dz;
2086 }
util::Point d_x

References geom::Ellipsoid::d_x, util::Point::d_x, util::Point::d_y, util::Point::d_z, ellipsoidBodyCoords(), and ellipsoidMetric().

Referenced by ellipsoidMetric().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ quatMul()

static void geom::anonymous_namespace{geomObjects.cpp}::quatMul ( double  aw,
double  ax,
double  ay,
double  az,
double  bw,
double  bx,
double  by,
double  bz,
double &  cw,
double &  cx,
double &  cy,
double &  cz 
)
static

Definition at line 2009 of file geomObjects.cpp.

2011 {
2012 cw = aw * bw - ax * bx - ay * by - az * bz;
2013 cx = aw * bx + ax * bw + ay * bz - az * by;
2014 cy = aw * by - ax * bz + ay * bw + az * bx;
2015 cz = aw * bz + ax * by - ay * bx + az * bw;
2016 }

References quatMul().

Referenced by quatMul().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ quatToAxisAngle()

static void geom::anonymous_namespace{geomObjects.cpp}::quatToAxisAngle ( double  qw,
double  qx,
double  qy,
double  qz,
util::Point axis,
double &  theta 
)
static

Definition at line 2040 of file geomObjects.cpp.

2041 {
2042 double n = std::sqrt(qw * qw + qx * qx + qy * qy + qz * qz);
2043 if (n < 1.0e-30) {
2044 axis = util::Point(0., 0., 1.);
2045 theta = 0.;
2046 return;
2047 }
2048 qw /= n;
2049 qx /= n;
2050 qy /= n;
2051 qz /= n;
2052 if (qw < 0.) {
2053 qw = -qw;
2054 qx = -qx;
2055 qy = -qy;
2056 qz = -qz;
2057 }
2058 qw = std::max(-1., std::min(1., qw));
2059 theta = 2. * std::acos(qw);
2060 const double sv = std::sqrt(qx * qx + qy * qy + qz * qz);
2061 if (sv < 1.0e-15) {
2062 axis = util::Point(0., 0., 1.);
2063 theta = 0.;
2064 return;
2065 }
2066 axis = util::Point(qx / sv, qy / sv, qz / sv);
2067 }

References quatToAxisAngle().

Referenced by quatToAxisAngle().

Here is the call graph for this function:
Here is the caller graph for this function: