A quad mesh on a regular grid is completely determined by a tiny
recipe: the grid dimension (nx, ny cells), the
extent (xmin, xmax, ymin, ymax), and the y orientation
(ydown). Everything in textures is a view of that recipe at
some level of materialization:
quad_spec() - the recipe itself, a plain serializable
list, nothing materializedquad_edges() - the unexpanded intermediate, the x and y
coordinates of the cell edges as two short vectors (nx + 1 and ny + 1
values)quad_index(), quad_vertex() - the
materialized components, the 4 x (nx * ny) vertex index and the expanded
vertex coordinatesquad_mesh(), quad(),
quad_texture() - assembled ‘mesh3d’ objects‘mesh3d’ objects are constructed directly (rgl is not required, it
lives in Suggests). With rgl installed they plot with
plot3d(), shade3d(), persp3d(),
wire3d(), or dot3d(), and
as.mesh3d() works on a quad_spec via delayed S3
registration. A 2D base graphics plot() method is
included.
matrix()/image() convention, and raster cell
order when ydown = TRUE. Face-indexed values (colours,
na.rm) align with grid cell order.material3d back argument).ydown flips the orientation so y coordinates begin at
the top and count down, and rotates the index cycle so winding remains
correct.dimension) is independent of the pixel dimension
of a texture image: a coarse mesh may carry a full-resolution image, the
graphics engine interpolates within each quad.quad_index() returns integer storage where it fits, and
transparently promotes to double storage (exact for integer values to
2^53) when the vertex count or index length exceeds the integer maximum.
R subsetting and ‘mesh3d’ use accept double indexes natively; take care
not to apply as.integer() to such an index. The compact
spec and the edges intermediate are the escape hatch when full
materialization is not wanted at all.
Registered via cpp11 in src/quad-build.cpp, callable
from R as internal functions:
inst/include/textures/quad.h, namespace
quad, installed so that other packages may generate mesh
components via LinkingTo: textures:
cpp11::writable::integers quad_ib(int nx, int ny, bool ydown)
cpp11::writable::doubles quad_ib_dbl(double nx, double ny, bool ydown)
cpp11::writable::doubles quad_vb(int nx, int ny, bool ydown, bool zh)
cpp11::writable::doubles_matrix<> quad_matrix_vb(int nx, int ny, bool ydown, bool zh)quad_ib and quad_vb return flat vectors (4
values per quad, and interleaved x, y with optional constant z and
homogeneous h), quad_matrix_vb returns the matrix form.
ib_index() and vb_vertex() in
R/quad-Rcode.R are pure-R versions of the index and vertex
generators, kept as the executable specification - the tests pin the
compiled path to them.