Matrix CreateScale Method (Vector3D)Delta Engine Documentation

Namespace: DeltaEngine.Datatypes
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public static Matrix CreateScale(
	Vector3D scale
)

Return Value

Type: Matrix
Remarks

Tests: DeltaEngine.Tests.Datatypes.MatrixTests
Examples

3 unit tests call DeltaEngine.Datatypes.Matrix.CreateScale(DeltaEngine.Datatypes.Vector3D)
[Test]
public void CreateScale()
{
    matrix = Matrix.CreateScale(Vector3D.One*2);
    var expected = new Matrix(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1);
    Assert.AreEqual(expected, matrix);
}
[Test]
public void CreateScaleFromThreeScalar()
{
    matrix = Matrix.CreateScale(3, 4, 7);
    var expected = new Matrix(3, 0, 0, 0, 0, 4, 0, 0, 0, 0, 7, 0, 0, 0, 0, 1);
    Assert.AreEqual(expected, matrix);
}
[Test]
public void TransformPosition()
{
    var position = new Vector3D(3, 5, 2);
    var translation = Matrix.CreateTranslation(2, 0, 5);
    var rotation = Matrix.CreateRotationZYX(0, 90, 0);
    var scale = Matrix.CreateScale(3, 3, 3);
    var transformation = scale * rotation * translation;
    var result = translation * (rotation * (scale * position));
    Assert.IsTrue((transformation * position).IsNearlyEqual(result));
}
See Also