facing3d subsets an object by converting it to a triangle mesh, then subsetting to those triangles that are counterclockwise (for front = TRUE) when projected into a plane.

projectDown computes a projection that “looks down” the specified direction.

facing3d(obj, up = c(0, 0, 1),
P = projectDown(up),
front = TRUE, strict = TRUE)
projectDown(up)

## Arguments

obj

An object that can be converted to a triangular mesh object.

up

The direction that is to be considered “up”. It may be either a 3 vector in Euclidean coordinates or a 4 vector in homogeneous coordinates.

P

The projection to use for draping, a 4x4 matrix. See drape3d for details on how P is used.

front

If front = TRUE, retains triangles that are counterclockwise after projection by P, otherwise retains those that are clockwise.

strict

If TRUE, drops indeterminate triangles (those that are annihilated by P).

## Details

By default the returned subset will be those triangles whose upper side matches front. Change up or use an arbitrary projection for different subsets.

drape3d and shadow3d project objects onto meshes; these functions can be used to project only onto the top or front.

## Value

facing3d returns a mesh object made of those triangles which face in the desired direction. projectDown computes a 4x4 matrix. The first two coordinates of asEuclidean(x %*% projectDown(up))give a projection of x from above into a plane, where up determines which direction is taken to be “up”.

drape3d, shadow3d

## Examples

open3d()
d <- rnorm(3)
d <- d/sqrt(sum(d^2))
shade3d( facing3d( icosahedron3d(), up = d, strict = FALSE),
col = "yellow")
wire3d( facing3d( icosahedron3d(), up = d, front = FALSE),
col = "black")
# Show the direction:
arrow3d(-2*d , -d)

