Show Posts

Pages: [1] 2 3 ... 104

1

Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML)

on: 20150827 12:46:34

So any thoughts on range requirements? I'm seeing internal inconsistencies. Some axisangle 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 nonunit quaternions...I say user's problem.



4

Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML)

on: 20150827 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? 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: 20150827 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 usecases they desire in place. Foreverandever 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.



7

Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML)

on: 20150826 19:41:00

So I started a refactor 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: 20150826 09:55:52

First pass of experimental testing of HotSpot transforms: https://github.com/roquendm/JGOGrabbag/blob/master/src/roquen/info/HsIntrinsics.javaSome 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 workstealer) 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 icecaps. For icore2 it's doing typically functionality for performing the ops without changing the rounding mode.



11

Game Development / Game Mechanics / Re: Case Studies

on: 20150824 08:08:58

Pseudocode 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) } 



14

Game Development / Game Mechanics / Re: Case Studies

on: 20150822 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: 20150822 16:18:08

I had in mind geometric reasoning...but this is all headed in the right direction. Gosh we have abcos(t), if we could cheaply find absin(t) we could use atan2.
vectorToEnemy.length() is positive.



17

Game Development / Game Mechanics / Re: Case Studies

on: 20150821 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.



20

Game Development / Game Mechanics / Case Studies

on: 20150821 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); 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 subproblem 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: 20150821 11:44:48

ignores negative zeros Rude. 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 shortcut 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 64bit 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 testsuite for some intrinsics and common interesting patterns.



22

Discussions / Miscellaneous Topics / Re: What I did today

on: 20150821 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: 20150820 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: 20150820 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 3space 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 subexpressions. However if you're bulk transforming then manually collecting the common subexpressions 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.



26

Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML)

on: 20150819 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
 public static void maxLerpAngleAbsError(float[] r, float d) { final double bias = Double.MIN_NORMAL; double ca = Math.abs(d)+bias; double sa = Math.sqrt(1.0ca*ca); double a = Math.atan2(sa,ca); double t0 = ca1.0; double tn = a*sa*(sa*saa*sa+t0*t0); double td = 2.0*(a*caa); double t = 0.5+Math.sqrt(tn)/td; double e = Math.atan2(t*sa, 1.0+t*(ca1.0))  t*a; e = 2.0*e; e = Math.toDegrees(e); r[0] = (float)t; r[1] = (float)e; } 



27

Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML)

on: 20150818 20:15:08

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 nonunit input. Let's leave this for another day.



28

Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML)

on: 20150818 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: 20150818 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.





GamerC4
(21 views)
20150822 20:38:50
GamerC4
(20 views)
20150822 20:37:18
GamerC4
(24 views)
20150822 20:37:01
Kefwar
(26 views)
20150822 18:07:24
GamerC4
(23 views)
20150822 01:00:24
GamerC4
(35 views)
20150822 01:00:17
GamerC4
(21 views)
20150822 00:57:35
GamerC4
(23 views)
20150822 00:56:59
BurntPizza
(28 views)
20150821 01:38:01
KaiHH
(42 views)
20150819 15:01:05

javagaming.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

