View source: R/mesh_addGridInfo.R
| addGridInfo | R Documentation |
Computes a grid based on a) the maximum distance between the input coordinates along either of the two requested axes, and b) the requested size of the grid intervals. Each coordinate is then assigned to a grid interval along the two requested axes (e.g. x and y) - in essence, to a grid cell.
addGridInfo(coords, c.res, axes = c(1, 2))
coords |
a data frame object with coordinates (one per row) |
c.res |
size of the requested grid intervals in mesh units (e.g. if mesh units are mm, then a value of 0.2 would indicate a gid resolution of 0.2mm). |
axes |
a vector containing 2 indices or names for the input columns to be used (e.g. c("x","y"), or c(1,2)). Longer vectors will be truncated to the first two entries (e.g. c("x","y","z") == c("x","y")) |
A list containing the altered input coordinate data frame object and information on the grid. The output df contains two additional columns: GDIM1 and GDIM2.
The grid origin is set to 0,0 along the requested axes. Note that the GDIM1 and GDIM2 columns refer to x,y locations on a 2d map of the coordinates, projected according to the specified columns.
You should ensure the requested grid resolution makes sense given the resolution of the mesh (i.e. how many vertices are expected per given interval)
This function is generic - it will work on any data.frame.
NA values will result with some bad input (e.g. number of requested breaks)
Cornel M. Pop
library(Morpho)
data(demoFlake1)
alignedMesh<-pcAlign(demoFlake1$mesh)
vertexCoords<-data.frame(t(alignedMesh$vb))
gridded<-Lithics3D:::addGridInfo(vertexCoords, 0.2, axes=c(2,3)) # or c("y","z")
mfval<-par("mfcol")
par(mfcol=c(2,1))
# Plot raw data:
plot(t(alignedMesh$vb)[,2:3], pch=".", asp=1, xlab="y", ylab="z")
# Plot grid: origin points of each grid cell.
plot(gridded$coords[,5:6], pch=".", asp=1, xlab="y", ylab="z")
par(mfcol=mfval) # reset graphic parameters
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.