Record TTriangle3
Unit
Declaration
type TTriangle3 = record
Description
Triangle in 3D space.
Triangle's three points must not be collinear, i.e. routines in this unit generally don't accept "degenerated" triangles that are not really triangles. So 3D triangle must unambiguously define some plane in the 3D space. The only function in this unit that is able to handle "degenerated" triangles is TTriangle3.IsValid, which is exactly used to check whether the triangle is degenerated.
Overview
Nested Types
TIndex = 0..2; 
Fields
Data: packed [TIndex] of TVector3; 
Methods
function ToString: string; 

function IsValid: boolean; 

function Direction: TVector3; 

function Normal: TVector3; 

function Plane: TVector4; 

function NormalizedPlane: TVector4; 

function Transform(const M: TMatrix4): TTriangle3; 

function Area: Single; 

function AreaSqr: Single; 

function RandomPoint: TVector3; 

function Barycentric(const Point: TVector3): TVector3; 
Properties
property Items [const Index: TIndex]: TVector3 read GetItems write SetItems; 
Description
Nested Types
TIndex = 0..2; 

This item has no description. 
Fields
Data: packed [TIndex] of TVector3; 

This item has no description. 
Methods
function ToString: string; 

Multiline triangle description. 
function Direction: TVector3; 

Like a normal vector of a triangle (see Normal), but not necessarily normalized. 
function Normal: TVector3; 

Normal vector of a triangle. Returns vector pointing our from CCW triangle side (for righthanded coordinate system), and orthogonal to triangle plane. For degenerated triangles (when IsValid would return 
function Plane: TVector4; 

Plane of the triangle. Note that this has many possible solutions (plane representation as equation It's guaranteed that the direction of this plane (i.e. first 3 items of returned vector) will be in the same direction as calcualted by Direction, which means that it points outward from CCW side of the triangle (assuming righthanded coord system). For NormalizedPlane, this direction is also normalized (makes a vector with length 1). This way NormalizedPlane calculates also Normal. For three points that do not define a plane, a plane with first three components = 0 is returned. In fact, the 4th component will be zero too in this case (for now), but don't depend on it. 
function NormalizedPlane: TVector4; 

This item has no description. 
function Transform(const M: TMatrix4): TTriangle3; 

Transform triangle by 4x4 matrix. This simply transforms each triangle point. Exceptions raised

function Area: Single; 

Surface area of 3D triangle. This works for degenerated (equal to line segment or even single point) triangles too: returns 0 for them. 
function AreaSqr: Single; 

This item has no description. 
function RandomPoint: TVector3; 

Random triangle point, chosen with a constant density for triangle area. 
function Barycentric(const Point: TVector3): TVector3; 

For a given Point lying on a given Triangle, calculate it's barycentric coordinates. The resulting Barycentric coordinates can be used for linearly interpolating values along the triangle, as they satisfy the equation: Result.X * Triangle.Data[0] + Result.Y * Triangle.Data[1] + Result.Z * Triangle.Data[2] = Point
See also [http://en.wikipedia.org/wiki/Barycentric_coordinate_system_%28mathematics%29] 
Properties
property Items [const Index: TIndex]: TVector3 read GetItems write SetItems; 

Access the points of the triangle. This is the same as accessing Data field, it is also the default record property so you can just write 
Generated by PasDoc 0.16.0.