Planar computational geometry utility header.
More...
#include <stdbool.h>
#include "utils/abs.h"
#include "utils/vector2.h"
#include "utils/max.h"
#include "utils/min.h"
Go to the source code of this file.
Planar computational geometry utility header.
Winding and segment intersection tests built on vector2_t. All points must live in the same cartesian frame; units are arbitrary but must be consistent.
- Author
- Amruth Nadimpally (nadim.nosp@m.paa@.nosp@m.purdu.nosp@m.e.ed.nosp@m.u)
-
Aditya Saini (saini.nosp@m.91@p.nosp@m.urdue.nosp@m..edu)
◆ winding_t
| Enumerator |
|---|
| WINDING_COLLINEAR | |
| WINDING_CLOCKWISE | |
| WINDING_COUNTERCLOCKWISE | |
◆ segment2_contains_bounds()
Test whether a point falls inside a segment's bounding box.
Only meaningful for a point already known to be collinear with the segment, where it distinguishes lying on the segment from lying on its extension.
- Parameters
-
| segment | The input segment |
| point | The point to test |
- Returns
- True if the point is within the segment bounds.
◆ segment2_intersects()
Test whether two segments intersect, including collinear overlap.
- Parameters
-
| a | The first segment |
| b | The second segment |
- Returns
- True if the segments touch or cross anywhere.
◆ segment2_length()
| static float segment2_length |
( |
const segment2_t | segment | ) |
|
|
inlinestatic |
Calculate the length of a segment.
- Parameters
-
- Returns
- The distance between the segment endpoints.
◆ segment2_perpendicular_bisector()
| static segment2_t segment2_perpendicular_bisector |
( |
const segment2_t | segment, |
|
|
const float | half_length ) |
|
inlinestatic |
Build the segment perpendicular to a segment through its midpoint.
- Parameters
-
| segment | The segment to bisect |
| half_length | Distance the result extends either side of the midpoint |
- Returns
- The perpendicular bisector, degenerate if segment has no length.
◆ vector2_winding()
Determine which way the path a -> b -> c turns.
- Parameters
-
| a | The first point |
| b | The second point |
| c | The third point |
- Returns
- The winding direction of the three points.
◆ GEOMETRY_EPSILON
| float GEOMETRY_EPSILON = 1e-6f |
|
staticconstexpr |