19 const Point
zero(0.0, 0.0, 0.0);
20 return pt.absolute_fuzzy_equals(
zero);
34 const std::vector<Point> & candidates,
35 const unsigned int axis)
40 for (
const auto & c : candidates)
43 const Real dy = c(
idx.second) - pt(
idx.second);
52 projectPoint(
const Real x0,
const Real x1,
const unsigned int axis)
73 return (pt1(i.first) - pt3(i.first)) * (pt2(i.second) - pt3(i.second)) -
74 (pt2(i.first) - pt3(i.first)) * (pt1(i.second) - pt3(i.second));
78 pointInPolygon(
const Point & point,
const std::vector<Point> & corners,
const unsigned int axis)
80 const auto n_pts = corners.size();
82 std::vector<bool> negative_half_space;
83 std::vector<bool> positive_half_space;
86 const int next = (i == n_pts - 1) ? 0 : i + 1;
88 negative_half_space.push_back(half < 0);
89 positive_half_space.push_back(half > 0);
92 const bool negative = std::find(negative_half_space.begin(), negative_half_space.end(),
true) !=
93 negative_half_space.end();
94 const bool positive = std::find(positive_half_space.begin(), positive_half_space.end(),
true) !=
95 positive_half_space.end();
97 const bool in_polygon = !(negative && positive);
108 pointOnEdge(
const Point & point,
const std::vector<Point> & corners,
const unsigned int axis)
110 const auto n_pts = corners.size();
113 constexpr
Real tol = 1e-8;
116 const int next = (i == n_pts - 1) ? 0 : i + 1;
117 const auto & pt1 = corners[i];
118 const auto & pt2 = corners[next];
127 const bool between_points = (point(
idx.first) >=
std::min(pt1(
idx.first), pt2(
idx.first))) &&
133 if (close_to_line && between_points)
140 std::pair<unsigned int, unsigned int>
143 std::pair<unsigned int, unsigned int> indices;
173 const Real dx = pt2(i.first) - pt1(i.first);
174 const Real dy = pt2(i.second) - pt1(i.second);
177 const Point gap_line = pt2 - pt1;
179 const auto cross_product = gap_line.cross(normal);
181 if (cross_product(axis) > 0)
182 return normal.unit();
190 const Point a = pt - line0;
191 const Point b = pt - line1;
192 const Point c = line1 - line0;
194 return (a.cross(b).norm()) / c.norm();
209 polygonCorners(
const unsigned int num_sides,
const Real radius,
const unsigned int axis)
211 std::vector<Point> corners;
212 const Real theta = 2.0 * M_PI / num_sides;
213 const Real first_angle = M_PI / 2.0 - theta / 2.0;
217 const Real angle = first_angle + i * theta;
230 const Real cos_theta =
cos(angle);
231 const Real sin_theta =
sin(angle);
234 const Real xy = axis(0) * axis(1);
235 const Real xz = axis(0) * axis(2);
236 const Real yz = axis(1) * axis(2);
238 const Point x_op(cos_theta + axis(0) * axis(0) * (1.0 - cos_theta),
239 xy * (1.0 - cos_theta) - axis(2) * sin_theta,
240 xz * (1.0 - cos_theta) + axis(1) * sin_theta);
242 const Point y_op(xy * (1.0 - cos_theta) + axis(2) * sin_theta,
243 cos_theta + axis(1) * axis(1) * (1.0 - cos_theta),
244 yz * (1.0 - cos_theta) - axis(0) * sin_theta);
246 const Point z_op(xz * (1.0 - cos_theta) - axis(1) * sin_theta,
247 yz * (1.0 - cos_theta) + axis(0) * sin_theta,
248 cos_theta + axis(2) * axis(2) * (1.0 - cos_theta));
259 Point diff = (box.
max() - box.
min()) / 2.0;
260 const Point origin = box.
min() + diff;
266 const Point dx(2.0 * diff(0), 0.0, 0.0);
267 const Point dy(0.0, 2.0 * diff(1), 0.0);
268 const Point dz(0.0, 0.0, 2.0 * diff(2));
270 std::vector<Point> verts(8, origin - diff);
271 const unsigned int pts_per_dim = 2;
275 verts[pts_per_dim * pts_per_dim * z + pts_per_dim * y + x] += x * dx + y * dy + z * dz;
std::string name(const ElemQuality q)
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sin(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tan
libMesh::Point projectPoint(const libMesh::Real x0, const libMesh::Real x1, const unsigned int axis)
Given two coordinates, construct a point in the 2-D plane perpendicular to the specified axis...
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
libMesh::Real projectedDistanceFromLine(libMesh::Point pt, libMesh::Point line0, libMesh::Point line1, const unsigned int axis)
Compute the distance from a 3-D line, provided in terms of two points on the line.
libMesh::Real projectedLineHalfSpace(libMesh::Point pt1, libMesh::Point pt2, libMesh::Point pt3, const unsigned int axis)
If positive, point is on the positive side of the half space (and vice versa).
libMesh::Point projectedUnitNormal(libMesh::Point pt1, libMesh::Point pt2, const unsigned int axis)
Get the unit normal vector between two points (which are first projected onto the plane perpendicular...
libMesh::Point rotatePointAboutAxis(const libMesh::Point &p, const libMesh::Real angle, const libMesh::Point &axis)
Rotate point about an axis.
std::vector< libMesh::Point > polygonCorners(const unsigned int num_sides, const libMesh::Real radius, const unsigned int axis)
Get the corner coordinates of a regular 2-D polygon, assuming a face of the polygon is parallel to th...
Real distance(const Point &p)
auto max(const L &left, const R &right)
TypeVector< Real > unit() const
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template cos(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(cos
bool pointOnEdge(const libMesh::Point &point, const std::vector< libMesh::Point > &corners, const unsigned int axis)
Whether a point is on the edge of a 2-D polygon in the plane perpendicular to the specified axis...
const Point & min() const
libMesh::Point unitVector(const libMesh::Point &pt, const std::string &name)
Get the unit vector for a point parameter.
bool isPointZero(const libMesh::Point &pt)
Check whether a point is equal to zero.
std::pair< unsigned int, unsigned int > projectedIndices(const unsigned int axis)
Get the indices of the plane perpendicular to the specified axis.
libMesh::Real distanceFromLine(const libMesh::Point &pt, const libMesh::Point &line0, const libMesh::Point &line1)
Compute the distance from a 3-D line, provided in terms of two points on the line.
libMesh::Real minDistanceToPoints(const libMesh::Point &pt, const std::vector< libMesh::Point > &candidates, const unsigned int axis)
Get the minimum distance from a point to another set of points, in the plane perpendicular to the spe...
std::vector< libMesh::Point > boxCorners(const libMesh::BoundingBox &box, const libMesh::Real factor)
Get corner points of a bounding box, with side length re-scaled.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool pointInPolygon(const libMesh::Point &point, const std::vector< libMesh::Point > &corners, const unsigned int axis)
Whether a point is in 2-D a polygon in the plane perpendicular to the specified axis, given by corner points.
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
IntRange< T > make_range(T beg, T end)
const Point & max() const
auto min(const L &left, const R &right)
auto index_range(const T &sizable)