phkahler 12 days ago

Fun fact. Take 4 points representing the vertices of a tetrahedron. Put them in a 4x4 matrix, using 1 as the 4th element then invert the matrix. The 4 row vectors of the result will be the coefficients for the plane equations of the faces of the tetrahedron.

They'll be scaled such that the point not on a plane will evaluate to 1 when plugged into the equation. You can see this easily because multiplying the planes matrix by the points matrix is just plugging each of the 4 points into each of the 4 plane equations, and you get the identity matrix by definition.

  • thechao 12 days ago

    > They'll be scaled such that the point not on a plane will evaluate to 1 when plugged into the equation.

    Evaluating a plane equation with a point will give a signed distance from the point to the plane. However, unless the equation is normalized, the distance could be scaled in unusual ways that are less than useful. I think a better way to say this is that a point who's shortest straight line distance to the line is 1 will evaluate to 1, after taking the absolute value.

    The LRBni ISA had a whole set of instructions designed to take advantage of signed distance fields defined in both plane equation & barycentric forms. (That's what the bit mask for the lanes was for, in part.)

    • a1369209993 12 days ago

      > However, unless the equation is normalized, the distance could be scaled in unusual ways that are less than useful.

      > > []the[] point not on a plane will evaluate to 1

      They mean the vertex (of the tetrahedron). The signed distance function is scaled such that the (single remaining) vertex that isn't at distance 0 (by construction) will instead be at distance 1. So the distance is always scaled in a unique well-defined way (assuming not all four points are coplanar). Whether that way of scaling is useful depends on your use case, of course.

  • nbcomplete 12 days ago

    [flagged]

    • radarsat1 12 days ago

      Even though it's well intended, I feel like pasting in responses from ChatGPT should be against HN guidelines, if it's not yet. Reason is, if I want that type of explanation, I can go and get it myself. I come here for people's personal comments, not to read them regurgitate what they had an LLM generate. And I use ChatGPT all the time so don't get me wrong, I just think it doesn't add a lot to the discussion here and takes up a lot of room.

      • Terr_ 12 days ago

        I'm torn on this, because I don't want to have LLM stuff gunking everything up either, but I think there's a general case to be made for comments like: "For anyone who is confused about X like I was, I found this explanation."

        In other words, how would one exclude LLM regurgitation but permit Wikipedia quotes?

        • amelius 12 days ago

          Ask the LLM to cite a source, then use that.

      • robswc 12 days ago

        I agree on principal and instinct... but then I realize how often people add quotes from Wikipedia or 1st or 2nd results from a google search.

        Maybe most of the bad vibe comes from the "wall of text" and "tone" ChatGPT outputs.

gary_0 12 days ago

I was recently algebra-ing down a complex 3D algorithm to speed it up, and it seemed peculiar how so many things can be boiled down into to a crap-ton of dot products. One of the recurring mathematical themes of the universe, I guess.

  • SardineArmor 11 days ago

    This is because you weren't algebraing, you were pre-Hilberting :)

    Let's forget we're in finite dimension for a minute, in which case it is not trivial to expect a scalar product on our vector space.

    So now we have two things, which are separate: a vector space, and a scalar product.

    The vector space says: you can sum my elements, multiply them by a scalar, and I'm stable by linear combinations. That's all it says, really.

    Everything else, the geometry, is a consequence of the scalar product. It even defines the norm in the first place, thus the topology. For instance, there's no talking about convergence in a vector space if you don't have a norm. You can't even tell if a sequence converges.

    You can define a norm without a scalar product, of course. But then you lose certain notions, like orthogonality.

    Anyways, in the case of finite dimension vector spaces, there's always a scalar product at hand, and this is where the geometry comes from, really. The algebra portion of it - being a group with a scalar multiplication - is certainly necessary, but not the one to define geometry.

shiandow 12 days ago

Shame this doesn't include my favorite description, a 4d vector in projective affine coordinates.

Instead of a normal and point or constant you get (x,y,z,1) . P = 0. The translation between the two is trivial. If you want a plane spanned by 3 points you just can use the generalized cross product to find P.

One advantage is that you can avoid all the special cases with 3 intersecting planes. There exists exactly 1 point that is on all 3 planes, but as this is in projective coordinates it might lie at infinity.

  • alexharri 12 days ago

    I haven't heard of this before, I'd be interested in learning more about how this is useful. Do you know of a good resource to read more about this?

    • shiandow 12 days ago

      I honestly don't know, I encountered the concept during my study, but it took lots of practice to get comfortable with it. Most articles I encounter are too practical to really foster understanding, or too technical to work as an introduction.

      You can start with a description of how projective matrices work (and how translation and rotation are related to it). After that, best tips I can give are start with 2D until you can't bear to see another cross product. Then get familiar with Cramer's rule and higher dimensions. You'll need sone fluency in linear algebra.

      My first practical use of the concept was to rectify photographs where e.g. a building was not quite upright. That might be a good starting point.

      • alexharri 12 days ago

        Thanks a lot, will use this as a starting point

  • boppo1 12 days ago

    Do you have any good resources for developing an intuition about the projective plane?

jsenn 12 days ago

Another useful representation is as a point in spherical coordinates. The polar+azimuth angles encode the normal, and the radius encodes the distance from the origin.

This is handy because it puts similar planes nearby in space. For example, it allows you to efficiently cluster objects by coplanarity using a spatial index.

  • zodiac 12 days ago

    Interesting, in this representation a plane is represented by the point on it closest to the origin, right?

    • jsenn 12 days ago

      Yes, that's a good way of thinking about it.

BenoitP 12 days ago

What a wonderfully crafted piece. But a part of me can't refrain from saying it would have looked way more elegant and succinct in 3D Projective Geometric Algebra.

Most of the last sections (all intersections) feel like corner cases, when in PGA they are one and the same.

  • at_compile_time 12 days ago

    Yup. Geometric algebra has one equation for each of: projection, rejection, join (e.g., two points into a line), and meet (e.g., two planes interacting at a line). The algebraic expression is the same regardless of the elements you're working with or the space you're working in.

    You get transformations too, as easy as M=b/a, where M can be applied to any element in the algebra by taking the square root and applying double-sided multiplication such that b = √M a ~√M, where tilde represents the reverse. These transformations are isomorphic to complex numbers, quaternions, and hypercomplex numbers, and understanding them makes other explanations of these concepts feel inadequate and woefully un-geometric.

    Add in logarithms and the exponential map for these transformations and we can perform linear interpolation between states and parametrize transformations.

    I'm just a motivated amateur and I can do all of these things. The vector algebra I learned in engineering is useful, and it's often all I need for simple 3-dimensional problems, but it's just shy of something far more powerful and far more general.

  • ngruhn 12 days ago

    I keep hearing this and I'm very interested. But most recommended resources I've seen so far are more targeted at Physicists. Any good text book for CS people?

    Edit: nevermind, read in other comments that https://bivector.net/ has a ton of resources.

  • sebastos 12 days ago

    For those interested, this appears to be a really high quality library that provides a 3D PGA C++ API:

    https://github.com/jeremyong/klein

    I've always wanted to find an excuse to rebuild some projects at work around this.

ReleaseCandidat 12 days ago

There is an error in the line's description, any normal of a line is perpendicular to the line itself (all through a point of the line are contained in a plane perpendicular to the line, with two special ones, the principal normal and the binormal, as with every curve) and does not point "in the direction of the line".

A remark: a plane has two (different) unit length normals, which point in exactly opposite directions (one can be obtained by multiplying the other by -1). This determines the positive and negative half-spaces in which each plane splits the 3 dimensional space - the positive and negative direction, which appears for example in the distance calculation on the site.

greenbit 12 days ago

"A plane in 3D space can be thought of as a flat surface that stretches infinitely far, splitting space into two halves."

Fun fact - if you have the coefficients of the equation ax+by+cz+d=0 that represents your plane, you can plug any point (x,y,z) into the expression ax+by+cz+d, and the result will be positive in one half-space, and negative in the other. I think if you divide the values by sqrt(a^2+b^2+c^2), you end up with the distance from the point to the plane. Easy enough to see which half-space is which by plugging in the origin. I.e., if 'd' is positive, the origin is in the positive half.

memco 12 days ago

Are bivectors a 4th way to express planes in 3D space or is that what the 3rd method the article describes is. I didn’t see them mentioned anywhere in the article. I only have a cursory knowledge of their existence and use so not totally sure how they fit, but I feel like they should.

  • tsuru 12 days ago

    If you use 3D Plane-based Geometric Algebra (https://bivector.net) planes are vector elements and bivectors could be the line intersection of two planes. I'm grossly simplifying here, see link for more info on this interpretation. There are more algebras that have other interpretations of bivectors.

mwexler 12 days ago

Just to get it out of the way, I assumed just from the title that this was about airplanes in 3d space and was excited to see what I was missing, as I thought they all flew in a 3 dimensional context.

I know I'm not the only one...

  • ReleaseCandidat 12 days ago

    There are woodworking planes too, with which the title makes more sense.

absurdcornbread 12 days ago

Where can I get a job developing software using these kinds of techniques? I had to perform a ray tracing calculation one time (before I knew what ray tracing was and was essentially deriving the same things the author is talking about) and absolutely loved working with 3D geometry and implementing it into software.

What kinds of industries should I look for to essentially work with programming math problems like this?

dargscisyhp 12 days ago

Great article, would love to know what you're using to create these diagrams!

  • alexharri 12 days ago

    They're created with ThreeJS and react-three-fiber. My website is open source, you can find all of the 3D scenes here: https://github.com/alexharri/website/tree/master/src/threejs...

    • pixelpoet 11 days ago

      Nice work, one thing (which you'll see everywhere once you've fixed it yourself) though: in TeX you want to escape functions like cos, i.e. use "\cos" not "cos", which will get rendered as a product of 3 variables c, o and s.

      • alexharri 11 days ago

        Just pushed a fix changing "cos" to "\cos", looks much better. Thank you!

randv 12 days ago

super cool...thanks

makerdiety 12 days ago

> Learning about planes felt abstract and non-intuitive to me. “Sure, that's a plane equation, but what do I do with it? What does a plane look like?” It took some time for me to build an intuition for how to reason about and work with them.

Imagine how far human society can go if people dumped the desire for intuition that appeals to anthropocentric sensibilities.

But I guess that's forbidden dark arts and wasting time with trivial pursuits and stuff is the culture to adopt while you're in the modern day Rome equivalent.

y = mx + b is enough for me.

  • harshaxnim 12 days ago

    Anthropomorphic intuition has its advantages - it cuts down the ideas search space with its learnt heuristics. We are intuitive beings, and system 2 thinking is very deliberate and not so natural to us. Secondly, it might often be intractable to process things with sys2 thinking. That said, I don’t think anthropomorphic intuition is necessarily static; I can learn new intuitive skills with enough practice - for example, a person grown in a tribe with very rudimentary speech cannot intuit how to communicate even mildly non-simple ideas, but I can do half a decent job very intuitively.

    And finally I think even if you don’t care for intuition, it cares for you. I mean, if you play with y=mx+c long enough, you’ll gain an intuition, intuitively. So, with these devices (like visualisers etc.), we’re essentially trying to gain an intuitive understanding deliberately, which I see nothing wrong with. It’s just meta intuition.

    • makerdiety 12 days ago

      A preference for level two is what got us a general theory of relativity and, subsequently, working global positioning satellite technology. Having a cognitive bias toward visual presentations of planes in 3D and higher space leads to techno-scientific stagnation.

      • sqeaky 12 days ago

        I think you have this exactly backwards. Einstein applied his intuition to find gaps in special relativity. He had built an intuition for how light works and asked what happened in corner cases so he could rapidly understand the boundaries of. Then after finding those cases busted out the math to create a rigorous solution.

        Source: https://www.britannica.com/story/how-albert-einstein-develop...

        "Level two" ? As if there is a single best way to think and we should all climb towards it? There are advantages and disadvantages to every approach. Find what works in a domain and keep experimenting.

        • adrian_b 12 days ago

          The general relativity theory was not about gaps or corner cases of special relativity. It was about extending the theory outside its domain of applicability.

          The theory of special relativity showed how to transform the physical quantities between inertial reference systems, i.e. systems where Newton's law of inertia is true. The relative velocity between the origins of such systems must be constant and there must be no relative rotational movement between them.

          The theory of special relativity was not applicable to non-inertial reference systems, like one that has an accelerated motion relative to an inertial system.

          Einstein's quest has been to find the transformation relations for this more general case. Together with the theory of the stimulated emission of radiation (1917), this has been the most original part of Einstein's work, because the previous transformations of the special relativity had been discovered before Einstein, he had just given a new explanation for them.

          The only intuition related to general relativity was the guiding principle that whatever transformations will be found they must lead to indistinguishable local behavior of the forces of gravity vs. the forces of inertia.

        • makerdiety 12 days ago

          Karl Marx said something along the lines of "Each man does a job according to his abilities." Something like that.

          I take it, then, this modern society and civilization wants to specialize in low level technician style work and wait for aliens or angels to come and do the hard work of inventing faster than light travel? You know, intuition is the best scientists and engineers can do and all.

          • sqeaky 10 days ago

            I feel that you can't or aren't being serious. We just covered the go to example of a smart person doing the go to example of smart thing advancing advancing humanity's knowledge using intuition and other modes of thought.

            No one is saying we shouldn't also have other kinds of intelligence. You just started bashing one kind of intelligence, and provided quite possibly the absolute worst possible example.

            Thought, in the general sense, isn't a solved problem or even all that clearly understood yet. We don't yet have a working mathematical model of it and aren't even sure that will be a thing. At present we know of many kinds of intelligence and we can see then work differently on different problems.

            • makerdiety 9 days ago

              Since you insist in human intuition being a "required step in the process of knowledge discovery," I can safely say that your time preference you have is what led to the segmentation of the human species into categories such as races. When, really, any human baby born on Earth, absolutely any human child or man, that is, has the same genetics as a high level athlete like the famous Lebron James basketball player. There's no real difference between the races or types of humans. And, similarly, there's no difference between the "types" of intelligences that human intuition can help grab hold of.

              Quantum mechanics is a magical system, to you, only because you're limited and guided by your human biases and preferences. Dumping intuition is the way to go for seeing past the toys and child's play that is modern science, technology, engineering, and mathematics.

          • xanderlewis 12 days ago

            "From each according to his ability, to each according to his needs"

      • cityofdelusion 12 days ago

        Intuition is just a starting point — and one that changes with experience gained. Two students can start to learn piano either “intuitively” or mathematically and both end up at the same level of skill 30 years later. There isn’t some linear path of progression based off where you start — that’s what’s amazing about the human brain, it’s incredibly parallel and mesh based.

        • makerdiety 12 days ago

          The problem is that learning to play the piano isn't innovative. (So, technically, a monkey could eventually do it.) Because innovation is stifled by intuition. Particularly intuition meant to serve human ends.

          It's a simple equation: take away intuition and you're left with revolutions in technology and science.