# phong3D: Phong shading for a 3D body In RFOC: Graphics for Spherical Distributions and Earthquake Focal Mechanisms

## Description

Create phong shading for faces showing on the 3D block

## Usage

 ```1 2 3``` ```phong3D(aglyph, M = diag(1, nrow = 4), M2 = diag(1, nrow = 4), Light = c(45, 45), anorms = list(), zee = c(0, 0, 1), col = "white", border = "black") ```

## Arguments

 `aglyph` 3-D body list of faces and normals `M` Rotation Matrix `M2` Viewing Matrix `Light` light source direction `anorms` normals to faces `zee` Up vector for Body `col` color for faces `border` border color for sides

## Details

Uses a standard phong shading model based ont eh dot product of the face normal vector and direction of incoming light.

## Value

Graphical Side effect

## Author(s)

Jonathan M. Lees<jonathan.lees@unc.edu>

## References

Watt, Alan. Fundamentals of Three-dimensional Computer Graphics, Addison-Wesley, 1989, 430p.

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43``` ```########### create a block and rotation matrix, then color it ANG=(45) DEGRAD = pi/180 y1 = 1.5 y2 = y1 - 1/tan((ANG)*DEGRAD) z1 = 1 x1 = 1 Ablock1 = matrix(c(0,0,0, 1,0,0, 1,y1,0, 0,y1,0, 0,0,-1, 1,0,-1, 1,y2,-1, 0,y2,-1), byrow=TRUE, ncol=3) Nblock1 = makeblock3D(Ablock1) Light=c(45,45) angz = -45 angx = -45 R1 = ROTZ(angz) R2 = ROTX(angx) M = R1 Z2 = PROJ3D(Nblock1\$aglyph, M=M, anorms=Nblock1\$anorm , zee=c(0,0,1)) RangesX = range(attr(Z2, "RangesX")) RangesY = range(attr(Z2, "RangesY")) plot( RangesX, RangesY, type='n', asp=1, ann=FALSE, axes=FALSE) phong3D(Nblock1\$aglyph, M=M, anorms=Nblock1\$anorm , Light = Light, zee=c(0,0,1), col=rgb(.7,.5, .5) , border="black") ```