4 ms·
Geometric algebra looks cool, and this library seems like exactly what is needed for graphics programmers to use it. What I'd really like to see is a comprehen
by modeless 7y ago
Geometric algebra looks cool, and this library seems like exactly what is needed for graphics programmers to use it.
What I'd really like to see is a comprehensive cheat sheet with formulas for common tasks in computer graphics with an absolute minimum of theory and jargon; even less than this article. Of course it's great to learn the theory too, but most people just call slerp in a quaternion library without learning the theory of quaternions. It should be possible to use a geometric algebra library in a similar way.
- iod 7y agoMaybe you want to check out a javascript implementation of GA math with Ganja.js. While not yet comprehensive to all the tasks you probably would want to see, it does have some good examples that you can play around with https://enkimute.github.io/ganja.js/examples/coffeeshop.html#pga2d_inverse_kinematics https://enkimute.github.io/ganja.js/examples/coffeeshop.html...
- jiggawatts 7y agoThat library pisses me off on a visceral level. The author "Enki Mute" is no doubt a brilliant mathematician, his library looks awesome, the online demos are unreal, but he's squandered his talent. The code he writes is unreadable gibberish. Zero useful comments. One-character variable names. Stringly-typed programming. Regex soup. It's psychotic. I tried to reverse-engineer it in order to write a SIMD-optimised Rust version. But fuck me. It's like disassembling the machine code of an obfuscated anti-cheat library. Even with good tooling and industrial-strength refactoring, I couldn't make enough sense of it to make any useful headway. Just try and read this. Seriously: https://github.com/enkimute/ganja.js/blob/master/ganja.js https://github.com/enkimute/ganja.js/blob/master/ganja.js What saddens me is that every other library I looked at was ancient and no longer maintained. Half wouldn't even compile. Most started with an explicit assumption that only 2D, 3D, or non-degenerate metrics are needed. Very few have efficient code-generation, and those that do are invariably C++ only, but I'm never going back there, even at gunpoint. Just shoot me now, I'd rather eat a bullet than face another STL compilation error that I have to decode from a linker error to do with __malloc() or some garbage I don't care about. Enki Mute's Ganja.js is the only recent GA library I've seen that ticks all the checkboxes, but when I opened it up, I faced only the unspeakable horror of yet another dead end. GA is going nowhere because everyone cooks up their own special version, the terminology is unique and special to each researcher, and most libraries stop just short of being useful. What we need is standardisation around a well-documented and extensible library with polyglot code-gen. Something with expression simplification, SIMD, and both maths-centric and 3D graphics optimised capabilities. Ganja.js is not it, unfortunately.
- BorisTheBrave 7y agoAre we looking at the same file? It has masses of high quality comments. I think calling this stringly typed is unfair. Basis names appear to be strings with some densly coded information in them, and can sometimes take the values "-1", "0" or "1". But they're not integers, and it matches the mathematical notation used very closely. I see plenty of 1 character variable names, but the vast majority are either loop variables, or have a comment near the top of the file explaining their meaning, or are the only argument on a commented/named function. I see plenty of regexes, but they are all extremely short matching patterns. So it looks pretty good quality to me. Extremely densely written, typical for the "genius mathematician" programmer, but with some effort put into clarity.
- jiggawatts 7y agoAre we? The comments are all of the style "now, this is the thing that is the thing". None explain anything at all other than to give names to variables or functions. Which you know... can already be named using identifiers in the language. What are the matrices of constants? Where do they come from? What do they mean? What is their purpose? What are the random indexes into arrays? What do they do? This is one of the first "comments": // Documentation below is for implementors. I'll assume you know about Clifford Algebra's, grades, its products, etc .. // I'll also assume you are familiar with ES6. My style may feel a bith mathematical, advise is to read slow. I don't know about you, but whenever I see a comment littered with typos that says "this is a bit hard to read", it's a sure sign that whatever is to follow is of low quality. Not reusable. Not suitable for widespread use. Not extensible. Not useful at all. To reiterate: this makes me sad. I really wish it didn't, because GA is one of my favourite things, and this Enki Mute guy is clearly one of the few people that also "gets it" and wants to spread the good work. Clearly, his heart is in the right place. I know people like this guy. I went to University with a chap who would casually litter his Haskell code with 5 dimensional arrays of functions. Now I'm sure that made sense in his head, and his code actually worked, but no human being on Earth other than him could read it. He couldn't explain to me even verbally, let alone in comments. Unfortunately, while Enki Mute could have made a great contribution, his methodology has not helped GA become more approachable.
- modeless 7y agoGanja.js is exactly the opposite direction from what I want. The generality is not useful, the performance will be abysmal for graphics code, and the non-standard syntax is totally bonkers. It's a really cool experiment but not suitable for production use.
- ninepoints 7y agoOriginal author here, it is absolutely my goal that the library should be usable without needing to understand the ins and outs of GA. To this end, I've started adding a bunch of "helper" functions that do tasks like projecting a point onto a plane, or identifying the line through a pointer parallel to another line, etc. I've been (slowly) working on additional documentation in the meantime and didn't expect to see the animation article hit the frontpage :). That said, in the meantime, there is a GREAT cheatsheet for all the relevant formulae here: https://bivector.net/tools.html https://bivector.net/tools.html (scroll down to the bottom). You can get the PDF version here: https://bivector.net/3DPGA.pdf https://bivector.net/3DPGA.pdf
- auggierose 7y agoI was wondering, once you've abstracted from the GA bits enough, is there any point of using GA at all? I like GA as well, just wondering what it gives you once you've abstracted it away. Or in other words, are there aspects of GA that cannot be abstracted away like that?
- amelius 7y agoI guess you can abstract away a lot, but there will always be questions that require you to go back to the math. For example: a use would be to set up a transformation that projects points onto a plane and a library could cover that. But consider the question of having a bunch of points and (paired with them) projected points and given the task of computing the original projection transform. If the library doesn't contain that operation you'd have to do it yourself.
- modeless 7y agoThe main benefit I see is the generality of the formulas with no special cases for things like parallel lines. That should still work.
- ninepoints 7y agoYes actually :) It took me a long time to actually decide to invest in GA because the sentiment I had was "it just replaces what I already know" and what I knew at the time was matrices, quaternions, and dual quaternions. It turns out, I was pretty wrong in that respect. For example, in the current predominant formulism, it's awkward to rotate a line with a quaternion, then identify the dual quaternion that maps that line to yet another line, then apply that dual quaternion to a point. In GA, this just works (mind exploding gif). Or, I can construct a line between two points, then find the quaternion that maps a different line to that one, and convert it to a matrix to do "look at" transforms in a shader. Also just works. I think the more I use GA, the more elegant I find it, and it takes me well past the formulism I used to know (which is still useful from time to time, but far less expressive). While I could provide helpers for all the common operations, the operators in GA will always have their use because... there's just so much you can do with it. At some point, the library will just because unwieldy/large. I haven't necessarily found the sweet spot yet for size/convenience, but I hope to converge there over time. Provide enough to be usable for most people, while at the same time being a launchpad for learning more about the abstraction itself. From an implementation point of view, I've found a number of optimizations that were made easier (or even possible) with GA that I hadn't identified despite working with quaternions for years before.