KrisLibrary  1.0.0
Classes | Functions
Geometry Namespace Reference

Contains all definitions in the Geometry package. More...

Classes

struct  Angular2DOrdering
 
class  AnyCollisionGeometry3D
 An AnyGeometry with collision detection information. More...
 
class  AnyCollisionQuery
 A class that stores information regarding a collision query. May be slightly faster than running individual queries. More...
 
class  AnyContactsQueryResult
 
class  AnyContactsQuerySettings
 
class  AnyDistanceQueryResult
 
class  AnyDistanceQuerySettings
 
class  AnyGeometry3D
 A class that stores any kind of geometry we've defined. More...
 
class  ApproximatePenetrationDepth
 Uses a propagation method to calculate an approximate penetration distance of mesh m1 inside m2. More...
 
class  Arrangement1D
 An arrangement of 1-D intervals. Intervals identified by an integer ID. More...
 
class  BallTree
 
class  BallTreeNode
 A node of a ball-tree point location data structure. More...
 
struct  ClosestPointCallback
 
class  CollisionConvexHull3D
 The collision data class for ConvexHull3D that contains the solid3 data structure moved by some rigid transform. More...
 
class  CollisionImplicitSurface
 An implicit surface (usually signed-distance function) with a fast collision detection data structure. More...
 
class  CollisionMesh
 A triangle mesh along with PQP bounding volume structures that enable fast collision and other proximity queries. More...
 
class  CollisionMeshQuery
 A general-purpose distance querying class. More...
 
class  CollisionMeshQueryEnhanced
 
class  CollisionPointCloud
 A point cloud with a fast collision detection data structure. More...
 
class  ConvexHull3D
 A 3D convex hull class. More...
 
class  DenseTSDFReconstruction
 Performs a kinect-fusion-like dense TSDF reconstruction. More...
 
class  Grid
 A gridding of n-dimensional space. More...
 
class  GridHash
 An ND grid containing objects (referenced by void pointers) More...
 
class  GridHash3D
 A grid containing objects (referenced by void pointers) More...
 
class  GridSubdivision
 An ND grid with a list of arbitrary objects (given by void pointers) More...
 
class  GridSubdivision3D
 A grid with a list of arbitrary objects (given by void pointers) More...
 
class  GridTable
 A table with entry T on a gridding of n-dimensional space. More...
 
class  ICPParameters
 
struct  IndexHash
 
class  KDTree
 A kd-tree or a node of one. More...
 
class  LPSolvePointCallback
 Helper callback used in PolytopeProjection2D. More...
 
class  MultiVolumeGrid
 A 3D array over an axis-aligned 3D volume, containing one or more channels. More...
 
class  Octree
 
struct  OctreeNode
 
class  OctreePointSet
 Stores a point set P on an octree grid. Allows for O(d) adding, O(d h) range queries and pseudo-O(d) nearest neighbor queries. More...
 
class  OctreeScalarField
 Stores a function f(x) on an octree grid. Allows for O(d) setting, sub O(d) testing of f(x) in range [a,b], O(d h) selection of nodes with values in range [a,b]. More...
 
struct  Point2DWithID
 
class  PointPointCollider
 
struct  PointRay2D
 A 2D point or infinite ray. Note: rays should be normalized unit vectors. More...
 
struct  PointRay2DWithID
 
struct  PointRay3D
 A 3D point or infinite ray. Note: rays should be normalized unit vectors. More...
 
class  PolytopeProjection2D
 A method for projecting a polytope defined by the feasible set of a linear program lp onto a 2D subspace. Handles unbounded and infeasible problems. More...
 
struct  RayCastCallback
 
class  SegmentOverlay
 Computes the overlay of a set of segments using a sweep line algorithm. More...
 
class  SparseTSDFReconstruction
 Performs a kinect-fusion-like sparse TSDF reconstruction. A hash grid is used to build multiple TSDFs across an infinite domain. More...
 
class  SparseVolumeGrid
 A 3D array over a sparse, axis aligned 3D volume. Has a similar interface as VolumeGrid, but uses a hash grid data structure to achieve better performance in large grids with infinite domain. More...
 
struct  UnboundedPolytope2D
 A representation of a possibly unbounded polytope in the 2d plane. More...
 
struct  XMonotoneChain
 A polyline with vertices ordered in nondecreasing order. More...
 

Functions

void RigidTransformToPQP (const RigidTransform &f, PQP_REAL R[3][3], PQP_REAL T[3])
 
void GetMinMax (const Meshing::VolumeGrid *mingrid, const Meshing::VolumeGrid *maxgrid, const AABB3D &bb, Real &vmin, Real &vmax)
 
Real Distance (const CollisionImplicitSurface &s, const Vector3 &pt)
 
Real Distance (const CollisionImplicitSurface &s, const Vector3 &pt, Vector3 &surfacePt, Vector3 &direction)
 
Real Distance (const CollisionImplicitSurface &grid, const GeometricPrimitive3D &a, Vector3 &gridclosest, Vector3 &geomclosest, Vector3 &direction)
 
bool Collides (const CollisionImplicitSurface &s, const CollisionPointCloud &pc, Real margin, vector< int > &collidingPoints, size_t maxContacts)
 
Real DistanceLowerBound (const CollisionImplicitSurface &s, const CollisionPointCloud &pc, int nindex, const Matrix4 &Mpc_s)
 
Real Distance (const CollisionImplicitSurface &s, const CollisionPointCloud &pc, int &closestPoint, Real upperBound=Inf)
 Returns the distance and closest point to a CollisionPointCloud.
 
Real RayGridCellIntersect (const Ray3D &ray, const Meshing::VolumeGrid &grid, const IntTriple &c, Real umin, Real umax, Real levelSet, Real vtol=1e-3)
 
Real RayCast (const Meshing::VolumeGrid &grid, const Ray3D &ray, Real levelSet, Real tmax)
 
Real RayCast (const CollisionImplicitSurface &s, const Ray3D &rayWorld, Real levelSet, Real tmax)
 
bool Collides (const CollisionImplicitSurface &s, const CollisionPointCloud &pc, Real margin, std::vector< int > &collidingPoints, size_t maxContacts=1)
 
void PQPToRigidTransform (const PQP_REAL R[3][3], const PQP_REAL T[3], RigidTransform &f)
 
void ConvertTriToPQP (const TriMesh &tri, PQP_Model &pqp)
 
void CopyPQPModel (const PQP_Model *source, PQP_Model *dest)
 
bool OverlappingTriangleCollision (const CollisionMesh *m1, const CollisionMesh *m2, int a, int b, Vector3 &p1, Vector3 &p2)
 
void VEC3_COPY (PQP_REAL *res, const PQP_REAL *in)
 
Real distance (const Segment3D &s, const Point3D &p)
 
bool Collide (const Meshing::TriMesh &m1, const Meshing::TriMesh &m2)
 
bool WithinDistance (const Meshing::TriMesh &m1, const Meshing::TriMesh &m2, Real tol)
 
Real Distance (const Meshing::TriMesh &m1, const Meshing::TriMesh &m2, Real absErr, Real relErr)
 
Real ClosestPoints (const Meshing::TriMesh &m1, const Meshing::TriMesh &m2, Real absErr, Real relErr, Vector3 &p1, Vector3 &p2)
 
void Copy (const PQP_REAL p[3], Vector3 &x)
 
void Copy (const Vector3 &x, PQP_REAL p[3])
 
void BVToBox (const BV &b, Box3D &box)
 
void BoxToBV (const Box3D &box, BV &b)
 
int aabb_sphere_disjoint (const PQP_REAL box_dims[3], const PQP_REAL c[3], PQP_REAL r)
 
Real aabb_ray_collide (const PQP_REAL box_dims[3], const PQP_REAL s[3], const PQP_REAL d[3])
 
void ToLocal (const BV &b, const PQP_REAL p[3], PQP_REAL ploc[3])
 
void ToLocal (const BV &b, const Vector3 &in, Vector3 &out)
 
bool CollideBV (const PQP_REAL d[3], const Vector3 &pt)
 
void DistanceLimitsBV (const PQP_REAL d[3], const Vector3 &pt, Real &dmin, Real &dmax)
 
void ToLocal (const BV &bv, const Segment3D &in, Segment3D &out)
 
bool CollideBV (const PQP_REAL d[3], const Segment3D &s)
 
bool Collide (const Triangle3D &tri, const Segment3D &s, Vector3 &pt)
 
void ToLocal (const BV &bv, const Sphere3D &in, Sphere3D &out)
 
bool CollideBV (const PQP_REAL d[3], const Sphere3D &s)
 
bool Collide (const Triangle3D &tri, const Sphere3D &s, Vector3 &pt)
 
void ToLocal (const BV &bv, const BV &in, BV &out)
 
bool CollideBV (const PQP_REAL d[3], BV &bv)
 
bool Collide (const Triangle3D &tri, const BV &b, Vector3 &pt)
 
template<class Geom >
int CollideRecurse (const Geom &g, const PQP_Model &m, int b, Vector3 &pt)
 
template<class Geom >
void CollideAllRecurse (const Geom &g, const PQP_Model &m, int b, vector< int > &tris, size_t max)
 
int ClosestPoint (const CollisionMesh &mesh, const Vector3 &p, Vector3 &cp, Real bound)
 
int Collide (const CollisionMesh &m, const Segment3D &s, Vector3 &pt)
 
bool Collide (const CollisionMesh &m, const Sphere3D &s)
 Returns true if m intersects the given geometry.
 
bool Collide (const CollisionMesh &m, const AABB3D &bb)
 
bool Collide (const CollisionMesh &m, const Box3D &b)
 
bool Collide (const CollisionMesh &m, const GeometricPrimitive3D &g)
 
bool WithinDistance (const CollisionMesh &c, const GeometricPrimitive3D &a, Real d)
 
bool Collide (const CollisionMesh &m1, const CollisionMesh &m2)
 
void CollideAll (const CollisionMesh &m, const Sphere3D &s, vector< int > &tris, int max)
 Computes a list of triangles that overlap the geometry.
 
void CollideAll (const CollisionMesh &m, const Segment3D &s, vector< int > &tris, int max)
 
void CollideAll (const CollisionMesh &m, const AABB3D &bb, vector< int > &tris, int max)
 
