Learn R Programming

Rvcg (version 0.24)

vcgRaySearch: check if a mesh is intersected by a set of rays

Description

check if a mesh is intersected by a set of rays (stored as normals)

Usage

vcgRaySearch(x, mesh, mintol = 0, maxtol = 1e+15, mindist = FALSE, threads = 1)

Value

list with following items:

vb

4 x n matrix containing intersection points

normals

4 x n matrix containing homogenous coordinates of normals at intersection points

quality

integer vector containing a value for each vertex of x: 1 indicates that a ray has intersected 'mesh' , while 0 means not

distance

numeric vector: distances to intersection

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.

mintol

minimum distance to target mesh

maxtol

maximum distance to search along ray

mindist

search both ways (ray and -ray) and select closest point.

threads

number of threads used during search.

Details

vcgRaySearch projects a mesh (or set of 3D-coordinates) along a set of given rays (stored as normals) onto a target and return the hit points as well as information if the target mesh was hit at all. If nothing is hit along the ray(within the given thresholds), the ordinary closest point's value will be returned and the corresponding entry in quality will be zero.

Examples

Run this code
data(humface)
#get normals of landmarks
lms <- vcgClost(humface.lm, humface)
# offset landmarks along their normals for a negative amount of -5mm
lms$vb[1:3,] <- lms$vb[1:3,]+lms$normals[1:3,]*-5
intersect <- vcgRaySearch(lms, humface)
if (FALSE) {
require(Morpho)
require(rgl)
spheres3d(vert2points(lms),radius=0.5,col=3)
plotNormals(lms,long=5)
spheres3d(vert2points(intersect),col=2) #plot intersections
wire3d(humface,col="white")#'
}

Run the code above in your browser using DataLab