# incenter

Class: triangulation

Incenter of triangle or tetrahedron

## Syntax

```IC = incenter(TR,ti)[IC,r] = incenter(TR,ti)```

## Description

`IC = incenter(TR,ti)` returns the coordinates of the incenter of each triangle or tetrahedron specified by `ti`.

```[IC,r] = incenter(TR,ti)``` also returns the radii of the inscribed circles or spheres.

## Input Arguments

 `TR` Triangulation representation, see `triangulation` or `delaunayTriangulation`. `ti` Triangle or tetrahedron IDs, specified as a column vector.

## Output Arguments

 `IC` Incenters, returned as a matrix. Each row of `IC` contains the coordinates of an incenter. For example, `IC(j,:)` is the incenter of `ti(j)`. `r` Radii of the inscribed circles or spheres, returned as a vector. `r(j)` is the radius of the inscribed circle or sphere whose center is `IC(j,:)`.

## Definitions

### Triangle or Tetrahedron ID

A row number of the matrix, `TR.ConnectivityList`. Use this ID to refer a specific triangle or tetrahedron.

## Examples

expand all

### Find Incenters in 3-D Triangulation

Load a 3-D triangulation.

```load tetmesh ```

Calculate the incenters of the first five tetrahedra.

```TR = triangulation(tet,X); IC = incenter(TR,[1:5]') ```
```IC = -6.1083 -31.0234 8.1439 -2.1439 -31.0283 5.8742 -1.9555 -31.9463 7.4112 -4.3019 -30.8460 10.5169 -3.1596 -29.3642 6.1851 ```

### Find Incenters in 2-D Delaunay Triangulation

Create the Delaunay triangulation.

```x = [0 1 1 0 0.5]'; y = [0 0 1 1 0.5]'; DT = delaunayTriangulation(x,y); ```

Calculate incenters of the triangles

```IC = incenter(DT) ```
```IC = 0.2071 0.5000 0.5000 0.7929 0.7929 0.5000 0.5000 0.2071 ```

Plot the triangles and incenters.

```figure triplot(DT) axis equal axis([-0.2 1.2 -0.2 1.2]) hold on plot(IC(:,1),IC(:,2),'*r') hold off ```