Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

addNormals

Add normal vectors to objects so they render more smoothly


Description

This generic function adds normals at each of the vertices of a polyhedron by averaging the normals of each incident face. This has the effect of making the surface of the object appear smooth rather than faceted when rendered.

Usage

addNormals(x, ...)
## S3 method for class 'mesh3d'
addNormals(x, angleWeighted = TRUE, ...)

Arguments

x

An object to which to add normals.

...

Additional parameters which will be passed to the methods.

angleWeighted

See Details below.

Details

Currently methods are supplied for "mesh3d" and "shapelist3d" classes.

These methods work by averaging the normals on the faces incident at each vertex. By default these are weighted according to the angle in the polygon at that vertex. If angleWeighted = FALSE, a slightly faster but less accurate weighting by the triangle area is used.

Prior to rgl version 0.104.12 an incorrect weighting was used; it can be partially reproduced by using angleWeighted = NA, but not all the bugs in that scheme will be kept.

Value

A new object of the same class as x, with normals added.

Author(s)

Duncan Murdoch

Examples

open3d()
y <- subdivision3d(tetrahedron3d(col = "red"), depth = 3)
shade3d(y) # No normals
y <- addNormals(y)
shade3d(translate3d(y, x = 1, y = 0, z = 0)) # With normals

rgl

3D Visualization Using OpenGL

v0.106.8
GPL
Authors
Duncan Murdoch [aut, cre], Daniel Adler [aut], Oleg Nenadic [ctb], Simon Urbanek [ctb], Ming Chen [ctb], Albrecht Gebhardt [ctb], Ben Bolker [ctb], Gabor Csardi [ctb], Adam Strzelecki [ctb], Alexander Senger [ctb], The R Core Team [ctb, cph], Dirk Eddelbuettel [ctb], The authors of Shiny [cph], The authors of knitr [cph], Jeroen Ooms [ctb], Yohann Demont [ctb], Joshua Ulrich [ctb], Xavier Fernandez i Marin [ctb], George Helffrich [ctb], Ivan Krylov [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.