Roi Atalla avatar Roi Atalla committed 85970f4

Modified Quaternion.getMatrix to just create a row-major order float array.

Comments (0)

Files changed (4)

src/main/java/com/ra4king/opengl/GLProgram.java

 			String l;
 			
 			while((l = reader.readLine()) != null)
-				s.append(l).append("\n");
+				s.append(l).append('\n');
 			
 			return s.toString();
 		}

src/main/java/com/ra4king/opengl/arcsynthesis/gl33/chapter8/example2/Example8_2.java

 		Quaternion offset = new Quaternion(axis.x(), axis.y(), axis.z(), (float)Math.cos(angle/2));
 		
 		if(rightMultiply)
-			orientation = orientation.mult(offset).normalize();
+			orientation = orientation.mult(offset);
 		else
 			orientation = offset.mult(orientation);
 		

src/main/java/com/ra4king/opengl/arcsynthesis/gl33/chapter8/example3/Example8_3.java

+package com.ra4king.opengl.arcsynthesis.gl33.chapter8.example3;
+
+import com.ra4king.opengl.GLProgram;
+
+public class Example8_3 extends GLProgram {
+	public static void main(String[] args) {
+		new Example8_3().run(true);
+	}
+	
+	public Example8_3() {
+		super("Example 8.3", 500, 500, true);
+	}
+	
+	@Override
+	public void init() {
+		
+	}
+	
+	@Override
+	public void resized() {
+		super.resized();
+		
+		
+	}
+	
+	@Override
+	public void render() {
+		
+	}
+}

src/main/java/com/ra4king/opengl/util/math/Quaternion.java

 	}
 	
 	public Quaternion mult(Quaternion q) {
-		float xx = (w*q.x) + (x*q.w) + (y*q.z) - (z*q.y);
-		float yy = (w*q.y) + (y*q.w) + (z*q.x) - (x*q.z);
-		float zz = (w*q.z) + (z*q.w) + (x*q.y) - (y*q.x);
-		float ww = (w*q.w) - (x*q.x) - (y*q.y) - (z*q.z);
+		float xx = w*q.x + x*q.w + y*q.z - z*q.y;
+		float yy = w*q.y + y*q.w + z*q.x - x*q.z;
+		float zz = w*q.z + z*q.w + x*q.y - y*q.x;
+		float ww = w*q.w - x*q.x - y*q.y - z*q.z;
 		
 		x = xx;
 		y = yy;
 	
 	public Matrix4 getMatrix() {
 		float[] m = {
-				1 - 2*y*y - 2*z*z,     2*x*y - 2*w*z,     2*x*z + 2*w*y, 0,
-				    2*x*y + 2*w*z, 1 - 2*x*x - 2*z*z,     2*y*z - 2*w*x, 0,
-				    2*x*z - 2*w*y,     2*y*z + 2*w*x, 1 - 2*x*x - 2*y*y, 0,
+				1 - 2*y*y - 2*z*z,     2*x*y + 2*w*z,     2*x*z - 2*w*y, 0,
+				    2*x*y - 2*w*z, 1 - 2*x*x - 2*z*z,     2*y*z + 2*w*x, 0,
+				    2*x*z + 2*w*y,     2*y*z - 2*w*x, 1 - 2*x*x - 2*y*y, 0,
 				                0,                 0,                 0, 1,
 		};
 		
-		return new Matrix4(m).transpose();
+		return new Matrix4(m);
 	}
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.