Giter Site home page Giter Site logo

glus's People

Contributors

mcnopper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

glus's Issues

Relicense?

Hi,

I am very impressed with your library, but unfortunately for several uses and distribution channels its viral license makes it unusable. Could you please relicense it to something non-viral, such as Apache-2, BSD, or MIT?

Thanks for your time,
Colin

Precision problem in glusMatrix4x4Inversef

Hello, I have encountered a problem in glusMatrix4x4Inversef. When a matrix value is very low, the results are incorrect. I am not an expert in linear algebra, so please forgive me if this issue is naive.

Code example for reproducing the issue:

void dumpMatrix(float* mat)
{
	printf("%16g %16g %16g %16g\n", mat[ 0], mat[ 1], mat[ 2], mat[ 3]);
	printf("%16g %16g %16g %16g\n", mat[ 4], mat[ 5], mat[ 6], mat[ 7]);
	printf("%16g %16g %16g %16g\n", mat[ 8], mat[ 9], mat[10], mat[11]);
	printf("%16g %16g %16g %16g\n", mat[12], mat[13], mat[14], mat[15]);
}

void testMatrixInversion()
{
	float mat1[16];
	glusMatrix4x4Identityf(mat1);
	mat1[12] = 2.8f;
	mat1[13] = 3.9f;
	printf("**********************************************************************\n");
	printf("matrix 1 before inversion\n");
	dumpMatrix(mat1);
	glusMatrix4x4Inversef(mat1);
	printf("matrix 1 after inversion\n");
	dumpMatrix(mat1);
	printf("**********************************************************************\n");

	float mat2[16];
	glusMatrix4x4Identityf(mat2);
	mat2[12] = 2.8f;
	mat2[13] = 3.9f;
	mat2[1] = -5.55111512e-017;
	printf("**********************************************************************\n");
	printf("matrix 2 before inversion\n");
	dumpMatrix(mat2);
	glusMatrix4x4Inversef(mat2);
	printf("matrix 2 after inversion\n");
	dumpMatrix(mat2);
	printf("**********************************************************************\n");
}

void main()
{
	testMatrixInversion();
}

result of the execution of previous code:

**********************************************************************
matrix 1 before inversion
               1                0                0                0
               0                1                0                0
               0                0                1                0
             2.8              3.9                0                1
matrix 1 after inversion
               1                0                0                0
               0                1                0                0
               0                0                1                0
            -2.8             -3.9                0                1
**********************************************************************
**********************************************************************
matrix 2 before inversion
               1    -5.55112e-017                0                0
               0                1                0                0
               0                0                1                0
             2.8              3.9                0                1
matrix 2 after inversion
               1     5.55112e-017                0                0
               0                1                0                0
               0                0                1                0
               0             -3.9                0                1
**********************************************************************

Note that the -2.8 value is lost in second matrix inversion.

Currently I am avoiding this problem by trimming very low values (abs(value < 1e-9) to zero before inverting, but I don't know if that fix is correct.

Thanks for this great library, it is saving me a lot of work.

Cube shape vertex number does't take into account all 6 faxes

Hi,Maybe I am doing wrong smth but here is the case.
In GLUS glusShapeCreateCubef() numberVertices = 24; .
However if I draw it using

glDrawElements(GL_TRIANGLES, numberVertices, GL_UNSIGNED_INT, 0);

Two last faces are not being drawn.
I tried also drawing with GL_TRIANGLE_STRIP.
In that case the faces are not drawn in correct winding order at all.
Only when I set numberVertices = 36 the cube is being drawn fine.
So is it a bug ,or I am using wrong draw mode?

UPDATE:

Ok,ok,that's as I supposed is my confusion.I should put into second param the number of indicies and not vertices in indexed drawing.Now it is fine.

quaternion missing a few features

nlerp, it is less accurate but is much faster, only needing a single sqrt instead of 4 transcendal trig functions. (FYI you can get the slerp using a half dozen nlerps by binary searching into the range using slerp(q1, q2, 0.5) == nlerp(q1, q2, 0.5))

slerp should fall back to nlerp when cosAlpha > 0.95 to avoid instability. The error between nlerp and slerp will decrease as cosAlpha goes to 1.

Getting a quaternion representing the rotation between 2 vectors can be calculated using the cross and dot product directly instead of having to go through glusQuaternionRotatef.

   //assumes v0 and v1 were normalized
    GLUSfloat cross[3];
    glusVector3Crossf(cross, v0, v1);
    result[0] = cross[0];
    result[1] = cross[1];
    result[2] = cross[2];
    result[3] = dotf(v0, v1)+1; 

    glusQuaternionNormalizef(result);

What is GLUS?

Can you write in README what is GLUS and why I need it?
Thanks

Sphere shape gets a hole in the buttom with numSlices > 22

Hi. I am not sure if that is 100% bug.I used a function from your lib to generate sphere mesh. And I noticed that when I set numSlices more than 22 .A little gap appears at the bottom of the mesh. It looks like that number of parallels is not sufficient to generate triangles at the south pole region. try with radius 50 amd numSlices = 23. Here is how it looks on my side:

spherebug

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.