The R package molaR provides functions that allow the user to quantitatively measure and graphically represent dental surface complexity. The following is a demonstration of the major functions in molaR.

molaR utilizes three-dimensionally embedded triangular mesh files. These files can be imported to R using the “read.ply” function from the geomorph package. Here, we use 3D scan data of two teeth included in the molaR package as the objects “ex_tooth1” (DU-LP 09, Male *Aloutta palliata* lower M1) and “ex_tooth2” (DU-LP 07, Female *Aloutta palliata* lower M1).

```
library(molaR)
summary(ex_tooth1)
```

```
## Length Class Mode
## vb 20472 -none- numeric
## it 30000 -none- numeric
## primitivetype 1 -none- character
## material 0 -none- NULL
## normals 20472 -none- numeric
```

Dirichlet's normal surface energy can be calculated with the DNE function. The face energy density values calculated can then be projected onto a three dimensial surface image using DNE3d.

```
DNE1 = DNE(ex_tooth1)
```

```
## Total Surface DNE = 174.9181
```

```
DNE3d(DNE1)
```

Note that the color scale on this plot is set relative to the values of the tooth. When comparing multiple teeth, setting the scale manually will ensure it is the same for all teeth. This is done with the “setRange” parameter.

```
DNE2 = DNE(ex_tooth2)
```

```
## Total Surface DNE = 311.2332
```

```
DNE3d(DNE2, setRange = c(0, 1.3))
```

```
DNE3d(DNE1, setRange = c(0, 1.3))
```

The reported “Total Surface DNE” excludes boundary faces and the faces with the highest 0.1% energy densities. Both sets of faces can be accessed through the list object created by the DNE function

```
head(DNE1$Edge_Values)
```

```
## NULL
```

```
head(DNE1$Outliers)
```

```
## Dirichlet_Energy_Densities Face_Areas
## 1492 59883.54 1.494101e-06
## 1495 60540.91 1.393022e-06
## 1784 98141.82 1.302348e-06
## 2482 41877.93 3.216186e-06
## 2572 238778.54 1.310253e-06
## 2574 234776.93 3.824084e-08
```

The RFI function will caculate the relief index of a tooth, the three dimensional surface area of the tooth crown, and the area of the tooth crown's two dimensional foot print.

```
RFI1 = RFI(ex_tooth1, alpha=0.5)
```

```
## RFI = 0.4693475
## 3D Area = 118.6806
## 2D Area = 46.42047
```

The three dimensional surface and its two dimensional footprint can be plotted adjacently using the RFI3d function.

```
RFI3d(RFI1)
```

The OPC function bins each triangular face on a mesh surface (tooth) into one of 8 groups based on the x-y orientation of the face, then determines the number of resulting “patches” on the tooth. These patches can be visualized using the OPC3d function.

```
OPC1 = OPC(ex_tooth1)
```

```
## Total Number of Patches = 113
## Number of Patches per Directional Bin =
## Bin 1: 15
## Bin 2: 9
## Bin 3: 14
## Bin 4: 16
## Bin 5: 17
## Bin 6: 15
## Bin 7: 13
## Bin 8: 14
```

```
OPC3d(OPC1)
```

By default, the OPC function counts any patch consisiting of two or more faces. This can be changed using the minimum_faces parameter or overriden by the minimum_area parameter, which sets the minimum proportion of total surface area a patch must contain to be counted.

```
OPC2 = OPC(ex_tooth1, minimum_faces = 20)
```

```
## Total Number of Patches = 41
## Number of Patches per Directional Bin =
## Bin 1: 4
## Bin 2: 4
## Bin 3: 6
## Bin 4: 6
## Bin 5: 5
## Bin 6: 6
## Bin 7: 5
## Bin 8: 5
```

```
OPC3 = OPC(ex_tooth1, minimum_area = 0.01)
```

```
## Total Number of Patches = 20
## Number of Patches per Directional Bin =
## Bin 1: 2
## Bin 2: 2
## Bin 3: 1
## Bin 4: 3
## Bin 5: 3
## Bin 6: 2
## Bin 7: 4
## Bin 8: 3
```

Due to the somewhat arbitrary boundaries of bins, differences in specimen orientation during analysis can result in minor variations of OPC. The OPCr function attempts to account for this by iteratively rotating the tooth (default is 8 iterations between 0 and 45 degrees of rotation) and calculating the OPC of each iteration. A mean OPC is reported.

```
OPCr1 = OPCr(ex_tooth1)
```

```
## Average patch count after 8 OPC calculations at 5.625 degrees
## rotated between each calculation = 115.25
```

```
OPCr2 = OPCr(ex_tooth1, Steps = 5, stepSize = 9, minimum_faces = 2) #the minimum_faces and minimum_area parameters are passed to each iteration of OPC
```

```
## Average patch count after 5 OPC calculations at 9 degrees
## rotated between each calculation = 173
```

The object returned by OPCr also contains the OPC values and degrees of rotation for each iteration.

```
OPCr1$Each_Run
```

```
## Degrees_Rotated Calculated_OPC
## [1,] 0.000 113
## [2,] 5.625 129
## [3,] 11.250 122
## [4,] 16.875 110
## [5,] 22.500 106
## [6,] 28.125 122
## [7,] 33.750 104
## [8,] 39.375 116
```

```
OPCr2$Each_Run
```

```
## Degrees_Rotated Calculated_OPC
## [1,] 0 180
## [2,] 9 187
## [3,] 18 180
## [4,] 27 159
## [5,] 36 159
```