Java OpenGL Math Library (JOML)

I feel like crying. Given unit vectors a & b and we want quaternion q that rotates a into b then solve the rotation equation:

b = qaq
q = sqrt(ba
)

now carry through the derivation. The equation ba* is quaternion speak for compose the magnitudes and find the relative angle and containing plane. Remember how I said that sqrt of unit quaternions and multiply with one conjugated are basic building blocks? These composed together result in zero trig and one square root. Apply the quaternion rotation equation 3 times to (1,0,0), (0,1,0) & (0,0,1) and you have a matrix form that requires zero roots in the unit vector case.

EDIT: Oh and it should be obvious that there are not multiple solutions. The solution is unique.

Just noticed that today is JOML’s first birthday! :slight_smile:

Celebrating this anniversary with a new 1.7.0 release and the first steps of expanding JOML into the realms of geometric intersection algorithms, some of which are already being used by @theagentd in WSW.
They can be interesting for people wanting to do their own physics, which does not require a full physics engine like jBullet, or just for checking whether things intersect each other.

JOML - Reference Card for Matrix4 (Version 1.7.1)

JOML is a good reference, but I had trouble deciphering the algorithms used in Matrix4f, as it deals mainly dumping matrix data into new matrices when translation or rotation goes on.

Hmm. I see you’ve started using the word “affine” for certain functions. Might want to rename the “4x3” ones to something like that too, as they work on affine transforms too.

Great idea, thanks! Will do. That’s exactly why I like working with people who really know about and are engaged in the topic.

If you want to know more about the algorithms/formulas, then Wikipedia is a good resource. Many more complex JOML methods are also annotated in their JavaDocs with references to web pages describing the algorithm/formula.
I was being told that Khan Academy has a good course on linear algebra, too: https://www.khanacademy.org/math/linear-algebra

I’ve searched and searched but anything on the wikipedia math wise isn’t legible to me and everyones complex answers don’t revolve around how the matrix exists, but just where it is stored. The translations and rotations algorithms don’t explain anything on this subject, and for opengl tutorials its all the fixed function pipeline and hidden method bullcrap that are either outdated or just stupid. > Refers to my post about decent learning material <

The topic itself is not easy to actually “explain” and I agree with you that it is hard to learn.
At some point with math we just have to simply accept that it is what it is and that it works out.
With rotation I was about to explain this. It has not yet reached at the actual “matrix”, but it will lead to it, until I made the step from ad-hoc/manual formula to linear algebra with matrices.
Maybe you can make something out of this.

I opened it to look at it and when it didn’t explain to me what the coefficients and subscripts were I kind of just assumed and then got bored within two minutes. “Let R represent the rotation and sub x represent the x axis” would be nice. I also found that in school textbooks, the text right next to the code (which btw is in top to bottom per step, not side by side which could come in handy to represent, but I can see why its left to right) which explains the steps briefly like…

2z + 3z + 2z = 180 Set all outer angles equal to the sum of all exterior angles
7z = 180 Combine like terms
z = 180/7 Solve

Khan Academy’s linear algebra videos got me an A in Linear Algebra at my uni. They’re AWESOME at explaining the basics and giving you an intuitive idea of what’s going on underneath the surface, which sounds like exactly what you want. I can admit that having the tutorials in a video format is a bit annoying since it takes time to watch them, but they’re well worth it.

I can totally agree with you about college textbooks being extremely bad at actually TEACHING you new things. They’re almost always just throwing shit out there and expecting you to get it. This is especially true for university/college text books in my experience. My statistics book would throw out a crazy formal expression defining a Poisson distribution, not even bothering to explain what the different variables stood for. Khan Academy would start with a binomial distribution, give an example of an interesting problem and then derived the expression for a Poisson distribution to show the motivation and meaning of all variables in an extremely effective way. Khan Academy has their shit straight.

It’s also worth mentioning that most of the higher academic world is really frigging annoying when it comes to actually explaining things, and it’s best to get used to it. Learning from formal sources takes a crapload of time. I’ve learned that the best way for me to understand scientific papers is to just read a few things from it each day and trying to understand it. Example: Weighted Blended Order-Independent Transparency. 20 pages just to describe creating a weighted sum and dividing by the weight at the end, plus calculating the alpha value correctly. The code for this is literally ~20 lines. It took me over a week of skimming through the paper a bit every day understanding nothing until it finally clicked, and the ground trembled from the massive “meh” I let out.

Khan Academy isn’t the most reliable source for all of that is there. I don’t like Khan Academy to a certain extent condoning only subjects. However, I am using it right now to learn the entire course of trig. I am almost done. Proud of myself. pats back :point:

Having this sort of attitude is a sure way of never learning anything. Maybe certain concepts came to you easily in the past, but that’s no guarantee that it is always going to be the case.

Math is not easy. Programming is not easy. Learning any field beyond a few basic ideas is not easy. If you don’t understand something you have to look for explanations, and explanations for those explanations, etc. until you finally get it.
If you find yourself in way over your head, it’s probably because you’re trying to learn something without the proper foundations of previous concepts, in which case you need to take a step back and learn all those.

If you want to become good at something, you have to work hard at it, whether it’s interesting or not.

There are SOOO many resources on the internet to learn things that there is almost something for everyone. My favorite for linear algebra is

Note there are many other courses there too.

Expecting everything for free though and complaining when “free” doesn’t have exactly what you want is not very good. In those situations either pay some money for better material or ask lots of questions on forums to fill in the gaps.

True that, but the problem is finding the good stuff. In my experience the best teachers are the ones who recently learned what they’re teaching themselves, because they remember what was difficult to understand when they learned it. Pretty much all school text books are written by professors who are extremely good at their subjects, but they also have no connection at all anymore to the students that are using their books. It’s hilarious how all these books have “reviews” from other professors saying how it’s such a good book. Like, how the hell would you know? You already know all this stuff. You can just verify that the facts are correct, not that it’s a good book for learning that stuff. Plus the obvious risk of buddy reviews between professors.

You probably already figured out this much, but this is my favorite primer regarding matrices in programming: https://www.sjbaker.org/steve/omniv/matrices_can_be_your_friends.html

LA is meta. I found thinking of it in it’s original context the easiest to understand…specifically a system of equations. So a 3x3 rotation matrix is a set of 3 equations: how each of x,y & z map to a new values in a different coordinate frame. Moving to 4x3 or 4x4 simply allows adding new terms to each equation formed by a matrix product. Of course LA has it’s own structure and properties which can give you additional insight into the equations in question that individually may not be obvious. Likewise for looking at the same problem in language of some other area of mathematics. So it goes.

I like the bottom portion, but they don’t really explain it well enough to grasp imo. Although, I know matrices enough now.

The TypeScript/JavaScript variant JOML.js now has a first build system working under Travis, which compiles the TypeScript files to a single joml.js under target/.
That JavaScript file can readily be used in your JavaScript/WebGL project. See the GitHub README.md on how to use it.
If you happen to use TypeScript, then please instead use the provided *.ts files under src/ to also have typesafety and auto-suggest. You only need to reference the single joml.ts file, which itself references all other files.

Btw. what do people use these days to build JavaScript projects? —> Make? :smiley:
Well… I did.

To build yourself you only need Make, nodejs and typescript installed (via npm install -g typescript).
Windows users: Building works under GnuWin32 make, mingw32-make, MSys make, as well as under Cygwin.

EDIT: Actually, you don’t even need Make now, since you can just invoke “tsc” without any arguments since now a tsconfig.json is present.

Good job.

Ewww JavaScript :stuck_out_tongue:
Lua master race!