Jump to content
  • Advertisement
Sign in to follow this  
clb

MathGeoLib

This topic is 2260 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

one of the more common topics on the math forums here at GD is about 3D mathematics, geometry manipulation or primitive testing. A lot of people have written their own libraries for doing vector/matrix/quaternion math and geometric primitive intersection testing. There does not seem to exist a single library that would be specifically tuned for these purposes.

Along the years, I have accumulated tons of different utility functions for performing games-related geometric tests. Recently, I was faced by a task of implementing a script API for math and geometry handling, and that script API would be used by people who are very unfamiliar with scripting and mathematics in general. I started collecting all the code I had scattered all over, and bundled it up to a very object-oriented manner, so that I could create an automatic script bindings generator for exposing this functionality to a JavaScript engine.

The result is now called MathGeoLib, which is a C++ library for games-oriented 3D mathematics and geometry manipulation:

  • homepage
  • source code on github
  • class reference documentation
  • v1.0 zip package download


    I am not overly interested in "preaching" people to start using this library, since I am not that big fan of open source development in general and I have little time to do free maintenance work or tech support on the library ("you are on your own"). Instead, I hope that the documentation and online source code will function as a useful repository to anyone looking for code snippets on how certain intersection tests or mathematical constructs are often implemented.



    Any thoughts? Spot obvious bugs? Criticism? Am I good at drawing diagrams or what? :)

Share this post


Link to post
Share on other sites
Advertisement
I am wondering if anyone is going to code up some simple examples with this great lib?

Also do you have functions to do things like Polar to Cartesian and Cartesian to Polar coordinates? And Spherical coordinates....

Thanks!!

Share this post


Link to post
Share on other sites
Unfortunately, the MathGeoLib repository does not come with any sample applications.

MathGeoLib is being used in the realXtend Tundra codebase, although it's a large project that contains all sorts of other stuff, and it can be difficult to find examples there. Most of the MathGeoLib use in that project is in JavaScript form, since the MathGeoLib library is exposed to QtScript using automatically generated script bindings.

Apart from that, I do not know of any open codebases that utilize MathGeoLib. This demo uses MathGeoLib via cross-compiling C++ code to JavaScript using the Emscripten compiler. (and uses this rendering api). Unfortunately the sources are not available.

There were no functions for polar <-> euclidean conversion, but I added them in, if you update your git clone. (see this commit). Functions for spherical <-> euclidean conversion did already exist, but if you look at the online documentation for float3, you will not find them there, since I'm a bit afraid to update the online documentation because I've directly hotlinked to line numbers to the documentation in this forum. I will try to coincide an online doc update with a new versioned release and a method to link to function names so that the links will retain and use a url based on version name, so that old links won't break or point to wrong docs.

Warning: the code for polar/spherical conversions are untested.

Share this post


Link to post
Share on other sites
SetFromPolarCoordinates() works correctly

I get this error and that is after a rebuild of the libs.... of the files you posted for the float headers and .cpp file

1>Test2.obj : error LNK2019: unresolved external symbol "public: static class math::float2 __cdecl math::float2::FromPolarCoordinates(float,float)" (?FromPolarCoordinates@float2@math@@SA?AV12@MM@Z) referenced in function _wmain
1>F:\Programming\Work\Test2\Debug\Test2.exe : fatal error LNK1120: 1 unresolved externals


BTW you may want to add this also

Cartesian To Cylindrical and back also...


Thanks!!! Edited by MARS_999

Share this post


Link to post
Share on other sites
1>f:\programming\mathgeolib\src\geometry\kdtree.h(8): fatal error C1083: Cannot open include file: 'Container/MaxHeap.h': No such file or directory

I get that error when I try to use

#include <MathGeoLib.h>
or

#include <Geometry/GeometryAll.h>
#include <Math/MathAll.h>

headers....

Share this post


Link to post
Share on other sites
Pushed a fix to that. You can skip over similar missing items by just commenting the offending lines out.

Share this post


Link to post
Share on other sites
Hey there,

I found that there might be an issue in file "OBB.cpp",

Regarding Method "OBB::Intersects(const OBB &b, float epsilon)", please see below cod:


float3 min_A(0,0,0);
float3 max_A(1,1,1);
float3 min_B(0,0,0);
float3 max_B(2,2,2);
AABB a(min_A, max_A);
AABB b(min_B, max_B);
OBB oa(a);
OBB ob(b);
float4x4 transMatrix(0.00000000000000, 0.00000000000000, 1.00000000000000, 0.00000000000000,
-0.50000000000000, 0.86602540378444, 0.00000000000000, 0.00000000000000,
-0.86602540378444, -0.50000000000000, 0.00000000000000, 0.00000000000000,
0.00000000000000, 0.00000000000000, 0.00000000000000, 1.00000000000000);
ob.Transform(transMatrix);
bool res = oa.Intersects(ob, 1e-7f);



On principle, these 2 OBB should be overlap on (0,0,0), but it returned a "false", not sure if it is an issue.

btw, is there a mistake in the line 823 of file "OBB.cpp"
if (Abs(t.x + R[0] + t.y * R[1] + t.z * R[2]) > ra + rb)
should it be
if (Abs(t.x * R[0] + t.y * R[1] + t.z * R[2]) > ra + rb) ?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!