header_utils
Loading...
Searching...
No Matches
intersection.h
1
4
5#pragma once
6
7#include "geometry_common.h"
8#include "shape_concepts.h"
9#include "circle.h"
10#include "triangles.h"
11#include "squares.h"
12#include "segment.h"
13#include "ray.h"
14#include "polygon.h"
15#include "ellipse.h"
16
17namespace ghassanpl::geometry
18{
21
22 template <typename T, typename U>
23 bool intersects(T const&, U const&) noexcept = delete;
24
25 template <typename T>
26 bool intersects(trec2<T> const& a, trec2<T> const& b) noexcept
27 {
28 return a.intersects(b);
29 }
30
31 template <typename T>
32 bool intersects<tcircle<T>, tcircle<T>>(tcircle<T> const& a, tcircle<T> const& b) noexcept
33 {
35 return glm::distance(a.center, b.center) < a.radius + b.radius;
36 }
37
38 /*
39 int c2CircletoAABB(c2Circle A, c2AABB B)
40 {
41 c2v L = c2Clampv(A.p, B.min, B.max);
42 c2v ab = c2Sub(A.p, L);
43 float d2 = c2Dot(ab, ab);
44 float r2 = A.r * A.r;
45 return d2 < r2;
46 }
47 */
49
50 template <typename T>
52 {
53 enum shape_relation relation {};
54 glm::tvec3<T> points_and_depths[2] {};
55 glm::tvec2<T> normal {};
56 };
57
58 template <typename T, typename U>
59 void intersection(T const&, U const&) noexcept = delete;
60
61}
glm::tvec2< T > normal
x,y - point, z - depth
bool intersects(T const &, U const &) noexcept=delete
TODO: Steal from: https://github.com/RandyGaul/cute_headers/blob/master/cute_c2.h.
Circle vs Capsule: https://github.com/RandyGaul/cute_headers/blob/master/cute_c2.h#L1393.
Represents a 2D rectangle polygon_shape.
Definition rec2.h:31