# Titanium.UI.Matrix3D

> The 3D Matrix is an object for holding values for a 3D affine transform.

- Source: https://titaniumsdk.com/docs/sdk/12.8.0/Titanium.UI.Matrix3D
- Titanium SDK version: 12.8.0
- Kind: proxy
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 8.0.0
- Extends: Titanium.Proxy
- Inheritance: Titanium.Proxy

The 3D Matrix is created by [Titanium.UI.createMatrix3D](https://titaniumsdk.com/docs/sdk/Titanium.UI.md#createMatrix3D). A 3D transform is
used to rotate, scale, translate, or skew the objects in three-dimensional
space. A 3D transform  is represented by a 4 by 4 matrix.

You create an `identity matrix` by creating a 3D Matrix with an empty
constructor.

## Example: Apply a 3D Matrix to a Label

Move a label through a translation that repositions it from 100px to 200px from the top of
the display.

``` js
var win = Ti.UI.createWindow();

var label = Ti.UI.createLabel({
  font: { fontSize : 50 },
  text: 'Titanium',
  textAlign: 'center',
  top: 100
});
win.add(label);

var button = Ti.UI.createButton({
  title: 'Animate',
  bottom: 20,
  width: 200,
  height: 40
});
win.add(button);

button.addEventListener('click', function() {
  var t1 = Ti.UI.createMatrix3D();
  t1 = t1.translate(0, 100, 200);
  t1.m34 = 1.0 / -90.0;
  var a1 = Ti.UI.createAnimation();
  a1.transform = t1;
  a1.duration = 800;
  label.animate(a1);
});
win.open();
```

## Properties

### m11

- Type: Number
- Platforms: iPhone, iPad, macOS

The entry at position [1,1] in the matrix.

### m12

- Type: Number
- Platforms: iPhone, iPad, macOS

The entry at position [1,2] in the matrix.

### m13

- Type: Number
- Platforms: iPhone, iPad, macOS

The entry at position [1,3] in the matrix.

### m14

- Type: Number
- Platforms: iPhone, iPad, macOS

The entry at position [1,4] in the matrix.

### m21

- Type: Number
- Platforms: iPhone, iPad, macOS

The entry at position [2,1] in the matrix.

### m22

- Type: Number
- Platforms: iPhone, iPad, macOS

The entry at position [2,2] in the matrix.

### m23

- Type: Number
- Platforms: iPhone, iPad, macOS

The entry at position [2,3] in the matrix.

### m24

- Type: Number
- Platforms: iPhone, iPad, macOS

The entry at position [2,4] in the matrix.

### m31

- Type: Number
- Platforms: iPhone, iPad, macOS

The entry at position [3,1] in the matrix.

### m32

- Type: Number
- Platforms: iPhone, iPad, macOS

The entry at position [3,2] in the matrix.

### m33

- Type: Number
- Platforms: iPhone, iPad, macOS

The entry at position [3,3] in the matrix.

### m34

- Type: Number
- Platforms: iPhone, iPad, macOS

The entry at position [3,4] in the matrix.

### m41

- Type: Number
- Platforms: iPhone, iPad, macOS

The entry at position [4,1] in the matrix.

### m42

- Type: Number
- Platforms: iPhone, iPad, macOS

The entry at position [4,2] in the matrix.

### m43

- Type: Number
- Platforms: iPhone, iPad, macOS

The entry at position [4,3] in the matrix.

### m44

- Type: Number
- Platforms: iPhone, iPad, macOS

The entry at position [4,4] in the matrix.

## Methods

### invert

- Platforms: iPhone, iPad, macOS

Returns a matrix constructed by inverting this matrix.

Returns: Titanium.UI.Matrix3D

### multiply

- Platforms: iPhone, iPad, macOS

Returns a matrix constructed by combining two existing matrix.

The result of this function is the first matrix multiplied by the second matrix. You might perform
several multiplications in order to create a single matrix that contains the cumulative effects of
several transformations. Note that matrix operations are not commutative - the order in which
you concatenate matrices is important. That is, the result of multiplying matrix t1 by matrix t2
does not necessarily equal the result of multiplying matrix t2 by matrix t1.

Parameters:

- `t2` (Titanium.UI.Matrix3D): Matrix to concatenate to this matrix.

Returns: Titanium.UI.Matrix3D

### rotate

- Platforms: iPhone, iPad, macOS

Returns a matrix constructed by rotating this matrix.

Parameters:

- `angle` (Number): The angle, in degrees, by which to rotate the matrix. A positive value specifies counterclockwise rotation and a negative value specifies clockwise rotation.
- `x` (Number): The x part of the vector about which to rotate.
- `y` (Number): The y part of the vector about which to rotate.
- `z` (Number): The z part of the vector about which to rotate.

Returns: Titanium.UI.Matrix3D

### scale

- Platforms: iPhone, iPad, macOS

Returns a matrix constructed by scaling this matrix.

Parameters:

- `sx` (Number): The value by which to scale x values of the matrix.
- `sy` (Number): The value by which to scale y values of the matrix.
- `sz` (Number): The value by which to scale z values of the matrix.

Returns: Titanium.UI.Matrix3D

### translate

- Platforms: iPhone, iPad, macOS

Returns a matrix constructed by translating an existing matrix.

Parameters:

- `tx` (Number): The value by which to move x values with the matrix.
- `ty` (Number): The value by which to move y values with the matrix.
- `tz` (Number): The value by which to move z values with the matrix.

Returns: Titanium.UI.Matrix3D

## Inherited members

6 members are inherited. Each is documented on the type that declares it.

- [Titanium.Proxy](https://titaniumsdk.com/docs/sdk/12.8.0/Titanium.Proxy.md): `addEventListener`, `apiName`, `applyProperties`, `bubbleParent`, `fireEvent`, `removeEventListener`

---

- This corpus documents Titanium SDK 13.4.1. Anything here that does not name a version describes 13.4.1.
- Titanium is maintained by TiDev. The Appcelerator toolchain is retired: there is no `appc` CLI, no Appcelerator Studio and no hosted build service. The supported CLI is `titanium` on npm, invoked as `ti`.

