@Override Object get() { return new Matrix3f(value); }
@Override Object get() { Matrix3f[] arr = new Matrix3f[this.length]; for (int i = 0; i < this.length; i++) { int j = i * 9; arr[i] = new Matrix3f(); arr[i].m00 = this.value[j+0]; arr[i].m01 = this.value[j+1]; arr[i].m02 = this.value[j+2]; arr[i].m10 = this.value[j+3]; arr[i].m11 = this.value[j+4]; arr[i].m12 = this.value[j+5]; arr[i].m20 = this.value[j+6]; arr[i].m21 = this.value[j+7]; arr[i].m22 = this.value[j+8]; } return arr; }
public static float[] getRotation(Matrix4f matrix) { float x,y,z; Matrix3f m = new Matrix3f(); matrix.get(m); if(Math.abs(m.m02 - 1) < 0.0000001) { x = (float) Math.atan2(-m.m10,m.m11); y = (float) (-3.1415926535897931/2); z = 0.0f; } else if(Math.abs(m.m02 + 1)< 0.0000001) { x = (float) Math.atan2(m.m10,m.m11); y = (float) (3.1415926535897931/2); z = 0.0f; } else { x = (float) Math.atan2(m.m12,m.m22); y = (float) Math.atan2(-m.m02, Math.sqrt(m.m12 * m.m12 + m.m22 * m.m22)); z = (float) Math.atan2(m.m01,m.m00); } return new float[] {x,y,z}; }
Matrix3f m3f = new Matrix3f();
Matrix3f mat = new Matrix3f(0.492403876506104f, 0.586824088833465f, -0.642787609686539f, 0.413175911166535f, 0.492403876506104f, 0.766044443118978f, 0.766044443118978f, -0.642787609686539f, 0f); Transform3D trans = new Transform3D(); trans.set(mat);
public static void decompose(final Matrix4f mat, final Vector3f origin, final AxisAngle4f rotation, final Vector3f translation) { final Matrix3f rot = new Matrix3f(); mat.get(rot); rotation.set(rot); final Point3f tmp = new Point3f(origin); rot.transform(tmp); tmp.sub(origin); mat.get(translation); translation.add(tmp); }
public void setTransform(final Transform3D transform) { if (contentNode == null) return; final Transform3D t = new Transform3D(); final Point3d c = new Point3d(); contentNode.getCenter(c); final Matrix3f m = new Matrix3f(); transform.getRotationScale(m); t.setRotationScale(m); // One might thing a rotation matrix has no translational // component, however, if the rotation is composed of // translation - rotation - backtranslation, it has indeed. final Vector3d v = new Vector3d(); v.x = -m.m00 * c.x - m.m01 * c.y - m.m02 * c.z + c.x; v.y = -m.m10 * c.x - m.m11 * c.y - m.m12 * c.z + c.y; v.z = -m.m20 * c.x - m.m21 * c.y - m.m22 * c.z + c.z; t.setTranslation(v); localRotate.setTransform(t); final Vector3d v2 = new Vector3d(); transform.get(v2); v2.sub(v); t.set(v2); localTranslate.setTransform(t); }