rNd.h File Reference

Interface for rNd. More...

#include <stdint.h>

Go to the source code of this file.

Classes

struct  rNd_rvec
 A N-vector. More...
 
struct  rNd_dvec
 An integer N-vector for grid indexing. More...
 
struct  rNd_plane
 A hyperplane. More...
 
struct  rNd_vertex
 A doubly-linked vertex. More...
 
struct  rNd_poly
 An RND_DIM-dimensional polytope. More...
 

Macros

#define RND_DIM   4
 
#define RND_MAX_VERTS   1024
 

Typedefs

typedef double rNd_real
 Real type specifying the precision to be used in calculations. More...
 
typedef int32_t rNd_int
 Integer type used for indexing. More...
 
typedef int64_t rNd_long
 

Functions

void rNd_clip (rNd_poly *poly, rNd_plane *planes, rNd_int nplanes)
 Clip a polytope against an arbitrary number of hyperplanes (find its intersection with a set of half-spaces). More...
 
void rNd_reduce (rNd_poly *poly, rNd_real *moments, rNd_int polyorder)
 Integrate a polynomial density over a polytope. Still under development. More...
 
rNd_int rNd_is_good (rNd_poly *poly)
 Checks a polytope to see if it is a valid RND_DIM-polyhedral graph, by testing compliance with Balinski's theorem. More...
 
rNd_real rNd_orient (rNd_rvec verts[RND_DIM+1])
 Get the signed volume of the RND_DIM-simplex defined by the input vertices. More...
 
void rNd_print (rNd_poly *poly)
 Prints the vertices and connectivity of a polytope. For debugging. More...
 
void rNd_rotate (rNd_poly *poly, rNd_real theta, rNd_int ax1, rNd_int ax2)
 Rotate a polytope about one axis. More...
 
void rNd_translate (rNd_poly *poly, rNd_rvec shift)
 Translate a polytope. More...
 
void rNd_scale (rNd_poly *poly, rNd_rvec scale)
 Scale a polytope. More...
 
void rNd_shear (rNd_poly *poly, rNd_real shear, rNd_int axb, rNd_int axs)
 Shear a polytope. Each vertex undergoes the transformation pos.xyz[axb] += shear*pos.xyz[axs]. More...
 
void rNd_affine (rNd_poly *poly, rNd_real mat[RND_DIM+1][RND_DIM+1])
 Apply a general affine transformation to a polytope. More...
 
void rNd_init_simplex (rNd_poly *poly, rNd_rvec verts[RND_DIM+1])
 Initialize a polytope as an RND_DIM-simplex. More...
 
void rNd_init_box (rNd_poly *poly, rNd_rvec rbounds[2])
 Initialize a polytope as an axis-aligned hyperrectangle. More...
 

Detailed Description

Interface for rNd.

Author
Devon Powell
Date
31 August 2015

Macro Definition Documentation

◆ RND_DIM

#define RND_DIM   4

◆ RND_MAX_VERTS

#define RND_MAX_VERTS   1024

Typedef Documentation

◆ rNd_int

typedef int32_t rNd_int

Integer type used for indexing.

◆ rNd_long

typedef int64_t rNd_long

◆ rNd_real

typedef double rNd_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

◆ rNd_affine()

void rNd_affine ( rNd_poly poly,
rNd_real  mat[RND_DIM+1][RND_DIM+1] 
)

Apply a general affine transformation to a polytope.

Parameters
[in,out]polyThe polytope to transform.
[in]matThe (RND_DIM+1)*(RND_DIM+1) homogeneous transformation matrix.

◆ rNd_clip()

void rNd_clip ( rNd_poly poly,
rNd_plane planes,
rNd_int  nplanes 
)

Clip a polytope against an arbitrary number of hyperplanes (find its intersection with a set of half-spaces).

Parameters
[in,out]polyThe polytope to be clipped.
[in]planesAn array of hyperplanes against which to clip this polytope.
[in]nplanesThe number of hyperplanes in the input array.

◆ rNd_init_box()

void rNd_init_box ( rNd_poly poly,
rNd_rvec  rbounds[2] 
)

Initialize a polytope as an axis-aligned hyperrectangle.

Parameters
[out]polyThe polytope to initialize.
[in]rboundsAn array of two vectors, giving the lower and upper corners of the box.

◆ rNd_init_simplex()

void rNd_init_simplex ( rNd_poly poly,
rNd_rvec  verts[RND_DIM+1] 
)

Initialize a polytope as an RND_DIM-simplex.

Parameters
[out]polyThe polytope to initialize.
[in]vertsAn array of RND_DIM+1 vectors, giving the vertices of the simplex.

◆ rNd_is_good()

rNd_int rNd_is_good ( rNd_poly poly)

Checks a polytope to see if it is a valid RND_DIM-polyhedral graph, by testing compliance with Balinski's theorem.

Parameters
[in]polyThe polytope to check.
Returns
1 if the polytope is valid, 0 if not.

◆ rNd_orient()

rNd_real rNd_orient ( rNd_rvec  verts[RND_DIM+1])

Get the signed volume of the RND_DIM-simplex defined by the input vertices.

Parameters
[in]vertsRND_DIM+1 vertices defining a simplex from which to calculate a volume.
Returns
The signed volume of the input simplex.

◆ rNd_print()

void rNd_print ( rNd_poly poly)

Prints the vertices and connectivity of a polytope. For debugging.

Parameters
[in]polyThe polytope to print.

◆ rNd_reduce()

void rNd_reduce ( rNd_poly poly,
rNd_real moments,
rNd_int  polyorder 
)

Integrate a polynomial density over a polytope. Still under development.

Parameters
[in]polyThe polytope over which to integrate.
[in]polyorderOrder of the polynomial density field. 0 for constant (1 moment), 1 for linear (RND_DIM+1 moments), etc.
[in,out]momentsArray to be filled with the integration results, up to the specified polyorder. Order of moments is row-major.

◆ rNd_rotate()

void rNd_rotate ( rNd_poly poly,
rNd_real  theta,
rNd_int  ax1,
rNd_int  ax2 
)

Rotate a polytope about one axis.

Parameters
[in,out]polyThe polytope to rotate.
[in]thetaThe angle, in radians, by which to rotate the polytope.
[in]ax1Along with ax2, the plane in which to rotate the polytope.
[in]ax2Along with ax1, the plane in which to rotate the polytope.

◆ rNd_scale()

void rNd_scale ( rNd_poly poly,
rNd_rvec  scale 
)

Scale a polytope.

Parameters
[in,out]polyThe polytope to scale.
[in]scaleThe factor by which to scale the polytope along each dimension.

◆ rNd_shear()

void rNd_shear ( rNd_poly poly,
rNd_real  shear,
rNd_int  axb,
rNd_int  axs 
)

Shear a polytope. Each vertex undergoes the transformation pos.xyz[axb] += shear*pos.xyz[axs].

Parameters
[in,out]polyThe polytope to shear.
[in]shearThe factor by which to shear the polytope.
[in]axbThe axis along which to shear the polytope.
[in]axsThe axis across which to shear the polytope.

◆ rNd_translate()

void rNd_translate ( rNd_poly poly,
rNd_rvec  shift 
)

Translate a polytope.

Parameters
[in,out]polyThe polytope to translate.
[in]shiftThe vector by which to translate the polytope.