Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: OpenGL Math Library

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jan 2003
    Posts
    146

    OpenGL Math Library

    Can you guess what the #1 thing on my list that is missing from OpenGL?

    That's right, a math library specific to OpenGL. Most of these functions we call
    like glMatrix, glRotate, glScale, glTranslate, etc... use math to some degree, so I think
    there should be at least a math library for OpenGL (like D3DX for DirectX).

    I'm sick and tired and putting together my own math library. It's bits and pieces of
    other math functions I've found on the web. I need something that is not only consistent,
    but covers everything from vectors, matrices, and quaternions, basic operations and
    conversions.

  2. #2
    Intern Contributor
    Join Date
    Sep 2003
    Location
    Jersey, Channel Islands
    Posts
    67

    Re: OpenGL Math Library

    Welcome to the jungle!

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Aug 2001
    Location
    Italy
    Posts
    628

    Re: OpenGL Math Library

    While I can see the usefulness of an "OpenGL math library", I would not like it. It's not strictly necessary so it should not be included to mantain the GL as small and simple as possible.
    By the way, I guess it's pretty difficult to do a library which is well-behaved to all the applications GL has. Going to the lowest common denominator wouldn't solve the problem.

  4. #4
    Junior Member Regular Contributor
    Join Date
    Jan 2003
    Posts
    146

    Re: OpenGL Math Library

    Just to avoid any confusion, I mean more like a compiled .lib as a math library.
    I don't want a math library built into the 'gl' interface.

  5. #5
    Junior Member Regular Contributor
    Join Date
    Jan 2003
    Posts
    146

    Re: OpenGL Math Library

    One of the areas that I get into trouble are conversions to/from the following:
    Euler angles, matrices, quaternions, and axis/angle.

    Euler angle->matrix
    Euler angle->quaternion
    Euler angle->axis/angle

    Matrix->euler angle
    Matrix->quaternion
    Matrix->axis/angle

    Quaternion->euler angle
    Quaternion->matrix
    Quaternion->axis/angle

    Axis/Angle->euler angle
    Axis/Angle->matrix
    Axis/Angle->quaternion

  6. #6
    Junior Member Regular Contributor
    Join Date
    May 2003
    Location
    New York
    Posts
    206

    Re: OpenGL Math Library

    Originally posted by gator:
    One of the areas that I get into trouble are conversions to/from the following:
    Euler angles, matrices, quaternions, and axis/angle.

    That's fixed in C++ easily enough by creating special unit-knowing types like Degrees and Radians instead of floats. The compiler can do one implicit conversion automatically, so you could have a function that takes Radians and pass it a Degree (with appropriate operator const Radians) and it will convert for you. This sort of type-checking can catch most of those errors, including axis/angle.

    I agree we need a standard lib and I'm happy to help write one in my free time. God knows most companies have crap math libs due to the pain-in-the-ass factor. All the time wasted debugging some client's pre/post matrix multiply routines could be better spent writing a solid math lib.

    Avi

  7. #7
    Intern Contributor
    Join Date
    Sep 2003
    Location
    Jersey, Channel Islands
    Posts
    67

    Re: OpenGL Math Library

    There are good reasons why providing this sort of standard is not a trivial issue. Most of these reasons have to do with the fact that developers usually taylor the math libs down to the needs of specific applications. They have to pull all these tricks in favor of stability and performance.

    One could always rip off math libs from some successful open source 3d engines. After all, this is what open source is all about.

    Having said that, how would we know the math lib we just got is a good one? What would be really useful is to establish a set of tests which a successful math library should be able to pass.

  8. #8
    Junior Member Regular Contributor
    Join Date
    Jan 2003
    Posts
    146

    Re: OpenGL Math Library

    That's a good idea, but I've never encountered any math lib testing tools before?

    And even if I grabbed some open source math lib, I'm sure there has to be an easy way
    to interface it with the testing part?

  9. #9
    Junior Member Regular Contributor
    Join Date
    Jan 2003
    Posts
    146

    Re: OpenGL Math Library

    I would probably use #define macros to interface the testing part. Maybe could also use
    Mathematica, Matlab, Excel to get good values, instead of writing it around an existing
    math library? But I don't have any math software.

  10. #10
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    England
    Posts
    10

    Re: OpenGL Math Library

    The DirectX math lib can actually be used with OpenGL too. (Just be carefull as the coordinate systems have the z axis reversed)

    I know that sounds frankly dodgy but it links into your code without any external dependencies.

    If your after cross platform compatibility, hmm, as madmortigan said, welcome to the jungle.

    Personally I liked the challenge of writing my own maths lib but I realise that's not for everyone. Just for a reference, the Quake III mod lib has a math section with most of the complex core functions such as SLERP which is quite good to learn from.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •