06 November 2012 - 11:24 AM
26 August 2011 - 09:17 AM
21 March 2011 - 08:35 AM
It can be shown that no two-parameter coordinate system can avoid such degeneracy. We can avoid such problems by embedding the sphere in three-dimensional space and parameterizing it with three Cartesian coordinates (here w,x,y),
Points on the sphere satisfy the constraint w^{2} + x^{2} + y^{2} = 1, so we still have just two degrees of freedom though there are three coordinates.
The point (w,x,y,z) represents a rotation around the axis directed by the vector (x,y,z) by an angle
18 March 2011 - 04:08 PM
/* * Returns a ray in eye space */ public Ray raycast(Point2 position) { //Viewport to NDC Point3 pickPoint = paintingSurface.normalise(new Point3(position, 0)); //NDC to eye coordinates Point3 reprojectedPoint = inverseProjection.multiply(pickPoint); reprojectedPoint.homogenousDivide(); Vector3 rayDir = reprojectedPoint.subtract(Point3.ZERO); rayDir.normalize(); return new Ray(new Point3(0,0,-1), rayDir); /// :-(((((( Why??? }
01 May 2010 - 01:13 PM
public class NewMatrix3 { private Vector3 x, y, z; private Point3 w; ... }The matrix has now subobjects, which bring their own methods. From a programming point of view this makes lots of things easier (at least in my opinion =)) Particularily I tried this:
public Point3 multiply(Point3 p) { Point3 r = new Point3(w); Vector3 dx = x.multiply(p.getX()); Vector3 dy = x.multiply(p.getY()); Vector3 dz = x.multiply(p.getZ()); r.translate(dx); r.translate(dy); r.translate(dz); return r; }The purpose of this method is to transform a point in space by the matrix. The method is unorthodox, but much more visual than plain row/column dot-product multiplication. The result point is translated into the origin of our coordinate system and a linear combination of the axis vectors is added to the origin point. So mathematically all should be right ?!! Hope so, but thats not the point. We have a method here with at least 3 local objects, the vectors dx, dy, dz, which are allocated inside the scalar multiply method of vector3. When I understand right, these are perfect candiates for escape analysis. Thats a thing I really dislike about java... code like this is simply not feasible from a performance standpoint (at least it was), but is perfectly fine in c++ ;-( I really would appreciate to write like this. So I tried this: -server -XX:+DoEscapeAnalysis with a small test program:
NewMatrix3 matrix = new NewMatrix3(); matrix.loadAxisAngleRotation(30, new Vector3(1,1,1)); Point3 p = new Point3(); for(;;) { p.set((float)Math.random() * 100f, (float)Math.random() * 100f, (float)Math.random() * 100f); Point3 r = matrix.multiply(p); System.out.println(r.getX()); }Unfortunately there is NO difference to no escape analysis at all. The netbeans profiler reports a hell of lots of Vector3 objects that are allocated. But if I got this right, none should be allocated at all. I really appreciate some help. Because I like java and there are advantages to come later on in game programming, like good scripting support, continuations via javaflow, reflection, low compilation times, runtime code loading. But this sacrifice of readability in exchange for performance is really a pain. I am even thinking of porting my project to C++... :-( I would really appreciate help in this case. Btw. escape analysis seems to work somehow, as it lowered total object creation in my main program. So it does at least something. But i believe the example I provided should be the standard case for escape analysis and should provide a stellar speed up, shouldn't it ?! Thank you! Really desperate for help, Frederick
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.