Small feature request to com.jme3.math.Matrix3f

Please implement normalize() and normalizeLocal() like javax.vecmath.Matrix3f.normalizeCP() . It’s very useful after creating a rotation matrix from a transformation matrix, because you don’t have to re-normalize normal vectors transformed by an orthonormal matrix. Here is the workaround I use in my DecalMeshGenerator:

[java]
package com.jme3.math;

/**
*

  • @author survivor
    */
    public class Matrix3fx
    {
    public static void normalize(Matrix3f m)
    {
    float mag = 1.0f / FastMath.sqrt(
    m.m00 * m.m00 +
    m.m10 * m.m10 +
    m.m20 * m.m20);

    m.m00 = m.m00 * mag;
    m.m10 = m.m10 * mag;
    m.m20 = m.m20 * mag;

    mag = 1.0f / FastMath.sqrt(
    m.m01 * m.m01 +
    m.m11 * m.m11 +
    m.m21 * m.m21);

    m.m01 = m.m01 * mag;
    m.m11 = m.m11 * mag;
    m.m21 = m.m21 * mag;

    m.m02 = m.m10 * m.m21 - m.m11 * m.m20;
    m.m12 = m.m01 * m.m20 - m.m00 * m.m21;
    m.m22 = m.m00 * m.m11 - m.m01 * m.m10;
    }
    }
    [/java]

1 Like

This could be very useful. Currently we don’t have a normalize() method in Matrix3f.

Done in last SVN. You now have a normalize(store) and a normalizeLocal() method

3 Likes

Merci beaucoup! :lol: