Sitelet https://github.com/google/mathfu/issues/22
Skip to content
This repository was archived by the owner on May 6, 2024. It is now read-only.
This repository was archived by the owner on May 6, 2024. It is now read-only.

Ortho/Perspective matrices are different than from DirectX 9 Math library. #22

Description

@FrankStain

Hi there.
Currently i have working on some test and found some unclear moments between Mathfu and DirectX Math.
I know how the canonical perspective and orthographic matrices looks like. What i wondering is why DirectX Math uses different calculations for perspective and orthographic matrices?
I work with DirectX Math almost 10 years and never had a problems with projection matrices.

For example i had run tests from 'matrix_test.cpp' for DirectX 9 Math and get next results.

Right-handed perspective
   ( atan( 1.0 ) * 2.0, 1.0, -2.0, 2.0 )
        Mathfu              DirectX9
| 1.0  0.0  0.0  0.0 | 1.0  0.0  0.0  0.0 |
| 0.0  1.0  0.0  0.0 | 0.0  1.0  0.0  0.0 |
| 0.0  0.0 -0.5 -1.0 | 0.0  0.0 -0.5 -1.0 |
| 0.0  0.0  2.0  0.0 | 0.0  0.0  1.0  0.0 |

Left-handed perspective
   ( atan( 1.0 ) * 2.0, 1.0, -2.0, 2.0 )
        Mathfu              DirectX9
| 1.0  0.0  0.0  0.0 | 1.0  0.0  0.0  0.0 |
| 0.0  1.0  0.0  0.0 | 0.0  1.0  0.0  0.0 |
| 0.0  0.0  0.5  1.0 | 0.0  0.0  0.5  1.0 |
| 0.0  0.0  2.0  0.0 | 0.0  0.0  1.0  0.0 |

Right-handed orthographic
      ( 1.0, 3.0, 1.0, 3.0, 1.0, 3.0 )
        Mathfu              DirectX9
| 1.0  0.0  0.0  0.0 | 1.0  0.0  0.0  0.0 |
| 0.0  1.0  0.0  0.0 | 0.0  1.0  0.0  0.0 |
| 0.0  0.0 -1.0  0.0 | 0.0  0.0 -0.5  0.0 |
|-2.0 -2.0 -2.0  1.0 |-2.0 -2.0 -0.5  1.0 |

Left-handed orthographic
      ( 1.0, 3.0, 1.0, 3.0, 1.0, 3.0 )
        Mathfu              DirectX9
| 1.0  0.0  0.0  0.0 | 1.0  0.0  0.0  0.0 |
| 0.0  1.0  0.0  0.0 | 0.0  1.0  0.0  0.0 |
| 0.0  0.0  1.0  0.0 | 0.0  0.0  0.5  0.0 |
|-2.0 -2.0 -2.0  1.0 |-2.0 -2.0 -0.5  1.0 |

This moment is crucial in cross-platform development perspective. In fact, the DirectX math library is good enough for using it on Windows desktop systems. But for portability purposes we need another math library. And Mathfu looks good enough to use it on other systems.

But that difference mixes the cards. Does the different calculations makes the real difference in results?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions