Java-Gaming.org Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (611)
Games in Android Showcase (172)
games submitted by our members
Games in WIP (657)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2 3 ... 104
1  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-08-27 12:46:34
So any thoughts on range requirements?  I'm seeing internal inconsistencies.  Some axis-angle routines are assuming unit length and others are not.

Also:  Any reason @Override isn't begin used and @SuppressWarnings("hiding") where field hiding is reasonable?

EDIT: And effectively static methods which aren't static.

EDIT 2: I may not have ever said why [-pi,pi]...only one trig op is needed for sin(a) & cos(a).

EDIT 3: Some routines are converting returned angles to positive variants...see EDIT 2.  Make work that reduces their usefulness.

EDIT 4: Quaternion get(AxisAngleXf dest)...checks for non-unit quaternions...I say user's problem.
2  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-08-27 12:30:39
There are some more.  I'm correcting them as I go.  (Like: public AxisAngle4f set(AxisAngle4f a))
3  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-08-27 11:55:42
Tossed all my old refactor...starting a new one that's less ambitious.  As a data point for my argument: public AxisAngle4f set(AxisAngle4f a).  Pointless code repetition leads to bugs. QED.
4  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-08-27 08:35:35
What do you think about my main point of sensible input ranges and an aux method to enforce at user's request?

Quote
It does serve purpose, since it was being requested by a user.

You're focusing on one element of a combinatorial set.  I suggested way up near the top to let the compiler (and specifically inlining) do the work for you.  Nobody needs to read/write and maintain.
5  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-08-27 00:03:45
Yet another disclaimer:  This is my kinda thinking and the intention of my comments is improve the library, of which I will never be a user because I never use basic math libraries.

Backward compatibly is:  proxy method and refactor OR these classes aren't final...app extents class with marginal use-cases they desire in place.  Forever-and-ever library backward compatibly is a different design space.  Besides nobody has to change from their current version.

On sane ranges examples.  The axis angle classes and conversion thereof should assume the axis is unit magnitude and that the angle is on [-pi, pi].  Likewise on raw input.

Note that AxisAngle4f is used in about 190 methods.  About 2 of these perform any work.  Direct transform of a vec3 and vec4.  Two forwarding methods to the xform.  The remainder is due to a combinatorial explosion of type conversions.   

This is pretty wide spread and serves little to no purpose.  Some examples:

Mixing and matching singles/doubles: 
public Vector2d add(Vector2f v, Vector2d dest)


oh I think you get my attempted point.
6  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-08-26 20:56:27
The big question is:  Is it more important to allow user to supply random input?  Or place logical restrictions on what's deemed legal and if the user breaks the contract:  garbage-in, garbage-out?  This change everything.
7  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-08-26 19:41:00
So I started a re-factor but stopped (or paused).  There are too many issues of interest before putting the effort in.  First:  there are tons of redundant functionality for marginal (approaching useless) usage (as I've mentioned before) and conversely large holes in common functionality.

But the other big issues is the lack of contracts.  Users are given too much freedom in value ranges which serves zero purpose and this leads to much more complex code (runtime cost).  Users should be limited to partially sane values and the library could provide conicalization methods for users than want to pass in completely random values.
8  Discussions / Business and Project Management Discussions / Re: JGO Grabbag on: 2015-08-26 09:55:52
First pass of experimental testing of HotSpot transforms: https://github.com/roquendm/JGO-Grabbag/blob/master/src/roquen/info/HsIntrinsics.java

Some observations (insignificant number of data points so take with grain of salt).  HotSpot is doing the simple thing (nothing wrong with that given the compiler is a work-stealer) and is only handling certain types of primitives in each logical register set.  Integer/pointers in general purpose, float/double in SSE..except when x87 has specialized opcodes for the operation.  In that case it does the simple thing..move SSE to memory, memory to x87 perform op and store...rinse and repeat.  Likewise where an integer op could be performed in SSE..move to GP..do the thing, etc.

If an intrinsic math function (Float,Double,Math) has SSE support then the native opcode is generated.  Example:  (float)Math.sqrt(floatValue) generates single opcode sqrtss which is pure single, Math.sqrt(doubleValue) generates single opcode sqrtsd.  Don't know about floor & ceiling...my newish hardware is working hard to melt the polar ice-caps.  For icore2 it's doing typically functionality for performing the ops without changing the rounding mode.
9  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-08-25 08:54:29
Yeah I'm a firm believer in "It's better to ask forgiveness than permission".  What I had in mind was removing trivially inlinable (aka hotspot doesn't even think about it...just does it) code repeats into methods.  So it would be probably hundreds of small changes which produce identical native code.
10  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-08-25 07:17:22
How would you feel about me doing a series of "Golden Axe of Refactorization" push requests?  With an explanation of each?
11  Game Development / Game Mechanics / Re: Case Studies on: 2015-08-24 08:08:58
Pseudo-code for more robust computation (but we're not dropping real missiles into real teacups):
1  
2  
3  
4  
5  
6  
7  
{
  ma = magnitude(a);
  mb = magnitude(b);
  y  = magnitude(a*mb - b*ma);
  x  = mangitude(a*mb + b*ma);
  return 2 * atan2(y, x)
}
12  Game Development / Game Mechanics / Re: Case Studies on: 2015-08-24 07:47:47
Short answer: http://www.wolframalpha.com/input/?i=Plot%5B%7BArcCos%28x%29%2C+ArcTan%28x%29%7D%2C+%7Bx%2C0%2C1%7D%5D

I can expand on this if desired.


13  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-08-23 08:20:23
What are you using euler angles for?  IMHO the only sane place is certain styles of 3rd person camera control (and maybe avionics).  Where do you think are they helping vs. hurting you?

For the library...one trick here is that are are (if memory serves) 26 unique euler angle like systems.
14  Game Development / Game Mechanics / Re: Case Studies on: 2015-08-22 18:03:25
Short answer atan & atan2 are (vs. acos and asin):
1) faster to compute
2) don't have input domain issues
3) are more robust.

I can give some details if you want.
15  Game Development / Game Mechanics / Re: Case Studies on: 2015-08-22 16:18:08
I had in mind geometric reasoning...but this is all headed in the right direction.  Gosh we have |a||b|cos(t), if we could cheaply find |a||b|sin(t) we could use atan2.

vectorToEnemy.length() is positive.
16  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-08-22 12:32:04
Inject a proxy method, then refactor.
17  Game Development / Game Mechanics / Re: Case Studies on: 2015-08-21 21:21:03
Likewise for the divide and conquer nlerps.  2d and yet they are manipulating 4d values.  Also bisected an angle is reducible.  Say think a PBR half vector.
18  Game Development / Game Mechanics / Re: Case Studies on: 2015-08-21 21:02:40
 This solution is lost in the equation.  I'm asking someone to reason about the meaning which is geometric.
19  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-08-21 20:29:22
To not pollute this thread even more:  http://www.java-gaming.org/topics/case-studies/36562/msg/347355/view.html#msg347355
20  Game Development / Game Mechanics / Case Studies on: 2015-08-21 20:28:13

In current version of JOML, class Vector3f
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
    public float angleCos(Vector3f v) {
        double length1 = Math.sqrt(x * x + y * y + z * z);
        double length2 = Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
        double dot = x * v.x + y * v.y + z * v.z;
        return (float) (dot / (length1 * length2));
    }

   public float angle(Vector3f v) {
        float cos = angleCos(v);
        // This is because sometimes cos goes above 1 or below -1 because of lost precision
        cos = Math.min(cos, 1);
        cos = Math.max(cos, -1);
        return (float) Math.acos(cos);
    }


And Vector4f looks the same as the 3D (just extended).  The problem is 2D regardless of the number of dimensions, so you want to try to work it as a 2D problem.  The version is slower and has more error than is needed.

