package com.jayanslow.projection.world.models;

import javax.vecmath.Matrix3f;
import javax.vecmath.Tuple3d;
import javax.vecmath.Tuple3f;
import javax.vecmath.Vector3f;

public class Rotation3f extends Tuple3f {
	private static final long	serialVersionUID	= 7372169161188811962L;

	public Rotation3f() {
		super();
	}

	public Rotation3f(float x, float y, float z) {
		super(x, y, z);
	}

	public Rotation3f(float[] t) {
		super(t);
	}

	public Rotation3f(Tuple3d t1) {
		super(t1);
	}

	public Rotation3f(Tuple3f t1) {
		super(t1);
	}

	public Matrix3f getRotationMatrix() {
		Matrix3f m = new Matrix3f(), m2 = new Matrix3f();

		// m = Rz(angleZ)
		m.rotZ(z);

		// m = Rz(angleZ) . Ry(angleX)
		m2.rotX(x);
		m.mul(m2);

		// m = Rz(angleZ) . Ry(angleX) . Rx(angleY)
		m2.rotY(y);
		m.mul(m2);

		return m;
	}

	public void inverseRotate(Vector3f v) {
		Matrix3f m = getRotationMatrix();
		m.invert();
		m.transform(v);
	}

	public void rotate(Vector3f v) {
		Matrix3f m = getRotationMatrix();
		m.transform(v);
	}
}

@@ -1011,11 +1011,297 @@
 m(v);%0A%09%7D
+%0A%0A%09public Rotation3f toDegrees() %7B%0A%09%09return new Rotation3f((float) Math.toDegrees(x), (float) Math.toDegrees(y), (float) Math.toDegrees(z));%0A%09%7D%0A%0A%09public Rotation3f toRadians() %7B%0A%09%09return new Rotation3f((float) Math.toRadians(x), (float) Math.toRadians(y), (float) Math.toRadians(z));%0A%09%7D
 %0A%7D%0A

Convert Rotation3f to/from degrees/radians