{"x":{"material":{"color":"#000000","alpha":1,"lit":true,"ambient":"#000000","specular":"#FFFFFF","emission":"#000000","shininess":50,"smooth":true,"front":"filled","back":"filled","size":3,"lwd":1,"fog":true,"point_antialias":false,"line_antialias":false,"texture":null,"textype":"rgb","texmipmap":false,"texminfilter":"linear","texmagfilter":"linear","texenvmap":false,"depth_mask":true,"depth_test":"less","isTransparent":false,"polygon_offset":[0,0],"margin":"","floating":false,"tag":""},"rootSubscene":502,"objects":{"508":{"id":508,"type":"triangles","material":{},"vertices":"0","colors":"2","centers":"3","normals":"1","ignoreExtent":false,"flags":32771},"509":{"id":509,"type":"triangles","material":{"front":"lines","back":"lines"},"vertices":"4","colors":"6","centers":"7","normals":"5","ignoreExtent":false,"flags":32771},"510":{"id":510,"type":"triangles","material":{},"vertices":"8","colors":"10","centers":"11","normals":"9","ignoreExtent":false,"flags":32771},"511":{"id":511,"type":"quads","material":{},"vertices":"12","colors":"14","centers":"15","normals":"13","ignoreExtent":false,"flags":32771},"506":{"id":506,"type":"light","vertices":[[0,0,1]],"colors":[[1,1,1,1],[1,1,1,1],[1,1,1,1]],"viewpoint":true,"finite":false},"505":{"id":505,"type":"background","material":{},"colors":"16","centers":"17","sphere":false,"fogtype":"none","fogscale":1,"flags":32768},"507":{"id":507,"type":"background","material":{"lit":false,"back":"lines"},"colors":"18","centers":"19","sphere":false,"fogtype":"none","fogscale":1,"flags":32768},"502":{"id":502,"type":"subscene","par3d":{"antialias":8,"FOV":30,"ignoreExtent":false,"listeners":502,"mouseMode":{"none":"none","left":"trackball","right":"zoom","middle":"fov","wheel":"pull"},"observer":[0,0,7.64664697647095],"modelMatrix":[[1,0,0,-0.0272068381309509],[0,0.342020153999329,0.939692616462708,0.342453926801682],[0,-0.939692616462708,0.342020153999329,-7.52200412750244],[0,0,0,1]],"projMatrix":[[3.73205065727234,0,0,0],[0,3.73205065727234,0,0],[0,0,-3.86370325088501,-27.5652770996094],[0,0,-1,0]],"skipRedraw":false,"userMatrix":[[1,0,0,0],[0,0.342020143325668,0.939692620785909,0],[0,-0.939692620785909,0.342020143325668,0],[0,0,0,1]],"userProjection":[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],"scale":[1,1,1],"viewport":{"x":0,"y":0,"width":1,"height":1},"zoom":1,"bbox":[-1,1.0544136762619,-1,1,-1.72886371612549,1],"windowRect":[0,0,256,256],"family":"sans","font":1,"cex":1,"useFreeType":true,"fontname":"NULL","maxClipPlanes":2147483647,"glVersion":"NA","activeSubscene":0},"embeddings":{"viewport":"replace","projection":"replace","model":"replace","mouse":"replace"},"objects":[507,508,509,510,511,506],"subscenes":[],"flags":33027}},"crosstalk":{"key":[],"group":[],"id":[],"options":[]},"width":480,"height":480,"context":{"shiny":false,"rmarkdown":null},"buffer":{"accessors":[{"bufferView":0,"componentType":5126,"count":30,"type":"VEC3"},{"bufferView":1,"componentType":5126,"count":30,"type":"VEC3"},{"bufferView":2,"componentType":5121,"count":1,"type":"VEC4"},{"bufferView":3,"componentType":5126,"count":10,"type":"VEC3"},{"bufferView":4,"componentType":5126,"count":30,"type":"VEC3"},{"bufferView":5,"componentType":5126,"count":30,"type":"VEC3"},{"bufferView":6,"componentType":5121,"count":1,"type":"VEC4"},{"bufferView":7,"componentType":5126,"count":10,"type":"VEC3"},{"bufferView":8,"componentType":5126,"count":42,"type":"VEC3"},{"bufferView":9,"componentType":5126,"count":42,"type":"VEC3"},{"bufferView":10,"componentType":5121,"count":1,"type":"VEC4"},{"bufferView":11,"componentType":5126,"count":14,"type":"VEC3"},{"bufferView":12,"componentType":5126,"count":36,"type":"VEC3"},{"bufferView":13,"componentType":5126,"count":36,"type":"VEC3"},{"bufferView":14,"componentType":5121,"count":1,"type":"VEC4"},{"bufferView":15,"componentType":5126,"count":9,"type":"VEC3"},{"bufferView":16,"componentType":5126,"count":1,"type":"VEC4"},{"bufferView":17,"componentType":5121,"count":1,"type":"VEC3"},{"bufferView":18,"componentType":5121,"count":1,"type":"VEC4"},{"bufferView":19,"componentType":5121,"count":1,"type":"VEC3"}],"bufferViews":[{"buffer":0,"byteLength":360,"byteOffset":0},{"buffer":0,"byteLength":360,"byteOffset":360},{"buffer":0,"byteLength":4,"byteOffset":720},{"buffer":0,"byteLength":120,"byteOffset":724},{"buffer":0,"byteLength":360,"byteOffset":844},{"buffer":0,"byteLength":360,"byteOffset":1204},{"buffer":0,"byteLength":4,"byteOffset":1564},{"buffer":0,"byteLength":120,"byteOffset":1568},{"buffer":0,"byteLength":504,"byteOffset":1688},{"buffer":0,"byteLength":504,"byteOffset":2192},{"buffer":0,"byteLength":4,"byteOffset":2696},{"buffer":0,"byteLength":168,"byteOffset":2700},{"buffer":0,"byteLength":432,"byteOffset":2868},{"buffer":0,"byteLength":432,"byteOffset":3300},{"buffer":0,"byteLength":4,"byteOffset":3732},{"buffer":0,"byteLength":108,"byteOffset":3736},{"buffer":0,"byteLength":16,"byteOffset":3844},{"buffer":0,"byteLength":3,"byteOffset":3860},{"buffer":0,"byteLength":4,"byteOffset":3863},{"buffer":0,"byteLength":3,"byteOffset":3867}],"buffers":[{"byteLength":3870,"bytes":"AAAAAHo3Hj8AAIA/AAAAAHo3Hr8AAIA/AACAPwAAAAB6Nx4/AAAAAHo3Hj8AAIA/AACAPwAA\nAAB6Nx4/ejcePwAAgD8AAAAAAAAAAHo3Hj8AAIA/ejcePwAAgD8AAAAAejcevwAAgD8AAAAA\nAAAAAHo3Hj8AAIA/ejcevwAAgD8AAAAAAACAvwAAAAB6Nx4/AAAAAHo3Hj8AAIA/AACAvwAA\nAAB6Nx4/AAAAAHo3Hr8AAIA/AACAPwAAAAB6Nx4/AAAAAHo3Hr8AAIA/ejcePwAAgL8AAAAA\nAACAvwAAAAB6Nx4/ejcevwAAgD8AAAAAAACAvwAAAAB6Nx6/AAAAAHo3Hr8AAIA/AACAvwAA\nAAB6Nx4/ejcevwAAgL8AAAAAejcevwAAgL8AAAAAejcePwAAgL8AAAAAAAAAAHo3Hr8AAIA/\nAACAvwAAAAB6Nx6/ejcevwAAgL8AAAAAAACAvwAAAAB6Nx4/YrG2PgAAAIDrJW8/YrG2PgAA\nAIDrJW8/YrG2PgAAAIDrJW8/O80TPzvNEz87zRM/O80TPzvNEz87zRM/O80TPzvNEz87zRM/\nAAAAAOslbz9isbY+AAAAAOslbz9isbY+AAAAAOslbz9isbY+O80TvzvNEz87zRM/O80TvzvN\nEz87zRM/O80TvzvNEz87zRM/YrG2vgAAAADrJW8/YrG2vgAAAADrJW8/YrG2vgAAAADrJW8/\nO80TPzvNE787zRM/O80TPzvNE787zRM/O80TPzvNE787zRM/6yVvv2Kxtj4AAAAA6yVvv2Kx\ntj4AAAAA6yVvv2Kxtj4AAAAAO80TvzvNE787zR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