# Record TTransformation

Hierarchy
Properties

## Declaration

`type TTransformation = record`

## Description

Describe transformation in a way comfortable to apply it in both ways.

## Overview

### Fields

 `Transform: TMatrix4;` `InverseTransform: TMatrix4;` `Scale: Single;` `UniformScale: Boolean;`

### Methods

 `procedure Init;` `procedure Multiply( const Center: TVector3; const Rotation: TVector4; const ScaleVector: TVector3; const ScaleOrientation: TVector4; const Translation: TVector3); overload;` `procedure Multiply( const Rotation: TVector4; const ScaleVector: TVector3; const Translation: TVector3); overload;` `procedure MultiplyMatrix(const Matrix: TMatrix4);` `procedure Translate(const Translation: TVector3);` `procedure ScaleToIdentity;`

## Description

### Fields

 `Transform: TMatrix4;` Transformation from local to outside coordinate space.
 `InverseTransform: TMatrix4;` Inverted Transform matrix. Note that any scale with zero component along the way will make this partially invalid (we'll substitute identity in place of inverted scaling matrix). This is unavoidable, there's no reverse matrix for scaling with zero factor, since one resulting point may correpond to infinitely many source points (i.e., it's natural that such scaling function cannot be reversed).
 `Scale: Single;` A uniform scale of the matrix Transform. If the matrix causes non-uniform scaling, this value represents an average scale.
 `UniformScale: Boolean;` Is the underlying scale uniform (which means that Scale accurately represents the scaling, is not only approximate).

### Methods

 `procedure Init;` Make no transformation (identity matrix, scale 1).
`procedure Multiply( const Center: TVector3; const Rotation: TVector4; const ScaleVector: TVector3; const ScaleOrientation: TVector4; const Translation: TVector3); overload;`

Modify transformation by an additional translation, rotation, scaling.

Multiplies at the same time transformation matrix in Transform, and it's inverse in InverseTransform. The precise meaning of Center, Translation and other parameters follows exactly the X3D Transform node definition (see http://www.web3d.org/files/specifications/19775-1/V3.2/Part01/components/group.html#Transform ).

###### Parameters
Rotation
Rotation is expressed as a 4D vector, in which the first 3 components specify the rotation axis (does not need to be normalized, but must be non-zero), and the last component is the rotation angle in radians.
 `procedure Multiply( const Rotation: TVector4; const ScaleVector: TVector3; const Translation: TVector3); overload;` This item has no description.
 `procedure MultiplyMatrix(const Matrix: TMatrix4);` Modify transformation by an additional transformation matrix. Using this is very discouraged, as we need to assume UniformScale=false, which in turn e.g. makes sphere collisions worse (at some transformations, they have to treat sphere as something larger). That is because matrix can contain any transformation, and even using MatrixDecompose and then analyzing whether resulting scale has X=Y=Z would be unreliable. Testcases: - Rendering ghost teeth in castle-game. This shows that we cannot just replace matrix with translation+rotation+scale by MatrixDecompose, matrix can contain other transformations like shear. So we need to account whole matrix. Replacing `MultiplyMatrix`(matrix) with MatrixDecompose + Multiply(vectors) makes wrong rendering. - Graves on "The Gate" level in castle-game. This shows that even calculating UniformScale based on scale resulting from MatrixDecompose doesn't work reliably. Replacing inside `MultiplyMatrix` the UniformScale detection, to assume true when scale (from MatrixDecompose) has X=Y=Z, results in blocked movement. MatrixDecompose cannot account fo arbitrary matrix that can contain anything. - Beginng position (blocked movement) on "castle hall" level in castle-game. Same as above. Shows that we cannot detect UniformScale smartly. Use the Multiply instead to provide separate translation, rotation etc. vectors. Use this method only when you are forced to do so, i.e. your input is already a matrix.
 `procedure Translate(const Translation: TVector3);` Modify transformation by an additional translation.
 `procedure ScaleToIdentity;` Set Scale expressed by this transformation to identify, preserving the translation and rotation.

Generated by PasDoc 0.16.0.