This is the exact sub-problem is the starting point of formulating slerp and the analysis of quaternion lerp.  The only difference between 2D problems in 2D vs. more than 2 is you have to find the plane. (and put it back in place if needed)
21  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-08-21 11:44:48
I'm being an ass again..negative zeroes are properly handled.

]as opposed to which implementation?
"If" based versions are staying comparisons and branches based (that's where my brain misfired on the negative zero thing).  An odd thing I noticed is that hotspot doesn't seem to be producing CPU aware short-cut opcodes like xor on same reg to produce a zero...it's loading a zero from memory.  I'll look more closely at that later. 

The properly inlined bit manipulation support chances all kinds of stuff.

...and I'm still not sure why there is a discrepancy between Math.abs(float) and Math.abs(double), according to the javadoc.
For singles on Intel it's takes both and produces the masked version.  As a guess because 64-bit immediate constants are uncommon in ISAs...but that doesn't matter if it recognizes the pattern.  Probably just a quirk of the author.

I'm starting a test-suite for some intrinsics and common interesting patterns.
22  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-08-21 01:11:12
1) Told Riven that raw float bit manipulation is slow.
2) Disproved 1, thus making an ass out of myself.
3) Since I'd broken out jitwatch I started looking at how HotSpot handles some patterns.
4) Discovered that FP abs (which ignores negative zeros really should look like this)

return Float.intBitsToFloat((Float.floatToRawIntBits(a) & (-1>>>1)));


5) Banged my head on my desk.
23  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-08-20 19:31:16
@Riven:
      int x = Float.floatToRawIntBits(s);
      {do stuff}
      f = Float.intBitsToFloat(x);

