#include <stdint.h>
Go to the source code of this file.
Classes | |
struct | r2d_rvec2 |
Vector struct. More... | |
struct | r2d_dvec2 |
Integer vector struct for grid indexing. More... | |
struct | r2d_plane |
A plane. More... | |
struct | r2d_orientation |
Perpendicular distances and bit flags for up to 6 faces. More... | |
struct | r2d_vertex |
A doubly-linked vertex. More... | |
struct | r2d_poly |
A polygon. More... | |
struct | r2d_dest_grid |
Destination grid information. More... | |
Macros | |
#define | R2D_MAX_VERTS 64 |
Typedefs | |
typedef double | r2d_real |
Real type specifying the precision to be used in calculations. More... | |
typedef int32_t | r2d_int |
Integer type used for grid indexing and bit flags. More... | |
typedef int64_t | r2d_long |
Long integer type used for grid indexing. More... | |
Functions | |
void | r2d_rasterize_quad (r2d_plane *faces, r2d_dest_grid *grid) |
Rasterize a convex quadrilateral to the destination grid. More... | |
void | r2d_clip_quad (r2d_poly *poly, unsigned char andcmp) |
Clip a polygon against four clip planes (find its intersection with a quadrilateral). More... | |
void | r2d_reduce (r2d_poly *poly, r2d_int polyorder, r2d_real *moments) |
Integrate a polynomial density over a polygon using simplicial decomposition. More... | |
void | r2du_init_box (r2d_poly *poly, r2d_rvec2 rbounds[2]) |
Initialize a polygon as an axis-aligned box. More... | |
void | r2du_faces_from_verts (r2d_rvec2 *verts, r2d_int nverts, r2d_plane *faces) |
Get faces (unit normals and distances to the origin) from an ordered-vertex description of a convex polygon. More... | |
r2d_real | r2du_orient (r2d_rvec2 pa, r2d_rvec2 pb, r2d_rvec2 pc) |
Get the signed area of the triangle defined by the input vertices. More... | |
Macro Definition Documentation
◆ R2D_MAX_VERTS
#define R2D_MAX_VERTS 64 |
Typedef Documentation
◆ r2d_int
typedef int32_t r2d_int |
Integer type used for grid indexing and bit flags.
◆ r2d_long
typedef int64_t r2d_long |
Long integer type used for grid indexing.
◆ r2d_real
typedef double r2d_real |
Real type specifying the precision to be used in calculations.
Default is double
(recommended). float
precision is enabled by compiling with -DSINGLE_PRECISION
.
Function Documentation
◆ r2d_clip_quad()
void r2d_clip_quad | ( | r2d_poly * | poly, |
unsigned char | andcmp | ||
) |
Clip a polygon against four clip planes (find its intersection with a quadrilateral).
- Parameters
-
[in,out] poly The polygon to be clipped. The distances to the clip plane and bit flags in poly.verts[...].orient
must be set prior to calling this function.[in] andcmp Set of bit flags allowing faces to be skipped. Face f
will be skipped ifandcmp & (1 << f)
evaluates totrue
.
◆ r2d_rasterize_quad()
void r2d_rasterize_quad | ( | r2d_plane * | faces, |
r2d_dest_grid * | grid | ||
) |
Rasterize a convex quadrilateral to the destination grid.
- Parameters
-
[in] faces The four faces of the quadrilateral to be voxelized. [in,out] grid The destination grid buffer that the quadrilateral will be voxelized to. The results of the rasterization are found in grid.moments
.
◆ r2d_reduce()
Integrate a polynomial density over a polygon using simplicial decomposition.
- Parameters
-
[in] poly The polygon over which to integrate. [in] polyorder Order of the polynomial density field. 0 for constant (1 moment), 1 for linear (3 moments), 2 for quadratic (6 moments). [in,out] moments Array to be filled with the integration results, up to the sepcified polyorder
. Order of moments is1
,x
,y
,x^2
,y^2
,x*y
.
◆ r2du_faces_from_verts()
Get faces (unit normals and distances to the origin) from an ordered-vertex description of a convex polygon.
- Parameters
-
[in] verts List of polygon vertices. [in] nverts Number of polygon vertices in the list. [out] faces Array of planes defining the faces of the polygon. Must be at least nverts
in size.
◆ r2du_init_box()
Initialize a polygon as an axis-aligned box.
- Parameters
-
[in,out] poly The polygon to initialize. [in] rbounds An array of two vectors, giving the lower and upper corners of the box.