4 ms·
Very interesting, but in the end this violates many good programming practices. The author is going to end up with a single type that can represent points, line
by phkahler 6y ago
Very interesting, but in the end this violates many good programming practices. The author is going to end up with a single type that can represent points, lines, rotations, planes, and probably more. The same operations will do different things based on which of those things you give them. It's important that the compiler can figure it all out because the programmer won't be able to tell what a*b does by looking at their code.
Not sure if I should be impressed or horrified. ;-)
- fanf2 6y agoMy plan is that the geometric algebra operations will be generic in Rust like they are in maths, but application code will be more concrete, using type aliases for points, rotations, etc. So the programmer can choose to be as abstract or specific as they want, depending on what makes sense in a particular situation. For example, if I have something like a polyhedron, I'll declare that as an array of points. A function for something like intersecting a line with a face (raytracing) will be generic internally but have a more concrete signature. I don't yet know how well this will work in practice :-)
- phkahler 6y agoSounds good. Keep going. We can never move forward if nobody tries.
- jiggawatts 6y ago> The author is going to end up with a single type that can represent points, lines, rotations, planes, and probably more. That's the point of geometric algebra! The concept is that you can think of a line as a circle with infinite radius. Similarly, a plane is a sphere with an infinite radius. A rotation is can be represented using two reflections along lines or planes. Etc... This makes some algorithms much more elegant, by removing conditional "if" statements. This matters when interpolating, which is the most common practical application of GA: game engines and robotic control often have problems with interpolating arbitrary rotations. With GA, there's no problem.
- valenterry 6y ago> The concept is that you can think of a line as a circle with infinite radius That's a different thing though. "Thinking of something as" is not the same as "is" in terms of types. The OP is right that in terms of programming ergonomics, it would be better to have distinct types that share the same operations, so you can _treat_ them in similar ways.
- jiggawatts 6y agoYou can have mathematically meaningful sub-types of a GA multi-vector that also map nicely to some basic shapes or transformations. Generally speaking, a multi-vector can be broken down by which "grades" it contains. There are subspaces like "all even grades" that are closures under all basic operations. If I remember correctly, the "even subset" of a 3D GA multi-vector is isomorphic to the Quarternions, which is why they turn up so often in 3D graphics libraries. But think about how messy this is! These 3D libraries are blending together subsets of vaguely related algebras that are not "compatible" from a type theory perspective and so they're forced to convert back-and-forth. It's like mixing Unicode UTF-8 with Latin-1 byte strings. If you squint, it looks like one is the subset of the other... but not really. With a pure GA-base library, the "rotation interpolation" functions would use the "even multivector subset" type, and be totally compatible with the rest of the library. It's the same type definitions, just with different parameters. This would be like using UTF-8 Unicode throughout the program, but having the ability to define a string-based type that only allows the "Basic Multilingual Plane".
- valenterry 6y ago> It's the same type definitions, just with different parameters The wording is important here. These "type definitions" you are talking about are not types. We usually call them "type constructors". So we mean the same thing, but please don't call multivector out to be a type without specifying the "grade" (then it becomes a type).
- a1369209993 6y ago> That's the point of geometric algebra! Yes, exactly. And making that not happen is the point of using distinct types `int` vs `float` vs `char* ` vs `struct foo* ` rather than stuffing everything into a `register_t`, or worse, `object`. (Or, as the case may be, `scalar` vs `vector` vs `bivector` etc, rather than stuffing everything into `multivector`.)