View source: R/surf_edgeIntersects.R
| e2sIntersect | R Documentation |
Computes the intersection coordinates of mesh edges (i.e., the sides of the triangles that form the triangular mesh) and a sphere for cases where edge ends are on opposite sides of the sphere's surface (i.e., one end is within the sphere, the other end is outside of it). In this implementation no intersections are returned for edges that cut across the sphere.
e2sIntersect(e_ids, s, mpts, medges)
e_ids |
A vector containing mesh edge IDs, corresponding to the row names of the Rvcg::vcgGetEdge output when run with "unique" set to TRUE). |
s |
A vector of length 4 (center.x, center.y, center.z, radius) defining a sphere |
mpts |
Nx4 matrix-like object corresponding to the transposed mesh
vertex coordinates ( |
medges |
An Nx4 data.frame corresponding to the output of
Rvcg::vcgGetEdge |
A data.frame with intersection coordinates (x,y,z), one per row, for all input edges; the row names correspond to input edge ids.
Cornel M. Pop
data(demoSphere) # Use the included demoSphere object for this example
t_edges <- Rvcg::vcgGetEdge(demoSphere, unique = TRUE)
t_sphere <- c(0.5, 0.5, 0.5, 1) # Offset by 0.5 from demoSphere's center
# Compute intersections (if any) with all edges of the demoSphere:
res <- e2sIntersect(rownames(t_edges),
t_sphere,
t(demoSphere$vb), # transpose vertex coordinates
t_edges)
## Not run:
library(rgl)
wire3d(demoSphere, col = "black")
spheres3d(t_sphere[1:3], col = "green", alpha = 0.5)
points3d(res, col = "red")
# Close the 3D window:
close3d()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.