void CollideAll (const CollisionMesh &m, const Box3D &bb, vector< int > &tris, int max)
 
void CollideAll (const CollisionMesh &m, const GeometricPrimitive3D &g, std::vector< int > &tris, int max)
 
bool WithinDistance (const CollisionMesh &m, const Vector3 &p, Real d)
 Returns true if p is within distance d of m using the PQP bounding heirarchy. More...
 
void NearbyTriangles (const CollisionMesh &m, const Vector3 &p, Real d, vector< int > &tris, int max)
 Computes the triangles in m within distance d to p on m. More...
 
void FitBox (const GeometricPrimitive3D &g, Box3D &box)
 
void NearbyTriangles (const CollisionMesh &m, const GeometricPrimitive3D &g, Real d, vector< int > &tris, int max)
 
void NearbyTriangles (const CollisionMesh &m1, const CollisionMesh &m2, Real d, vector< int > &tris1, vector< int > &tris2, int max)
 
Real Distance (const CollisionMesh &c, const Vector3 &pt, Real bound)
 
Real Distance (const CollisionMesh &c, const Vector3 &pt, int &closestTri, Vector3 &cp, Vector3 &dir, Real bound)
 
Real Distance (const CollisionMesh &c, const GeometricPrimitive3D &a, Real bound)
 
Real Distance (const CollisionMesh &c, const GeometricPrimitive3D &a, int &closestTri, Vector3 &cp, Vector3 &dir, Real bound)
 
int ClosestPointAndNormal (const TriMesh &m, Real pWeight, Real nWeight, const Vector3 &p, const Vector3 &n, Vector3 &cp)
 
int ClosestPointAndNormal (const CollisionMesh &mesh, Real nWeight, const Vector3 &p, const Vector3 &n, Vector3 &cp)
 
Real BVRayCollision (const BV &bv, const Ray3D &r)
 
int RayCast (const CollisionMesh &mesh, const Ray3D &r, Vector3 &pt)
 
int RayCastLocal (const CollisionMesh &mesh, const Ray3D &r, Vector3 &pt)
 
void GetBB (const CollisionMesh &m, Box3D &bb)
 Returns the bounding box containing m. More...
 
PQP_REAL TriDistance (PQP_REAL R[3][3], PQP_REAL T[3], Tri *t1, Tri *t2, PQP_REAL p[3], PQP_REAL q[3])
 
void CollideAll (const CollisionMesh &m, const Sphere3D &s, std::vector< int > &tris, int max=INT_MAX)
 Computes a list of triangles that overlap the geometry.
 
void CollideAll (const CollisionMesh &m, const Segment3D &s, std::vector< int > &tris, int max=INT_MAX)
 
void CollideAll (const CollisionMesh &m, const AABB3D &bb, std::vector< int > &tris, int max=INT_MAX)
 
void CollideAll (const CollisionMesh &m, const Box3D &b, std::vector< int > &tris, int max=INT_MAX)
 
bool WithinDistance (const CollisionMesh &m1, const CollisionMesh &m2, Real d)
 
void NearbyTriangles (const CollisionMesh &m, const Vector3 &p, Real d, std::vector< int > &tris, int max=INT_MAX)
 Computes the triangles in m within distance d to p on m. More...
 
void NearbyTriangles (const CollisionMesh &m, const GeometricPrimitive3D &g, Real d, std::vector< int > &tris, int max=INT_MAX)
 
void NearbyTriangles (const CollisionMesh &m1, const CollisionMesh &m2, Real d, std::vector< int > &tris1, std::vector< int > &tris2, int max=INT_MAX)
 
Real Distance (const CollisionMesh &m1, const CollisionMesh &m2, Real absErr, Real relErr, Real bound=Inf)
 Checks distance between two meshes (convenience function, equivalent to m1.Distance(m2))
 
void ClosestPoints (const CollisionMesh &m1, const CollisionMesh &m2, Real absErr, Real relErr, Vector3 &v1local, Vector3 &v2local, Real bound=Inf)
 
void GetBB (const CollisionPointCloud &pc, Box3D &b)
 Returns the oriented bounding box of the point cloud.
 
bool withinDistanceTest (void *obj)
 
bool WithinDistance (const CollisionPointCloud &pc, const GeometricPrimitive3D &g, Real tol)
 
bool distanceTest (void *obj)
 
Real Distance (const CollisionPointCloud &pc, const Vector3 &pt)
 Returns the nearest distance from any point in pc to g. O(log n) running time.
 
Real Distance (const CollisionPointCloud &pc, const Vector3 &pt, int &closestPoint, Real upperBound)
 
Real Distance (const CollisionPointCloud &pc, const GeometricPrimitive3D &g)
 
Real Distance (const CollisionPointCloud &pc, const GeometricPrimitive3D &g, int &closestPoint, Real upperBound)
 
Real Distance (const CollisionPointCloud &pc1, const CollisionPointCloud &pc2, int &closestPoint1, int &closestPoint2, Real upperBound)
 
bool nearbyTest (void *obj)
 
void NearbyPoints (const CollisionPointCloud &pc, const GeometricPrimitive3D &g, Real tol, std::vector< int > &pointIds, size_t maxContacts)
 
