# Triangle

## Introduction

vtkTriangle is a cell which representant a triangle. It contains static
method to make some computations directly link to triangle.

vtkCell

## Methods

### computeNormal

Compute the normalized normal of a triangle composed of three points. The
normal is returned in normal.

Argument Type Required Description
`v1` Vector3 Yes The first point coordinate.
`v2` Vector3 Yes The second point coordinate.
`v3` Vector3 Yes The third point coordinate.
`n` Vector3 Yes The normal coordinate.

### computeNormalDirection

Compute the normal direction according to the three vertex which composed a
triangle. The normal is not normalized. The normal is returned in normal.

Argument Type Required Description
`v1` Vector3 Yes The first point coordinate.
`v2` Vector3 Yes The second point coordinate.
`v3` Vector3 Yes The third point coordinate.
`n` Vector3 Yes The normal coordinate.

### evaluateLocation

Determine global coordinate (x]) from subId and parametric coordinates.

Argument Type Required Description
`pcoords` Vector3 Yes The parametric coordinates.
`x` Vector3 Yes The x point coordinate.
`weights` Array. Yes The number of weights.

### evaluatePosition

Evaluate the position of x in relation with triangle.

Compute the closest point in the cell.

• pccords parametric coordinate (computed in function)
• weights Interpolation weights in cell.
• the number of weights is equal to the number of points defining the
cell (computed in function).

A javascript object is returned :

Argument Type Required Description
`x` Vector3 Yes The x point coordinate.
`closestPoint` Vector3 Yes The closest point coordinate.
`pcoords` Vector3 Yes The parametric coordinates.
`weights` Array. Yes The number of weights.

### extend

Method used to decorate a given object (publicAPI+model) with vtkTriangle characteristics.

Argument Type Required Description
`publicAPI` Yes object on which methods will be bounds (public)
`model` Yes object on which data structure will be bounds (protected)
`initialValues` ITriangleInitialValues No (default: {})

### getCellDimension

Get the topological dimensional of the cell (0, 1, 2 or 3).

### getParametricDistance

Get the distance of the parametric coordinate provided to the cell.

Argument Type Required Description
`pcoords` Vector3 Yes The parametric coordinates.

### intersectWithLine

Compute the intersection point of the intersection between triangle and
line defined by p1 and p2. tol Tolerance use for the position evaluation
x is the point which intersect triangle (computed in function) pcoords
parametric coordinates (computed in function) A javascript object is
returned :

Argument Type Required Description
`p1` Vector3 Yes The first point coordinate.
`p2` Vector3 Yes The second point coordinate.
`tol` Number Yes The tolerance to use.
`x` Vector3 Yes The point which intersect triangle.
`pcoords` Vector3 Yes The parametric coordinates.

### newInstance

Method used to create a new instance of vtkTriangle.

Argument Type Required Description
`initialValues` ITriangleInitialValues No for pre-setting some of its content