/*
 * Copyright 2017 MovingBlocks
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.terasology.math;

import org.terasology.math.geom.Matrix3f;
import org.terasology.math.geom.Quat4f;
import org.terasology.math.geom.Vector3f;

public class Transform {
    public final Vector3f origin;
    public final Quat4f rotation;
    public float scale;

    public Transform(Vector3f origin, Quat4f rotation, float scale) {
        this.origin = origin;
        this.rotation = rotation;
        this.scale = scale;
    }

    public Matrix3f getBasis() {
        Matrix3f basis = new Matrix3f();

        basis.set(rotation);
        basis.mul(scale);

        return basis;
    }

    public void transform(Vector3f v) {
        getBasis().transform(v);
        v.add(origin);
    }
}

@@ -749,454 +749,1446 @@
 f;%0A%0A
-public class Transform %7B%0A    public final Vector3f origin;%0A    public final Quat4f rotation;%0A    public float scale;%0A%0A    public Transform(Vector3f origin, Quat4f rotation, float scale) %7B%0A        this.origin = origin;%0A        this.rotation = rotation;%0A        this.scale = scale;%0A    %7D%0A%0A    public Matrix3f getBasis() %7B%0A        Matrix3f basis = new Matrix3f();%0A%0A        basis.set(rotation);%0A        basis.mul(scale);%0A%0A        return basis;%0A    %7D%0A
+/**%0A * Represents a space transformation. Used for transforming points from one space to another space and%0A * vice versa.%0A */%0Apublic class Transform %7B%0A    /**%0A     * The origin vector (in global coordinates) of this transform.%0A     */%0A    public final Vector3f origin;%0A    /**%0A     * The rotation of this transform.%0A     */%0A    public final Quat4f rotation;%0A    /**%0A     * The scale of this transform.%0A     */%0A    public float scale;%0A%0A    /**%0A     * Creates a new %7B@link Transform%7D with the given origin, rotation, and scale.%0A     * @param origin The origin of the transform.%0A     * @param rotation The rotation of the transform.%0A     * @param scale The scale of the transform.%0A     */%0A    public Transform(Vector3f origin, Quat4f rotation, float scale) %7B%0A        this.origin = origin;%0A        this.rotation = rotation;%0A        this.scale = scale;%0A    %7D%0A%0A    /**%0A     * Creates and returns the basis matrix for this transform.%0A     *%0A     * A basis matrix is a 3x3 matrix which contains the rotation and scaling information of the transform.%0A     *%0A     * @return The basis matrix.%0A     */%0A    public Matrix3f getBasis() %7B%0A        Matrix3f basis = new Matrix3f();%0A%0A        basis.set(rotation);%0A        basis.mul(scale);%0A%0A        return basis;%0A    %7D%0A%0A    /**%0A     * Transforms the point %7B@code v%7D into the space represented by this transform. The result is placed%0A     * back into %7B@code v%7D.%0A     * @param v The point to transform.%0A     */
 %0A   

Document Transform