int RayCast (const CollisionPointCloud &pc, Real rad, const Ray3D &r, Vector3 &pt)
 
int RayCastLocal (const CollisionPointCloud &pc, Real rad, const Ray3D &r, Vector3 &pt)
 
Real Volume (const AABB3D &bb)
 
Real Volume (const OctreeNode &n)
 
bool Collides (const CollisionPointCloud &a, const CollisionPointCloud &b, Real margin, std::vector< int > &apoints, std::vector< int > &bpoints, size_t maxContacts)
 
void SubdivideAdd (const Triangle3D &t, Meshing::PointCloud3D &pc, Real maxDispersion2)
 
void MeshToPointCloud (const Meshing::TriMesh &mesh, Meshing::PointCloud3D &pc, Real maxDispersion=Inf, bool wantNormals=false)
 Places points on the vertices of a mesh. If any triangle has vertices farther away than maxDispersion, the triangle is subdivided until all triangles are covered by balls of radius maxDispersion.
 
void PointCloudToMesh (const Meshing::PointCloud3D &pc, Meshing::TriMesh &mesh, GLDraw::GeometryAppearance &appearance, Real depthDiscontinuity=Inf)
 Same as normal PointCloudToMesh, but colors and UV coordinates are extracted.
 
void PointCloudToMesh (const Meshing::PointCloud3D &pc, Meshing::TriMesh &mesh, Real depthDiscontinuity=Inf)
 If a point cloud is structured, this creates a uniform mesh out of it. If depthDiscontinuity is provided, the mesh is split at the points where the relative depth of adjacent points is greater than depthDiscontinuity * average depth. (A decent value is 0.02 for typical depth sensors.)
 
void PrimitiveToMesh (const GeometricPrimitive3D &primitive, Meshing::TriMesh &mesh, int numDivs)
 Creates a mesh for a geometric primitive. If the primitive has curved surfaces, they are split into numDivs strips.
 
void FitGridToBB (const AABB3D &bb, Meshing::VolumeGrid &grid, Real resolution, Real expansion=0.5)
 
void PrimitiveToImplicitSurface (const GeometricPrimitive3D &primitive, Meshing::VolumeGrid &grid, Real resolution, Real expansion=0)
 Creates an implicit surface for a geometric primitive. The grid has resolution no more than resolution on each axis.
 
void Extrema (const AABB3D &bb, const Vector3 &dir, Real &a, Real &b)
 
void SpaceCarving (const CollisionMesh &mesh, const Vector3 &d, const Vector3 &x, const Vector3 &y, Meshing::VolumeGrid &grid, Array3D< Real > &occupancy, Real resolution, bool firstPass=true)
 
void SaveSliceCSV (const Array3D< Real > &values, const char *fn)
 
void MeshToImplicitSurface_FMM (const CollisionMesh &mesh, Meshing::VolumeGrid &grid, Real resolution)
 Creates an implicit surface for a mesh using a Fast Marching Method. More...
 
void MeshToImplicitSurface_SpaceCarving (const CollisionMesh &mesh, Meshing::VolumeGrid &grid, Real resolution, int numViews=20)
 Creates an implicit surface for a mesh using a space-carving technique. The grid has resolution no less than resolution on each axis. numViews views (6 orthographic, numViews-6 random) are taken of the mesh to create the space carving. More...
 
void ImplicitSurfaceToMesh (const Meshing::VolumeGrid &grid, Meshing::TriMesh &mesh, Real levelSet=0.0)
 Creates a mesh from an implicit surface via Marching Cubes. This assumes the values of the grid are defined at the cell centers, unlike the methods in MarchingCubes.h which assume the array defines values at the cell corners... this performs the necessary correction.
 
void MeshToConvexHull (const Meshing::TriMesh &mesh, ConvexHull3D &ch)
 Creates a convex hull from a mesh.
 
void PointCloudToConvexHull (const Meshing::PointCloud3D &pc, ConvexHull3D &ch)
 Creates a convex hull from a point cloud.
 
void _HACD_CallBack (const char *msg, double progress, double concavity, size_t nVertices)
 
void MeshConvexDecomposition (const Meshing::TriMesh &mesh, ConvexHull3D &ch, Real concavity)
 Computes a convex decomposition of the mesh. concavity can be set to > 0 to compute an approximate convex decomposition using the HACD algorithm. More...
 
void AppendPoints (const ConvexHull3D &ch, vector< Vector3 > &points)
 
void ConvexHullToMesh (const ConvexHull3D &ch, Meshing::TriMesh &mesh)
 
template<typename Point , typename OrientFunc >
int ConvexHull2D_ChainTemplate (const Point P[], int n, Point H[], OrientFunc Orient)
 
int ConvexHull2D_Chain (const Point2D P[], int n, Point2D H[])
 Compute the convex hull of a set of sorted points (or point-rays) More...
 
int ConvexHull2D_Chain (const PointRay2D P[], int n, PointRay2D H[])
 
int ConvexHull2D_Chain (const Point2D P[], int n, Point2D H[], int Hindex[])
 
int ConvexHull2D_Chain (const PointRay2D P[], int n, PointRay2D H[], int Hindex[])
 
