11#ifndef UTIL_GEOMETRY_H
12#define UTIL_GEOMETRY_H
26std::pair<util::Point, util::Point> &box);
34std::vector<std::pair<util::Point, util::Point>>
getEdges(
size_t dim,
const
35std::pair<util::Point, util::Point> &box);
44 const std::pair<util::Point, util::Point> &box);
55 const std::pair<util::Point, util::Point> &box);
66 const std::pair<util::Point, util::Point> &box);
81 const std::pair<util::Point, util::Point> &box);
93 double y_min,
double y_max);
116 double y_min,
double y_max,
double theta);
162std::vector<double> &radius_vec,
unsigned int dim);
178std::vector<double> &radius_vec,
unsigned int dim,
double &d);
197bool areBoxesNear(
const std::pair<util::Point, util::Point> & b1,
198 const std::pair<util::Point, util::Point> & b2,
210 const std::pair<util::Point, util::Point> &line_2);
220 const std::pair<util::Point, util::Point> &line_2);
230 const std::pair<util::Point, util::Point> &line_2);
242 const std::pair<util::Point, util::Point> &plane_2);
252 const std::pair<util::Point, util::Point> &line);
262 const std::pair<util::Point, util::Point> &line);
273 const std::pair<util::Point, util::Point> &plane);
306double computeMeshSize(
const std::vector<util::Point> &nodes,
size_t start,
315std::pair<util::Point, util::Point>
computeBBox(
const
316 std::vector<util::Point> &nodes);
334std::pair<util::Point, util::Point>
toPointBox(
const std::vector<double>
335 &p1,
const std::vector<double>
357inline T
l2Dist(
const std::vector<T> &x1,
const std::vector<T> &x2) {
359 if (x1.size() != x2.size())
360 throw std::invalid_argument(
"size of two vectors not matching");
363 for (
size_t i=0; i<x1.size(); i++)
364 sum += (x1[i] - x2[i]) * (x1[i] - x2[i]);
366 return std::sqrt(sum);
Collection of methods useful in simulation.
T l2Dist(const std::vector< T > &x1, const std::vector< T > &x2)
Computes l2 distance between two vectors.
bool isPointInsideBox(util::Point x, size_t dim, const std::pair< util::Point, util::Point > &box)
Returns true if point is inside box.
double pointDistanceLine(const util::Point &p, const std::pair< util::Point, util::Point > &line)
Compute distance between point and line.
double computeMeshSize(const std::vector< util::Point > &nodes)
Computes minimum distance between any two nodes.
bool isPointInsideEllipse(const util::Point &p, const util::Point ¢er, const std::vector< double > &radius_vec, unsigned int dim)
Returns true if point is inside the ellipsoid.
double pointDistancePlane(const util::Point &p, const std::pair< util::Point, util::Point > &plane)
Compute distance between point and plane.
bool areBoxesNear(const std::pair< util::Point, util::Point > &b1, const std::pair< util::Point, util::Point > &b2, const double &tol, size_t dim)
Checks if given two boxes are within given distance from each other.
bool doLinesIntersect(const std::pair< util::Point, util::Point > &line_1, const std::pair< util::Point, util::Point > &line_2)
Do lines intersect.
double distanceBetweenPlanes(const std::pair< util::Point, util::Point > &plane_1, const std::pair< util::Point, util::Point > &plane_2)
Compute distance between planes.
bool isPointInsideCuboid(util::Point x, util::Point x_lbb, util::Point x_rtf)
Checks if point is inside a cuboid.
std::vector< std::pair< util::Point, util::Point > > getEdges(size_t dim, const std::pair< util::Point, util::Point > &box)
Returns all corner points in the box.
std::vector< util::Point > getCornerPoints(size_t dim, const std::pair< util::Point, util::Point > &box)
Returns all corner points in the box.
util::Point getPointOnLine(const util::Point &p1, const util::Point &p2, const double &s)
Returns point in line formed by points p1 and p2.
double distanceBetweenLines(const std::pair< util::Point, util::Point > &line_1, const std::pair< util::Point, util::Point > &line_2)
Compute distance between lines.
std::pair< util::Point, util::Point > computeBBox(const std::vector< util::Point > &nodes)
Computes bounding box for vector nodes.
util::Point getCenter(size_t dim, const std::pair< util::Point, util::Point > &box)
Returns center point.
double distanceBetweenSegments(const std::pair< util::Point, util::Point > &line_1, const std::pair< util::Point, util::Point > &line_2)
Compute distance between lines.
double inscribedRadiusInBox(size_t dim, const std::pair< util::Point, util::Point > &box)
Computes the radius of biggest circle/sphere completely within the object.
bool isPointInsideAngledRectangle(util::Point x, double x_min, double x_max, double y_min, double y_max, double theta)
Checks if point is inside an angled rectangle.
bool isPointInsideCylinder(const util::Point &p, const double &length, const double &radius, const util::Point &axis)
Returns true if point is inside the cylinder.
double pointDistanceSegment(const util::Point &p, const std::pair< util::Point, util::Point > &line)
Compute distance between point and line.
std::pair< util::Point, util::Point > toPointBox(const std::vector< double > &p1, const std::vector< double > &p2)
Create box from two coordinate data.
double triangleArea(const util::Point &x1, const util::Point &x2, const util::Point &x3)
Compute area of triangle.
double computeInscribedRadius(const std::pair< util::Point, util::Point > &box)
Computes maximum radius of circle/sphere within a given box.
bool isPointInsideRectangle(util::Point x, double x_min, double x_max, double y_min, double y_max)
Checks if point is inside a rectangle.
double circumscribedRadiusInBox(size_t dim, const std::pair< util::Point, util::Point > &box)
Computes the radius of smallest circle/sphere which can have the box inside.
A structure to represent 3d vectors.