raysearchMulti: Find all intersections of rays and a mesh

View source: R/vcgRaySearch.r

raysearchMultiR Documentation

Find all intersections of rays and a mesh

Description

Find all intersections by tracing rays through mesh #

Usage

raysearchMulti(x, mesh, maxtol = 1e+15, threads = 1, offset = 0.001)

Arguments

x

a triangular mesh of class 'mesh3d' or a list containing vertices and vertex normals (fitting the naming conventions of 'mesh3d'). In the second case x must contain x$vb = 3 x n matrix containing 3D-coordinates and x$normals = 3 x n matrix containing normals associated with x$vb.

mesh

triangular mesh to be intersected.

maxtol

maximum distance to search along ray

threads

number of threads used during search.

offset

amount to offset the hit points along the ray to find the next intersection. This is needed to avoid finding the same intersection over and over again.

Details

This function iteratively uses vcgRaySearch to find all intersections of rays and a given surface mesh.

Value

list with following items:

intersects

a list containing the result of vcgRaySearch at each step of the intersection search

hits

Vector containging number of intersections for each ray

See Also

vcgRaySearch

Examples

## Not run: 
require(Morpho); require(rgl)
data(humface)
humface1 <- scalemesh(humface,size=1.1)
mesh <- mergeMeshes(humface,humface1)     #get normals of landmarks
x <- vcgClost(humface.lm, humface)
# offset landmarks along their normals for a negative amount of -5mm
x$vb[1:3,] <- x$vb[1:3,]+x$normals[1:3,]*-5

myint <- raysearchMulti(x,mesh)
wire3d(mesh,col="white")
spheres3d(vert2points(x),radius=0.5,col=3)
plotNormals(x,length=55,lwd=2)
for (i in 1:length(myint$intersects)) {
 spheres3d(vert2points(myint$intersects[[i]])[which(as.logical(myint$intersects[[i]]$quality)),]
                       ,col=i)
}

## End(Not run)

Rvcg documentation built on April 4, 2025, 1:46 a.m.