int ConvexHull2D_Chain_Unsorted (Point2D P[], int n, Point2D H[])
 Same as above, but unsorted input. Upon exit, the contents of P are rearranged in lexicographical order.
 
int ConvexHull2D_Chain_Unsorted (PointRay2D P[], int n, PointRay2D H[])
 
int ConvexHull2D_Chain_Unsorted (Point2D P[], int n, Point2D H[], int Hindex[])
 
int ConvexHull2D_Chain_Unsorted (PointRay2D P[], int n, PointRay2D H[], int Hindex[])
 
void Point2DListToPlanes (const Point2D P[], int n, Plane2D H[])
 Given a list of points on a convex hull, return a list of planes along edges with normals pointing outward. More...
 
int Point2DListToPlanes (const PointRay2D P[], int n, Plane2D H[])
 
bool ConvexHull3D_Qhull (const vector< Vector3 > &points, vector< vector< int > > &facets)
 Computes the convex hull of the point set using the Qhull library. More...
 
bool ConvexHull3D_Qhull (const vector< double > &points, vector< vector< int > > &facets)
 
bool ConvexHull3D_Qhull (const std::vector< Vector3 > &points, std::vector< IntTriple > &tris)
 Computes the convex hull of the point set using the Qhull library. More...
 
DT_ShapeHandle _MakePolytope (const vector< double > &points)
 
std::tuple< Real, Vector3, Vector3dist_func (DT_ObjectHandle object1, DT_ObjectHandle object2)
 
std::ostream & operator<< (std::ostream &out, const ConvexHull3D &b)
 
std::istream & operator>> (std::istream &in, ConvexHull3D &b)
 
bool ConvexHull3D_Qhull (const std::vector< Vector3 > &points, std::vector< std::vector< int > > &facets)
 Computes the convex hull of the point set using the Qhull library. More...
 
bool ConvexHull3D_Qhull (const std::vector< double > &points, std::vector< std::vector< int > > &facets)
 
void Rank1Update (Matrix2 &m, const Vector2 &x, const Vector2 &y)
 
void Rank1Update (Matrix3 &m, const Vector3 &x, const Vector3 &y)
 
Vector2 GetMean (const vector< Vector2 > &pts)
 
Vector3 GetMean (const vector< Vector3 > &pts)
 
void GetCovariance (const vector< Vector2 > &pts, Matrix2 &C)
 
void GetCovariance (const vector< Vector3 > &pts, Matrix3 &C)
 
bool FitGaussian (const vector< Vector2 > &pts, Vector2 &mean, Matrix2 &R, Vector2 &axes)
 
bool FitGaussian (const vector< Vector3 > &pts, Vector3 &mean, Matrix3 &R, Vector3 &axes)
 
bool FitLine (const vector< Vector2 > &pts, Line2D &l)
 
bool FitLine (const vector< Vector3 > &pts, Line3D &l)
 
bool FitPlane (const vector< Vector3 > &pts, Plane3D &p)
 
bool FitCircle (const std::vector< Vector2 > &pts, Circle2D &c)
 
Vector2 GetMean (const std::vector< Vector2 > &pts)
 
Vector3 GetMean (const std::vector< Vector3 > &pts)
 
void GetCovariance (const std::vector< Vector2 > &pts, Matrix2 &C)
 
void GetCovariance (const std::vector< Vector3 > &pts, Matrix3 &C)
 
bool FitGaussian (const std::vector< Vector2 > &pts, Vector2 &center, Matrix2 &R, Vector2 &axes)
 
bool FitGaussian (const std::vector< Vector3 > &pts, Vector3 &center, Matrix3 &R, Vector3 &axes)
 
bool FitLine (const std::vector< Vector2 > &pts, Line2D &l)
 
bool FitLine (const std::vector< Vector3 > &pts, Line3D &l)
 
bool FitPlane (const std::vector< Vector3 > &pts, Plane3D &p)
 
void NeighborGraph (const Meshing::PointCloud3D &pc, Real R, Graph::UndirectedGraph< int, int > &G)
 
void NeighborGraph (const vector< Vector3 > &pc, Real R, Graph::UndirectedGraph< int, int > &G)
 
void NearestNeighborGraph (const Meshing::PointCloud3D &pc, int k, Graph::Graph< int, int > &G)
 
void NearestNeighborGraph (const vector< Vector3 > &pc, int k, Graph::Graph< int, int > &G)
 
bool Lexical2DOrder (const Point2D &p1, const Point2D &p2)
 Lexical < order on 2D points.
 
bool Lexical3DOrder (const Point3D &p1, const Point3D &p2)
 Lexical < order on 3D points.
 
Real Orient2D (const Point2D &p0, const Point2D &p1, const Point2D &p2)
 Orientation of p2 relative to p1, relative to p0. More...
 
Real HomogeneousCmp (Real a, bool awZero, Real b, bool bwZero)
 Comparison of 1D points in homogeneous coordinates. More...
 
Real HomogeneousSub (Real a, bool awZero, Real b, bool bwZero)
 Subtraction of 1D points in homogeneous coordinates.
 
bool LexicalRay2DOrder (const PointRay2D &p1, const PointRay2D &p2)
 
bool LexicalRay3DOrder (const PointRay3D &p1, const PointRay3D &p2)
 
