# Proposals/Matrix

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
```   dictionary Point {
double x;
double y;
double z;
double w;
}

dictionary DecomposedMatrix {
double[] translation;
double[] skew;
double[] perspective;
double[] quaternion;
}

[
Constructor(),
Constructor(DOMString string),
Constructor(Matrix matrix),
Constructor(DecomposedMatrix decomposedValues)
Constructor(Float32array array),
Constructor(sequence<float> array)
]
interface Matrix {

// These attributes are simple aliases for certaelements of the  matrix
attribute double a; // alias for m11
attribute double b; // alias for m12
attribute double c; // alias for m21
attribute double d; // alias for m22
attribute double e; // alias for m41
attribute double f; // alias for m42

attribute double m11;
attribute double m12;
attribute double m13;
attribute double m14;
attribute double m21;
attribute double m22;
attribute double m23;
attribute double m24;
attribute double m31;
attribute double m32;
attribute double m33;
attribute double m34;
attribute double m41;
attribute double m42;
attribute double m43;
attribute double m44;

// immutable transform functions
Matrix translate(double x, double y, optional double z);
Matrix scale(double scaleX, optional double x, optional double y, optional double z);
Matrix scaleNonUniform(double scaleX, optional double scaleY, optional double scaleZ, optional double x, optional double y, optional double z);
Matrix rotate(double angle, optional double x, optional double y, optional double z);
Matrix rotateFromVector(double x, double y, optional double z);
Matrix rotateAxisAngle(double x, double y, double z, double angle);
Matrix skewX(double sx);
Matrix skewY(double sy);
Matrix skewZ(double sz);

// immutable basic functions
Matrix multiply(Matrix otherMatrix);
Matrix flipX();
Matrix flipY();
Matrix flipZ();
Matrix inverse();
double determinant();

// mutable transform functions
void multiplyBy(Matrix otherMatrix);
void leftMultiplyBy(Matrix otherMatrix);
void translateBy(double x, double y, double z);
void scaleBy(double scale, optional double x, optional double y, optional double z);
void scaleNonUniformBy(double scaleX, double scaleY, optional double scaleZ, optional double x, optional double y, optional double z);
void rotateBy(double angle, optional double x, optional double y, optional double z);
void rotateFromVectorBy(double x, double y, optional double z);
void rotateAxisAngleBy(double x, double y, double z, double angle);
void skewXBy(double sx);
void skewYBy(double sy);
void skewZBy(double sz);
void invert();

// helper functions
boolean is2D();
Point transform(Point p);

// conversion functions
void copyIntoFloat32Array(Float32Array array);
Float32Array toFloat32Array();
DecomposedMatrix decompose();

DOMString toString();
};
```