<commit_before>package com.jme.math;

import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.math.Matrix3f;
import com.jme.util.LoggingSystem;
import com.jme.system.JmeException;
import com.jme.scene.Spatial;

import java.util.logging.Level;


/**
 * TransformMatrix holds a rotation (Matrix3f)  and translation (Vector3f) for point manipulation
 *
 * @author <NAME>
 */
public class TransformMatrix {
    // TODO: Clean up and standardize this class's functionality

    private Matrix3f rot=new Matrix3f();
    private Vector3f translation=new Vector3f();
    private Vector3f scale=new Vector3f(1,1,1);

    /**
     * Constructor instantiates a new <code>TransformMatrix</code> that is set to the
     * identity matrix by default.
     *
     */
    public TransformMatrix() {
    }

    /**
     * Constructor instantiates a new <code>TransformMatrix</code> that is set to the
     * provided matrix. This constructor copies a given matrix. If the
     * provided matrix is null, the constructor sets the matrix to the
     * identity.
     * @param mat the matrix to copy.
     */
    public TransformMatrix(TransformMatrix mat) {
        set(mat);
    }

    /**
     * Constructor instantiates a new <code>TransformMatrix</code> that has rotation
     * and translation defined by its parameters
     * @param myRot The given rotation, as a <code>Quaternion</code>
     * @param myPos The given translation, as a <code>Vector3f</code>
     */
    public TransformMatrix(Quaternion myRot, Vector3f myPos) {
        rot.set(myRot);
        translation.set(myPos);
    }

    /**
     * <code>set</code> transfers the contents of a given matrix to this
     * matrix. If a null matrix is supplied, this matrix is set to the
     * identity matrix.
     * @param matrix the matrix to copy.
     */
    public void set(TransformMatrix matrix) {
        if (matrix == null) {
            loadIdentity();
        } else {
            rot.copy(matrix.rot);
            translation.set(matrix.translation);
            scale.set(matrix.scale);
        }
    }


    /**
     *
     * <code>set</code> defines the values of the matrix based on a supplied
     * <code>Quaternion</code>. It should be noted that all previous values
     * will be overridden.
     * @param quaternion the quaternion to create a rotational matrix from.
     */
    public void set(Quaternion quaternion) {
        rot.set(quaternion);
        translation.zero();
        scale.set(1,1,1);
    }

    /**
     * <code>loadIdentity</code> sets this matrix to the identity matrix,
     * namely all zeros with ones along the diagonal.
     *
     */
    public void loadIdentity() {
        rot.loadIdentity();
        translation.zero();
        scale.set(1,1,1);
    }

    /**
     * Multiplies every value in the matrix by a scalar
     * @param scalar
     */
    public void mult(float scalar) {
        rot.multiply(scalar);
        translation.mult(scalar);
        scale.multLocal(scalar);
    }

    /**
     * <code>multLocal</code> multiplies this matrix with another matrix and stores
     * the result back in this, returning this.  if null is passed, nothing happens
     * This function changes this matrix to what the child would look like if this were applied as it's parent
     * @param child The matrix to multiply by
     * @param tempStore A temporary Vector3f object for this TransformMatrix to use during the calculation.
     * @return this matrix after multiplication
     */
    public TransformMatrix multLocal(TransformMatrix child,Vector3f tempStore){
        this.scale.multLocal(child.scale);
        this.translation.addLocal(rot.mult(child.translation,tempStore).multLocal(child.scale));
        this.rot.multLocal(child.rot);
        return this;
    }

    /**
     * Sets this transform to an interpolation between the start and end transforms.  Note that
     * this function isn't very efficient as it has to create 2 new Quaternions to do the
     * rotation interpolation
     * @param start Begining transform (delta=0)<commit_msg>cleaned up, added new methods (invert, adjoint and determinant) brought Mat3 and Mat4 into alignment and so forth.<commit_after>package com.jme.math;

import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.math.Matrix3f;
import com.jme.util.LoggingSystem;
import com.jme.system.JmeException;
import com.jme.scene.Spatial;

import java.util.logging.Level;


/**
 * TransformMatrix holds a rotation (Matrix3f)  and translation (Vector3f) for point manipulation
 *
 * @author <NAME>
 */
public class TransformMatrix {
    // TODO: Clean up and standardize this class's functionality

    private Matrix3f rot=new Matrix3f();
    private Vector3f translation=new Vector3f();
    private Vector3f scale=new Vector3f(1,1,1);

    /**
     * Constructor instantiates a new <code>TransformMatrix</code> that is set to the
     * identity matrix by default.
     *
     */
    public TransformMatrix() {
    }

    /**
     * Constructor instantiates a new <code>TransformMatrix</code> that is set to the
     * provided matrix. This constructor copies a given matrix. If the
     * provided matrix is null, the constructor sets the matrix to the
     * identity.
     * @param mat the matrix to copy.
     */
    public TransformMatrix(TransformMatrix mat) {
        set(mat);
    }

    /**
     * Constructor instantiates a new <code>TransformMatrix</code> that has rotation
     * and translation defined by its parameters
     * @param myRot The given rotation, as a <code>Quaternion</code>
     * @param myPos The given translation, as a <code>Vector3f</code>
     */
    public TransformMatrix(Quaternion myRot, Vector3f myPos) {
        rot.set(myRot);
        translation.set(myPos);
    }

    /**
     * <code>set</code> transfers the contents of a given matrix to this
     * matrix. If a null matrix is supplied, this matrix is set to the
     * identity matrix.
     * @param matrix the matrix to copy.
     */
    public void set(TransformMatrix matrix) {
        if (matrix == null) {
            loadIdentity();
        } else {
            rot.copy(matrix.rot);
            translation.set(matrix.translation);
            scale.set(matrix.scale);
        }
    }


    /**
     *
     * <code>set</code> defines the values of the matrix based on a supplied
     * <code>Quaternion</code>. It should be noted that all previous values
     * will be overridden.
     * @param quaternion the quaternion to create a rotational matrix from.
     */
    public void set(Quaternion quaternion) {
        rot.set(quaternion);
        translation.zero();
        scale.set(1,1,1);
    }

    /**
     * <code>loadIdentity</code> sets this matrix to the identity matrix,
     * namely all zeros with ones along the diagonal.
     *
     */
    public void loadIdentity() {
        rot.loadIdentity();
        translation.zero();
        scale.set(1,1,1);
    }

    /**
     * Multiplies every value in the matrix by a scalar
     * @param scalar
     */
    public void mult(float scalar) {
        rot.multLocal(scalar);
        translation.mult(scalar);
        scale.multLocal(scalar);
    }

    /**
     * <code>multLocal</code> multiplies this matrix with another matrix and stores
     * the result back in this, returning this.  if null is passed, nothing happens
     * This function changes this matrix to what the child would look like if this were applied as it's parent
     * @param child The matrix to multiply by
     * @param tempStore A temporary Vector3f object for this TransformMatrix to use during the calculation.
     * @return this matrix after multiplication
     */
    public TransformMatrix multLocal(TransformMatrix child,Vector3f tempStore){
        this.scale.multLocal(child.scale);
        this.translation.addLocal(rot.mult(child.translation,tempStore).multLocal(child.scale));
        this.rot.multLocal(child.rot);
        return this;
    }

    /**
     * Sets this transform to an interpolation between the start and end transforms.  Note that
     * this function isn't very efficient as it has to create 2 new Quaternions to do the
     * rotation interpolation
     * @param start Begining transform (delta=0)
{'fraction_non_alphanumeric': 0.09080989330746848, 'fraction_numerical': 0.006304558680892337, 'mean_word_length': 2.65485157288436, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6121044', 'n_tokens_mistral': 2322, 'n_tokens_neox': 2242, 'n_words': 784}