Real OrientRay2D (const PointRay2D &p0, const PointRay2D &p1, const PointRay2D &p2)
 
bool SweepLineOrder (const Point2D &a, const Point2D &b)
 

Detailed Description

Contains all definitions in the Geometry package.

Function Documentation

int Geometry::ClosestPoint ( const CollisionMesh m,
const Vector3 p,
Vector3 cplocal,
Real  bound = Inf 
)

Finds the closest point pt to p on m and returns the triangle index. The closest point is cplocal, given in the mesh's local frame If bound is given, this will quit and return -1 if the closest point is known to be farther than bound.

References ClosestPoint(), and Math3D::RigidTransform::mulInverse().

Referenced by ClosestPoint(), Distance(), Geometry::AnyCollisionGeometry3D::SetTransform(), and Geometry::BallTree::TreeSize().

int Geometry::ClosestPointAndNormal ( const Meshing::TriMesh m,
Real  pWeight,
Real  nWeight,
const Vector3 p,
const Vector3 n,
Vector3 cp 
)

Returns the point on the mesh that minimizes pWeight||p-x||^2 + nWeight||n-nx||^2. The point x is returned in cp, and the triangle index is the return value.

References ClosestPointAndNormal(), and Meshing::TriMesh::GetTriangle().

Referenced by ClosestPointAndNormal().

int Geometry::ClosestPointAndNormal ( const CollisionMesh mesh,
Real  nWeight,
const Vector3 p,
const Vector3 n,
Vector3 cplocal 
)

Same as above, but uses the PQP bounding heirarchy and assumes pWeight = 1.

p and n are assumed given in world coordinates, with the mesh's current transform taken into account.

The closest point is cplocal, which is given in mesh-local coordinates

References ClosestPointAndNormal(), Math3D::RigidTransform::mulInverse(), and Math3D::Matrix3::mulTranspose().

void Geometry::ClosestPoints ( const CollisionMesh m1,
const CollisionMesh m2,
Real  absErr,
Real  relErr,
Vector3 v1local,
Vector3 v2local,
Real  bound = Inf 
)

Convenience function to compute closest points between two meshes. v1 and v2 are in their respective mesh's local coordinates If bound is given, this will quit and return far away points if the closest points is known to be farther than bound.

int Geometry::Collide ( const CollisionMesh m,
const Segment3D s,
Vector3 pt 
)

Checks for collision between s and m. Returns the index of the tri, or -1 if none, and computes the intersecting point pt.

References Math3D::RigidTransform::mulInverse().

bool Geometry::Collides ( const CollisionImplicitSurface s,
const CollisionPointCloud pc,
Real  margin,
std::vector< int > &  collidingPoints,
size_t  maxContacts = 1 
)
bool Geometry::Collides ( const CollisionImplicitSurface s,
const CollisionPointCloud pc,
Real  margin,
std::vector< int > &  collidingPoints,
size_t  maxContacts = 1 
)
bool Geometry::Collides ( const CollisionPointCloud pc1,
const CollisionPointCloud pc2,
Real  margin,
std::vector< int > &  points1,
std::vector< int > &  points2,
size_t  maxContacts = 1 
)

Returns true if the point clouds are within margin distance of one another. points1 and points2 return one or more pairs of close-by points. maxContacts controls how many pairs are computed.

void Geometry::ConvexHullToMesh ( const ConvexHull3D ch,
Meshing::TriMesh mesh 
)

Computes a mesh from a ConvexHull. Uses Qhull.

References ConvexHull3D_Qhull().

Referenced by GLDraw::GeometryAppearance::Refresh().

Real Geometry::Distance ( const CollisionImplicitSurface s,
const Vector3 pt 
)

Returns the distance between s and pt, assuming it's a signed distance field. Negative values indicate interior points. Input is in world coordinates.

References Geometry::CollisionImplicitSurface::baseGrid, Geometry::CollisionImplicitSurface::currentTransform, Math3D::RigidTransform::mulInverse(), and Meshing::VolumeGridTemplate< T >::TrilinearInterpolate().

Referenced by Geometry::KDTree::ClosePoints(), Geometry::KDTree::Select(), and Geometry::AnyCollisionGeometry3D::SetTransform().

Real Geometry::Distance ( const CollisionImplicitSurface s,
const Vector3 pt,
Vector3 surfacePt,
Vector3 direction 
)

Returns the distance between s and pt, assuming s is a signed distance field. Negative values indicate interior points.

Outputs:

  • surfacePt is the closest point on the surface
  • direction is the unit normal in the direction of decreasing signed distance. If pt is outside, this points toward surfacePt, but if pt is inside, this points further into s.

Inputs and outputs are all in world coordinates.

References Geometry::CollisionImplicitSurface::baseGrid, Geometry::CollisionImplicitSurface::currentTransform, Meshing::VolumeGridTemplate< T >::Gradient(), Math3D::RigidTransform::mulInverse(), and Meshing::VolumeGridTemplate< T >::TrilinearInterpolate().

Real Geometry::Distance ( const CollisionImplicitSurface s,
const GeometricPrimitive3D geom,
Vector3 surfacePt,
Vector3 geomPt,
Vector3 direction 
)

