Visual Computing Library
|
List of intersection algorithms. More...
Functions | |
template<FaceConcept FaceType, PointConcept PointType> | |
bool | vcl::intersect (const FaceType &f, const Box< PointType > &box) |
Checks if a face intersects a box. | |
template<PointConcept PointType, FaceConcept FaceType> | |
bool | vcl::intersect (const Box< PointType > &box, const FaceType &f) |
Checks if a face intersects a box. | |
template<FaceConcept FaceType, PointConcept PointType, typename SScalar > | |
bool | vcl::intersect (const FaceType &f, const Sphere< SScalar > &sphere, PointType &witness, std::pair< SScalar, SScalar > &res) |
Compute the intersection between a sphere and a face, that may be also polygonal. | |
template<FaceConcept FaceType, typename SScalar > | |
bool | vcl::intersect (const FaceType &f, const Sphere< SScalar > &sphere) |
Compute the intersection between a sphere and a face, that may be also polygonal. | |
template<typename SScalar , FaceConcept FaceType> | |
bool | vcl::intersect (const Sphere< SScalar > &sphere, const FaceType &f) |
Compute the intersection between a sphere and a face, that may be also polygonal. | |
template<typename Obj1 , typename Obj2 > | |
auto | vcl::intersectFunction () |
Return a proper intersect function between a Obj1 object and an Obj2 object. | |
template<PlaneConcept PlaneType, Box3Concept BoxType> | |
bool | vcl::intersect (const PlaneType &plane, const BoxType &box) |
Checks if a plane intersects with a box. | |
template<Box3Concept BoxType, PlaneConcept PlaneType> | |
bool | vcl::intersect (const BoxType &box, const PlaneType &p) |
Checks if a plane intersects with a box. | |
template<PlaneConcept PlaneType, Segment3Concept SegmentType> | |
bool | vcl::intersect (const PlaneType &plane, const SegmentType &segment) |
Checks if a plane intersects with a segment. | |
template<Segment3Concept SegmentType, PlaneConcept PlaneType> | |
bool | vcl::intersect (const SegmentType &segment, const PlaneType &plane) |
Checks if a plane intersects with a segment. | |
template<PlaneConcept PlaneType, Segment3Concept SegmentType> | |
std::optional< typename SegmentType::PointType > | vcl::intersection (const PlaneType &plane, const SegmentType &segment) |
Returns the intersection point between a plane and a segment, if it exists. | |
template<SphereConcept SphereType, Box3Concept BoxType> | |
bool | vcl::intersect (const SphereType &sphere, const BoxType &box) |
Checks if a sphere intersects with a 3D box. | |
template<Box3Concept BoxType, SphereConcept SphereType> | |
bool | vcl::intersect (const BoxType &box, const SphereType &sphere) |
Checks if a sphere intersects with a 3D box. | |
template<Triangle2Concept TriangleType, Point2Concept PointType> | |
bool | vcl::intersect (const TriangleType &triangle, const PointType &point) |
Checks if a 2D point intersects with/is inside a given 2D triangle having its points in counterclockwise order. | |
template<Point2Concept PointType, Triangle2Concept TriangleType> | |
bool | vcl::intersect (const PointType &point, const TriangleType &triangle) |
Checks if a 2D point intersects with/is inside a given 2D triangle having its points in counterclockwise order. | |
template<Triangle3Concept TriangleType, Box3Concept BoxType> | |
bool | vcl::intersect (const TriangleType &triangle, const BoxType &box) |
Checks if a triangle intersects with a box. | |
template<Box3Concept BoxType, Triangle3Concept TriangleType> | |
bool | vcl::intersect (const BoxType &box, const TriangleType &triangle) |
Checks if a triangle intersects with a box. | |
template<Triangle3Concept TriangleType, SphereConcept SphereType, Point3Concept PointType, typename ScalarType > | |
bool | vcl::intersect (const TriangleType &triangle, const SphereType &sphere, PointType &witness, std::pair< ScalarType, ScalarType > &res) |
Compute the intersection between a sphere and a triangle. | |
template<Triangle3Concept TriangleType, SphereConcept SphereType> | |
bool | vcl::intersect (const TriangleType &triangle, const SphereType &sphere) |
Compute the intersection between a sphere and a triangle. | |
template<SphereConcept SphereType, Triangle3Concept TriangleType> | |
bool | vcl::intersect (const SphereType &sphere, const TriangleType &t) |
Compute the intersection between a sphere and a triangle. | |
List of intersection algorithms.
You can access these algorithms by including #include <vclib/algorithms/core/intersection.h>
bool vcl::intersect | ( | const Box< PointType > & | box, |
const FaceType & | f | ||
) |
Checks if a face intersects a box.
The function uses the separating axis theorem to test the overlap between a triangle and a box. If the face is a triangle, the function will use the intersect function between a triangle and a box. If the face is polygonal, the face is first triangulated using an earcut algorithm, and then for each triangle, the triangle-box intersection is computed.
FaceType | A type that satisfies the FaceConcept. |
PointType | A type that satisfies the PointConcept. |
[in] | f | The input face. |
[in] | box | The input box. |
bool vcl::intersect | ( | const BoxType & | box, |
const PlaneType & | p | ||
) |
Checks if a plane intersects with a box.
Uses the algorithm from https://gdbooks.gitbooks.io/3dcollisions/content/Chapter2/static_aabb_plane.html
PlaneType | The type of plane used in the intersection check. |
BoxType | The type of box used in the intersection check. |
[in] | plane | The plane to check intersection with. |
[in] | box | The box to check intersection with. |
bool vcl::intersect | ( | const BoxType & | box, |
const SphereType & | sphere | ||
) |
Checks if a sphere intersects with a 3D box.
SphereType | A type that satisfies the SphereConcept concept. |
BoxType | A type that satisfies the Box3Concept concept. |
[in] | sphere | The sphere to check for intersection. |
[in] | box | The box to check for intersection. |
bool vcl::intersect | ( | const BoxType & | box, |
const TriangleType & | triangle | ||
) |
Checks if a triangle intersects with a box.
The function uses the separating axis theorem to test the overlap between a triangle and a box. It tests for overlap in the following directions: 1) the {x,y,z}-directions (actually, since we use the AABB of the triangle we do not even need to test these) 2) normal of the triangle 3) cross product(edge from tri, {x,y,z}-direction)
TriangleType | A type that satisfies the Triangle3Concept concept. |
BoxType | A type that satisfies the Box3Concept concept. |
[in] | triangle | The triangle to test for intersection. |
[in] | box | The box to test for intersection with the triangle. |
https://gist.github.com/jflipts/fc68d4eeacfcc04fbdb2bf38e0911850
bool vcl::intersect | ( | const FaceType & | f, |
const Box< PointType > & | box | ||
) |
Checks if a face intersects a box.
The function uses the separating axis theorem to test the overlap between a triangle and a box. If the face is a triangle, the function will use the intersect function between a triangle and a box. If the face is polygonal, the face is first triangulated using an earcut algorithm, and then for each triangle, the triangle-box intersection is computed.
FaceType | A type that satisfies the FaceConcept. |
PointType | A type that satisfies the PointConcept. |
[in] | f | The input face. |
[in] | box | The input box. |
Compute the intersection between a sphere and a face, that may be also polygonal.
If the face is a triangle, the intersect function between triangle and sphere will be used. If the face is polygonal, the face is first triangulated using an earcut algorithm, and then for each triangle, the triangle-sphere intersection is computed.
[in] | f | the input face |
[in] | sphere | the input sphere |
bool vcl::intersect | ( | const FaceType & | f, |
const Sphere< SScalar > & | sphere, | ||
PointType & | witness, | ||
std::pair< SScalar, SScalar > & | res | ||
) |
Compute the intersection between a sphere and a face, that may be also polygonal.
If the face is a triangle, the intersect function between triangle and sphere will be used. If the face is polygonal, the face is first triangulated using an earcut algorithm, and then for each triangle, the triangle-sphere intersection is computed.
[in] | f | the input face |
[in] | sphere | the input sphere |
[out] | witness | the point on the triangle nearest to the center of the sphere (even when there isn't intersection) |
[out] | res | if not null, in the first item is stored the minimum distance between the face and the sphere, while in the second item is stored the penetration depth |
bool vcl::intersect | ( | const PlaneType & | plane, |
const BoxType & | box | ||
) |
Checks if a plane intersects with a box.
Uses the algorithm from https://gdbooks.gitbooks.io/3dcollisions/content/Chapter2/static_aabb_plane.html
PlaneType | The type of plane used in the intersection check. |
BoxType | The type of box used in the intersection check. |
[in] | plane | The plane to check intersection with. |
[in] | box | The box to check intersection with. |
bool vcl::intersect | ( | const PlaneType & | plane, |
const SegmentType & | segment | ||
) |
Checks if a plane intersects with a segment.
The function computes the projection of the segment endpoints onto the plane and checks if the endpoints are on opposite sides of the plane. If the endpoints are on opposite sides of the plane, the function returns true, indicating that an intersection exists.
PlaneType | The type of plane used in the intersection check. |
SegmentType | The type of segment used in the intersection check. |
[in] | plane | the plane to compute the intersection with. |
[in] | segment | the 3D segment to compute the intersection with. |
bool vcl::intersect | ( | const PointType & | point, |
const TriangleType & | triangle | ||
) |
Checks if a 2D point intersects with/is inside a given 2D triangle having its points in counterclockwise order.
Checks if a 3D point intersects/is inside a 3D triangle having its points in counterclockwise order.
The function checks if a point lies within a given triangle using barycentric coordinates. It first calculates the area of the triangle, and then calculates the barycentric coordinates of the point with respect to the triangle. If the barycentric coordinates satisfy certain conditions, then the point is considered to intersect with the triangle.
TriangleType | A type that satisfies the Triangle2Concept concept. |
PointType | A type that satisfies the Point2Concept concept. |
[in] | triangle | The triangle to test for intersection. |
[in] | point | The point to test for intersection with the triangle. |
TriangleType | A type that satisfies the Triangle3Concept concept. |
PointType | A type that satisfies the Point3Concept concept. |
[in] | triangle | The triangle to test for intersection. |
[in] | point | The point to test for intersection with the triangle. |
bool vcl::intersect | ( | const SegmentType & | segment, |
const PlaneType & | plane | ||
) |
Checks if a plane intersects with a segment.
The function computes the projection of the segment endpoints onto the plane and checks if the endpoints are on opposite sides of the plane. If the endpoints are on opposite sides of the plane, the function returns true, indicating that an intersection exists.
PlaneType | The type of plane used in the intersection check. |
SegmentType | The type of segment used in the intersection check. |
[in] | plane | the plane to compute the intersection with. |
[in] | segment | the 3D segment to compute the intersection with. |
Compute the intersection between a sphere and a face, that may be also polygonal.
If the face is a triangle, the intersect function between triangle and sphere will be used. If the face is polygonal, the face is first triangulated using an earcut algorithm, and then for each triangle, the triangle-sphere intersection is computed.
[in] | f | the input face |
[in] | sphere | the input sphere |
bool vcl::intersect | ( | const SphereType & | sphere, |
const BoxType & | box | ||
) |
Checks if a sphere intersects with a 3D box.
SphereType | A type that satisfies the SphereConcept concept. |
BoxType | A type that satisfies the Box3Concept concept. |
[in] | sphere | The sphere to check for intersection. |
[in] | box | The box to check for intersection. |
bool vcl::intersect | ( | const SphereType & | sphere, |
const TriangleType & | t | ||
) |
Compute the intersection between a sphere and a triangle.
[in] | triangle | the 3D input triangle |
[in] | sphere | the input sphere |
|
private |
Checks if a triangle intersects with a box.
The function uses the separating axis theorem to test the overlap between a triangle and a box. It tests for overlap in the following directions: 1) the {x,y,z}-directions (actually, since we use the AABB of the triangle we do not even need to test these) 2) normal of the triangle 3) cross product(edge from tri, {x,y,z}-direction)
TriangleType | A type that satisfies the Triangle3Concept concept. |
BoxType | A type that satisfies the Box3Concept concept. |
[in] | triangle | The triangle to test for intersection. |
[in] | box | The box to test for intersection with the triangle. |
https://gist.github.com/jflipts/fc68d4eeacfcc04fbdb2bf38e0911850
bool vcl::intersect | ( | const TriangleType & | triangle, |
const PointType & | point | ||
) |
Checks if a 2D point intersects with/is inside a given 2D triangle having its points in counterclockwise order.
Checks if a 3D point intersects/is inside a 3D triangle having its points in counterclockwise order.
The function checks if a point lies within a given triangle using barycentric coordinates. It first calculates the area of the triangle, and then calculates the barycentric coordinates of the point with respect to the triangle. If the barycentric coordinates satisfy certain conditions, then the point is considered to intersect with the triangle.
TriangleType | A type that satisfies the Triangle2Concept concept. |
PointType | A type that satisfies the Point2Concept concept. |
[in] | triangle | The triangle to test for intersection. |
[in] | point | The point to test for intersection with the triangle. |
TriangleType | A type that satisfies the Triangle3Concept concept. |
PointType | A type that satisfies the Point3Concept concept. |
[in] | triangle | The triangle to test for intersection. |
[in] | point | The point to test for intersection with the triangle. |
bool vcl::intersect | ( | const TriangleType & | triangle, |
const SphereType & | sphere | ||
) |
Compute the intersection between a sphere and a triangle.
[in] | triangle | the 3D input triangle |
[in] | sphere | the input sphere |
bool vcl::intersect | ( | const TriangleType & | triangle, |
const SphereType & | sphere, | ||
PointType & | witness, | ||
std::pair< ScalarType, ScalarType > & | res | ||
) |
Compute the intersection between a sphere and a triangle.
[in] | triangle | the 3D input triangle |
[in] | sphere | the input sphere |
[out] | witness | the point on the triangle nearest to the center of the sphere (even when there isn't intersection) |
[out] | res | if not null, in the first item is stored the minimum distance between the triangle and the sphere, while in the second item is stored the penetration depth |
Return a proper intersect function between a Obj1 object and an Obj2 object.
This function will return a function defined in a specialization of the struct IntersFunctionStruct.
The returned function is a std::function that takes in input two const references of the desired types and returns a boolean that tells if the two objects intersect.
If the intersection function for your types is not defined, you can write your own IntersFunctionStruct specialization that defines a proper static const inline
object called intersFun
of std::function
type.
std::optional< typename SegmentType::PointType > vcl::intersection | ( | const PlaneType & | plane, |
const SegmentType & | segment | ||
) |
Returns the intersection point between a plane and a segment, if it exists.
The function computes the projection of the segment endpoints onto the plane and checks if the endpoints are on opposite sides of the plane. If the endpoints are on opposite sides of the plane, the function computes and returns the intersection point between the plane and the segment.
If the endpoints are on the same side of the plane, or if the endpoints have the same projection onto the plane, the function returns an empty optional.
PlaneType | The type of plane used in the intersection check. |
SegmentType | The type of segment used in the intersection check. |
[in] | plane | the plane to compute the intersection with. |
[in] | segment | the 3D segment to compute the intersection with. |