• nlgranger@lemmy.world
    link
    fedilink
    arrow-up
    13
    ·
    edit-2
    1 day ago

    As an engineer, Z up right handed is the only one that makes sense. All engineering follows this convention, motion sensors (example) or GPS topography will use that.

    Cameras calibrations also use right hand but typically rotated such that it’s X right, Y down, Z depth. That way, the projection formula give the pixels column, row and depth values.

    camera coordinate system

    • calcopiritus@lemmy.world
      link
      fedilink
      arrow-up
      18
      ·
      1 day ago

      IMO there’s no correct answer. It depends on the purpose.

      Intuitively XY forms the plane where things are and Z is used for the “additional dimension”. Since first we think of 2D, and then we move to 3D, so it’s the natural way we think.

      So if you make a cities skylines type 2D game, the XY plane will form the ground. Which means that when you want to make the game 3D, Z means up.

      But if you’re making a platformer game (like old marios), you have XY being the left-up plane, like when drawing a graph in a paper. Then if you want make your game 3D (as in, having 3D models for assets, the movement would still be the same 2D). Then the Z will be forwards.

      Sometimes, even Y being down makes sense. Like with UI programming. This is specially important for window resizing. When you resize the window, you want everything to look roughly the same, but with more space. That is easier if you use (0,0) in a point that doesn’t move when resizing, like the top-left corner. Since the bottom-left corner moves if you make the window taller.

      • dejected_warp_core@lemmy.world
        link
        fedilink
        arrow-up
        7
        ·
        1 day ago

        I think the preference for Y being the vertical axis in gaming, comes from a legacy of orienting the work around screen-space (roughly 50 years ago). It was more efficient to have a memory layout that is easier to supply data to generate a TV signal. Since a CRT raster goes from upper-left to lower-right, line-by-line, that became the standard for screen-space: inverted y. So screen memory (or however the screen is represented in RAM) starts at address/offset zero, and increments from there. All the other features like hardware sprites, used the same convention since it was faster and simpler to do (easier math).

        When consumer 3D cards were relatively new, this was inherited, most notably when the hardware started to ship with “z-buffer” support. Carrying all this baggage into 3D engines just made sense, since there was never any confusion about the screen-orientation of it all. Why bother flipping axes around from world and camera space to the screen?

    • soulsource@discuss.tchncs.de
      link
      fedilink
      English
      arrow-up
      7
      ·
      1 day ago

      In Physics we mostly used right-hand, but X-right, Y-up, and Z pointing towards the viewer.

      But that’s details. The only important choice is between left- and right-handed, as that affects the signs in the cross product (and some other formulas - generally everything that cares about which rotation is considered positive).