Same as above, except that:

  • geomPt is the closest/deepest point on geom.
  • direction is the unit normal of decreasing distance, in that if geom is moved in this direction, the distance decreases.

Only points and spheres are currently supported

References GET_LOGGER.

Real Geometry::Distance ( const CollisionPointCloud pc,
const Vector3 pt,
int &  closestPoint,
Real  upperBound 
)

Returns the nearest distance from any point in pc to g. O(log n) running time. Saves the closest point index into ClosestPoint. If upperBound is given, and if no point is closer than upperBound, this may return upperBound as the return value and closestPoint=-1.

References Geometry::CollisionPointCloud::currentTransform, and Math3D::RigidTransform::mulInverse().

Real Geometry::Distance ( const CollisionPointCloud pc,
const GeometricPrimitive3D g 
)

Returns the nearest distance from any point in pc to g. O(log n) running time for points and spheres, O(n) running time for everythign else.

Real Geometry::Distance ( const CollisionPointCloud pc,
const GeometricPrimitive3D g,
int &  closestPoint,
Real  upperBound = Inf 
)

Returns the nearest distance from any point in pc to g. O(log n) running time for points and spheres, O(n) running time for everything else. Saves the closest point index into closestPoint. If upperBound is given, and if no point is closer than upperBound, this may return upperBound as the return value and closestPoint=-1.

References Geometry::CollisionPointCloud::bblocal, Geometry::CollisionPointCloud::currentTransform, Math::IsInf(), and Geometry::CollisionPointCloud::radiusIndex.

Real Geometry::Distance ( const CollisionPointCloud pc1,
const CollisionPointCloud pc2,
int &  closestPoint1,
int &  closestPoint2,
Real  upperBound = Inf 
)

Returns the nearest distance from any point in pc1 to any point in pc2. O(n log n) running time. Saves the closest point pair into closestPoint1 and closestPoint2. If upperBound is given, then if no pair of points is closer than upperBound, this may return upperBound as the return distance and closestPoint1=closestPoint2=-1.

References Geometry::CollisionPointCloud::currentTransform, and Geometry::CollisionPointCloud::radiusIndex.

Real Geometry::Distance ( const CollisionMesh m,
const Vector3 p,
Real  bound = Inf 
)

Returns the nearest distance from any point in m to g. O(log n) running time. If the distance is > bound, then this terminates early and returns bound.

References ClosestPoint().

Real Geometry::Distance ( const CollisionMesh m,
const Vector3 p,
int &  closestTri,
Vector3 surfacePt,
Vector3 direction,
Real  bound = Inf 
)

Same as the above, but with additional outputs

Outputs

  • surfacePt is the closest point on the surface, in world coordinates
  • direction is the unit normal from the surface to p, in world coordinates

References ClosestPoint(), Math::FuzzyZero(), and Meshing::TriMesh::TriangleNormal().

Real Geometry::Distance ( const CollisionMesh m,
const GeometricPrimitive3D g,
Real  bound = Inf 
)

Returns the nearest distance from any point in m to g. O(log n) running time for point / sphere, O(n) otherwise. If the distance is > bound, then this terminates early and returns bound.

Real Geometry::Distance ( const CollisionMesh m,
const GeometricPrimitive3D g,
int &  closestTri,
Vector3 surfacePt,
Vector3 direction,
Real  bound = Inf 
)

Same as the above, but with additional outputs

Outputs

  • surfacePt is the closest point on the surface, in world coordinates
  • direction is the unit normal from the surface to the closest / deepest point on g, in world coordinates

References GET_LOGGER, and Meshing::TriMesh::GetTriangle().

void Geometry::FitBox ( const GeometricPrimitive3D g,
Box3D box 
)
void Geometry::GetBB ( const CollisionMesh m,
Box3D bb 
)
void Geometry::NearbyPoints ( const CollisionPointCloud pc,
const GeometricPrimitive3D g,
Real  tol,
std::vector< int > &  points,
size_t  maxContacts = std::numeric_limits< size_t >::max() 
)

Computes the set of points in the pc that are within tol distance of the primitive g. O(min(n,c)) running time, where c is the number of grid cells within distance tol of the bounding box of g.

References Geometry::CollisionPointCloud::bblocal, Geometry::CollisionPointCloud::currentTransform, GetBB(), Geometry::CollisionPointCloud::maxRadius, and Geometry::CollisionPointCloud::radiusIndex.

Referenced by Geometry::AnyCollisionGeometry3D::SetTransform().

void Geometry::NearbyTriangles ( const CollisionMesh m,
const Vector3 p,
Real  d,
vector< int > &  tris,
int  max 
)

Computes the triangles in m within distance d to p on m.

Finds the triangles within distance d to p on m using the PQP bounding heirarchy

References CollideAll(), and NearbyTriangles().

Referenced by FitBox(), NearbyTriangles(), and Geometry::AnyCollisionGeometry3D::SetTransform().

void Geometry::NearbyTriangles ( const CollisionMesh m,
const Vector3 p,
Real  d,
vector< int > &  tris,
int  max 
)

Computes the triangles in m within distance d to p on m.

Finds the triangles within distance d to p on m using the PQP bounding heirarchy

References CollideAll(), and NearbyTriangles().

Referenced by FitBox(), NearbyTriangles(), and Geometry::AnyCollisionGeometry3D::SetTransform().

void Geometry::NearestNeighborGraph ( const Meshing::PointCloud3D pc,
int  k,
Graph::Graph< int, int > &  G 
)

Computes a graph where each node is an index of a point in the point cloud and each edge connects points (i,j) for which j is a k-nearest neighbor (in Euclidean space)

void Geometry::NearestNeighborGraph ( const vector< Vector3 > &  pc,
int  k,
Graph::Graph< int, int > &  G 
)

Computes a graph where each node is an index of a point in the point cloud and each edge connects points (i,j) for which j is a k-nearest neighbor (in Euclidean space)

References ArrayUtils::copy(), Geometry::KDTree::Create(), and Geometry::KDTree::KClosestPoints().

void Geometry::NeighborGraph ( const Meshing::PointCloud3D pc,
Real  R,
Graph::UndirectedGraph< int, int > &  G 
)

Computes a graph where each node is an index of a point in the point cloud and each edge connects points within distance R (in Euclidean space)

void Geometry::NeighborGraph ( const vector< Vector3 > &  pc,
Real  R,
Graph::UndirectedGraph< int, int > &  G 
)

Computes a graph where each node is an index of a point in the point cloud and each edge connects points within distance R (in Euclidean space)

References Geometry::GridSubdivision::Insert().

int Geometry::RayCast ( const CollisionPointCloud pc,
Real  rad,
const Ray3D r,
Vector3 pt 
)

Casts a ray at the point cloud (where each point is fattened by radius rad). Returns index of the first point hit (-1 if none) and the colliding point in pt.

References Geometry::CollisionPointCloud::currentTransform, Math3D::RigidTransform::mulInverse(), Math3D::Matrix3::mulTranspose(), and RayCastLocal().

Real Geometry::RayCast ( const Meshing::VolumeGrid grid,
const Ray3D ray,
Real  levelSet,
Real  tmax 
)

Returns the distance to the closest point on the implicit surface defined at the given level set. The algorithm marches along cells intersected by the ray until a zero-crossing is met (O(n)) where n is the resolution of the grid.

Returns the distance to the closest point on the implicit surface defined at the given level set. tmax will be returned if no collision is found.

The algorithm marches along cells intersected by the ray until a zero-crossing is met (O(n)) where n is the resolution of the grid.

References Meshing::GetSegmentCells(), RayCast(), and Meshing::VolumeGridTemplate< T >::TrilinearInterpolate().

Referenced by Geometry::AnyCollisionGeometry3D::ClearCollisionData(), PrimitiveToImplicitSurface(), and RayCast().

Real Geometry::RayCast ( const CollisionImplicitSurface s,
const Ray3D rayWorld,
Real  levelSet,
Real  tmax 
)

Returns the distance to the closest point on the implicit surface defined at the given level set. The algorithm uses the collision hierarchy (O(log n) where n is the resolution of the grid.

Returns the distance to the closest point on the implicit surface defined at the given level set. tmax will be returned if no collision is found.

The algorithm uses the collision hierarchy (O(log n) where n is the resolution of the grid.

References Geometry::CollisionImplicitSurface::baseGrid, Geometry::CollisionImplicitSurface::currentTransform, Meshing::VolumeGridTemplate< T >::GetIndexRange(), Meshing::VolumeGridTemplate< T >::GetIndexRangeClamped(), Meshing::GetSegmentCells(), Geometry::CollisionImplicitSurface::minHierarchy, Math3D::RigidTransform::mulInverse(), Math3D::Matrix3::mulTranspose(), RayCast(), and Meshing::VolumeGridTemplate< T >::TrilinearInterpolate().

int Geometry::RayCast ( const CollisionMesh m,
const Ray3D r,
Vector3 pt 
)

Casts a ray at the mesh. Returns the index of the first triangle hit (-1 if none) and stores the colliding point in pt (given in world coordinates).

References RayCast().

int Geometry::RayCastLocal ( const CollisionPointCloud pc,
Real  rad,
const Ray3D r,
Vector3 pt 
)

Same as RayCast, but the ray (and colliding point) are in the local frame of the point cloud

References Geometry::CollisionPointCloud::bblocal.

int Geometry::RayCastLocal ( const CollisionMesh m,
const Ray3D r,
Vector3 pt 
)

Same as RayCast, but the ray (and colliding point) are in the local frame of the mesh

References RayCastLocal().

Referenced by RayCast(), and RayCastLocal().

bool Geometry::WithinDistance ( const CollisionPointCloud pc,
const GeometricPrimitive3D g,
Real  tol 
)

Computes whether any point in the pc is within tol distance of the primitive g. O(min(n,c)) running time, where c is the number of grid cells within distance tol of the bounding box of g.

References Geometry::CollisionPointCloud::bblocal, Geometry::CollisionPointCloud::currentTransform, GetBB(), Geometry::CollisionPointCloud::maxRadius, and Geometry::CollisionPointCloud::radiusIndex.

bool Geometry::WithinDistance ( const CollisionMesh m,
const Vector3 p,
Real  d 
)

Returns true if p is within distance d of m using the PQP bounding heirarchy.

Returns true if m is within distance d of the geometry.