Learn R Programming

Rvcg (version 0.12.2)

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)

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 norm
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.

Value

  • list with following items:
  • vb4 x n matrix containing intersection points
  • normals4 x n matrix containing homogenous coordinates of normals at intersection points
  • qualityinteger vector containing a value for each vertex of x: 1 indicates that a ray has intersected 'mesh' , while 0 means not
  • distancenumeric vector: distances to intersection

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)
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