is being translated into (by C1):  SSE register has float, moves to regular register..do stuff..move back to SSE.  So they're both move operations.  So fast.  The odd thing is even if do stuff could be performed in SSE.  So I was indeed complete full of poop.
24  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-08-20 07:50:28
"One problem..."  (implies more than one) "...is decomposing..." (yes, yes) "...matrix back to..." (linear algebra is a really nice hammer) "...ill defined problem and no robust..." (and every problem is a nail) "...approximate solution..." (cringe) "...works reasonably well in the majority of cases." (is that like:  the letter's in the mail?).

In 3-space general rotations: 3 degrees of freedom, translation: 3 degrees of freedom, scale 1 degree: 7 total degrees of freedom. scale+quat+vect = 8.  4x3 LA=12, 4x4 LA=16.  Inverting: scale = multiplicative inverse, rotation=3 logical sign flips, translation=3 logical sign flips.  Reverse the order of composition and carry through the derivation.  The only place where matrices is a logical win is for bulk transforms since it is automatically composing common sub-expressions. However if you're bulk transforming then manually collecting the common sub-expressions is equivalent to converting the entire transform into a matrix (in local variables) at the point where you actually need them.

And no I'm not saying anyone is an idiot if they use matrices...just to get that out of the way.
25  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-08-19 19:08:43
for why double division is slower than float division online,
Most double operations have longer latency than single precision...division is one example, multiply is not.

EDIT: http://www.agner.org/optimize/#manuals (Instruction tables). as an example
26  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-08-19 10:04:59
@Riven - Ya know?  My comment about 1/sqrt is BS.  I'm assuming that rawBits and reverse are still slow.  That may not be the case.  Haven't looked in a long time.  If they're both intrinsics and produce sane results..that'd be the way to go (at least if you need to deal with the larger end of the range).

HotSpot does (or has) produces sqrtss (single sqrt) instructions..don't recall what patterns it matches.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
  /**
   * Given the dot product between two quaternions 'd' which
   * are going to be lerped, find the 't' of the maximum
   * abs angular error and the error.
   * <p>
   * The error is symmetric about t=.5, returns results from [0,.5]
   * <p>
   * r[0] = expected t of max error
   * r[1] = expected max abs error
   * <p>
   * r[0] is on 1/2-[1/(2 sqrt(3)), 1/2 sqrt(4/pi-1),  ] ~= [.211325, .238638]
   * r[0] = ~.238638 for angle = Pi/2
   * r[0] = ~.217459 for angle = Pi/4
   * r[0] = ~.211325 for angle = 0 (in the limit)
   * <p>
   * r[1] = abs error in degrees
   */

  public static void maxLerpAngleAbsError(float[] r, float d)
  {
    final double bias = Double.MIN_NORMAL;
   
    // This could be reduced, but can't see a reason to bother.
    double ca = Math.abs(d)+bias;        // cos(a)  
    double sa = Math.sqrt(1.0-ca*ca);    // sin(a)
    double a  = Math.atan2(sa,ca);       // a
    double t0 = ca-1.0;                  // cos(a)-1
    double tn = a*sa*(sa*sa-a*sa+t0*t0);
    double td = 2.0*(a*ca-a);
    double t  = 0.5+Math.sqrt(tn)/td;
    double e  = Math.atan2(t*sa, 1.0+t*(ca-1.0)) - t*a;
   
    e = 2.0*e;                           // Quat measure -> 3D
    e = Math.toDegrees(e);               // sane measure -> insane ;)
   
    r[0] = (float)t;
    r[1] = (float)e;
  }
27  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-08-18 20:15:08
Quote
But there is one thing that I still do not quite understand, namely the fact that the maximum rotation angle is only PI/2. My current intuition tells me that it should be PI.
Your intuition is correct.  The missing link is half the angle going into quaternion space and double it coming out:  an angle of Pi/2 in quaternion space translates into Pi in 3D, like you expected.

On fast 1/sqrt.  Hardware can do this faster, but java doesn't give access to it.  lerp always is too small except at the endpoints.  Worst case at t=.5.  Newton's method with reasonable guess.

Lerp and nlerp have the same angular error.  You can have to change how you measure it.  BUT likewise whatever takes the output likewise needs to be aware of non-unit input.  Let's leave this for another day.
28  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-08-18 12:45:31
Note the error is 3D is going to be 2*acos(abs(dot(ref,approx))).

Let me try to answer your question in a different way.  Most slerps do this (implicitly):

slerp(a,b,t) { d=dot(a, b); if (d<0) {d=-d; b=-b;} XXXX }

We have input a & b and assuming b != a && b != -a, then there is a plane that contains a,b and the origin.  We define 'a' to be our reference direction so we turn the plane so it points straight to the right (becomes the X axis).  We now define the Y axis to be the direction orthogonal to X that contains b.  This means that 'b' is by definition above X (is positive in Y).  If 'b' were in the second quadrant (say 3pi/4), we'd get a negative dot product which means it's the longer path...-b is closer to X (-pi/4).  So the entire domain is on [0,pi/2].  Negating 'b' will give us the opposite direction for Y in the example and in that plane it's angle (with respect to X) is pi/4.  Flipping the plane about it's X axis and looking at the opposite side.

Or another way from the example.  Negate a, now our new 'a' is point straight to the left.  We flip about the Y axis and it's point to the right again and 'b is in the first quadrant.

In this example in 3D the angle is pi/2 or 90 degrees, so if the dot is negative we're asking the math for a 270 degree rotation.
 





29  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-08-18 11:50:26
As implemented (not the math):
slerp( a,b) = slerp( a, -b) = r
slerp(-a,b) = slerp(-a,-b) = -r

the results r and -r represent the same rotation.

dot(a,b) = dot(-a,-b) = d
dot(a,-b) = dot(-a,b) = -d

if the dot product is negative you're really asking for the largest angle about the implied between the two input, but implementation swap it the to smallest automagically.
30  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-08-18 09:16:30
A slight cleaning pass on the raw data.  Folded negative and positive (they represent the same bin) and reversed order to show from the smallest angle to largest.

http://www.java-gaming.org/?action=pastebin&id=1330

Forward cumulative as rates: http://www.java-gaming.org/?action=pastebin&id=133

the first three values are: 0.48974302, 0.77403533, 0.8223283.  This means ~49% are in first bin, ~77.4 are in first two, ~82.2 in the first three, etc.
Pages: [1] 2 3 ... 104
 
GamerC4 (21 views)
2015-08-22 20:38:50

GamerC4 (20 views)
2015-08-22 20:37:18

GamerC4 (24 views)
2015-08-22 20:37:01

Kefwar (26 views)
2015-08-22 18:07:24

GamerC4 (23 views)
2015-08-22 01:00:24

GamerC4 (35 views)
2015-08-22 01:00:17

GamerC4 (21 views)
2015-08-22 00:57:35

GamerC4 (23 views)
2015-08-22 00:56:59

BurntPizza (28 views)
2015-08-21 01:38:01

KaiHH (42 views)
2015-08-19 15:01:05
Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!