View Full Version : OpenGL Math Library

gator

01-31-2004, 07:23 PM

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.

madmortigan

02-02-2004, 08:01 AM

Welcome to the jungle!

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.

gator

02-02-2004, 10:46 AM

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.

gator

02-02-2004, 04:26 PM

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

Cyranose

02-02-2004, 05:08 PM

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. http://www.opengl.org/discussion_boards/ubb/smile.gif

Avi

madmortigan

02-03-2004, 12:19 AM

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.

gator

02-03-2004, 05:29 AM

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?

gator

02-03-2004, 10:00 AM

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.

Dr Dogg

02-03-2004, 11:03 AM

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.

madmortigan

02-03-2004, 03:11 PM

Testing a math library

One option is to write some sort of layer, a set of adaptor classes, which will bind the math lib under test and the classes that are actually used for the definitions of the tests.

There is going to be an overhead using these classes, but this can measured and analysed, and in any case, we only want to see how one lib compares to another.

There are probably many ways to implement the test suite. The difficulty is to find a sufficient set of tests and say to everyone, here are the tests, pass these and your math lib is good.

A starting point could be some weird old theorems from Euclidean geometry.

xDigital

02-22-2004, 11:08 PM

Well, there is a math-library which inherits almost everything you might need in your application. Try the matlab library. Ok, matlab is not the cheapest tool, but if you want to start coding your own math-library keep in mind, that there are several more methods needed than transform from location a to b. Start with dynamic resizing of matrices for dimensions greater than 3. The Gauss Algorithm is nice to have, but useless if you want to handle matrices with dimensions of 500+. Only better algorithms gives you acces to determinants, inverse matrices, eigenvalues and so on.

But hey, I'd like to have a math-lib, too.

Regards xDigital

pothik

03-09-2004, 03:20 PM

Hi,

I'm writing a repot on the math behind the I-DEAS (NURBS). Can anyone help letting me know any information availabe on that on any book/ any link or giving some information?

Wishes,

Pothik

Coconut

03-11-2004, 09:25 AM

The thickest book about NURBS is "The NURBS Book" written by L. Piegl and W. Tiller.

It is an excellent book, but it is thick (646 pages).

There are numerous books/web stuff about NURBS, I would google "NURBS" to find our more.

pothik

03-12-2004, 05:58 AM

Thanks a lot. But, actually my problem is to know how I-DEAS use NURBS surfaces. I need some information about basic mathmematics behind I-DEAS.

I've some information about NURB , but how I-DEAS use those, I dont know that in details.

Would you pls suggest me something about that??

Thanks again

pothik

03-12-2004, 06:01 AM

One more thing, I was looking for some relative advantages and disadvantages of I-DEAS over CATIA,UG, PE,SE etc..

I've searched online, but don't get anything helpful..

Can u please suggest me where can i get those informations? any book/ link..?

Regards,

Pothik

paraprax

03-12-2004, 11:39 AM

I've got the beginnings of an opengl oriented math lib for C++ written and am just about ready to make it publicly available under a BSD-style license. It's pretty heavily templated, and is done in such a way as to allow things like SSE optimizations to take place automagically via operator overloading. I haven't implimented these yet, but I hope to get to that soon.

So far I have vectors, matrices, quaternions, and 2d lines in there, as well as some interpolators (catmull-rom, slerp).

In addition to the math classes, it also has a set of wrapper classes for dealing with vertex attributes in a generic way.

For some preliminary docs, check out http://web.ics.purdue.edu/~gennis/pell.xhtml

I hope to be able to get things cleaned up a bit and put on sourceforge or something similar over spring break (next week). Let me know what you think.

Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.