ferreiradaselva
Pengo 6 posts
Biologist (genomics); C programmer; Game development and art as hobbies. 
#13545
MATHC  Pure C math library for 2D and 3D programming 5 months, 1 week ago Edited by Pengo on Nov. 19, 2017, 9:57 a.m.
As I was working on my own game framework, I decided to decouple the math source on its own library:
GitHub link Documentation: https://github.com/ferreiradaselva/mathc/blob/master/REFERENCE.md This is mainly for OpenGL. Features
Planned Features Currently the library reached the first major release, but I'm adding features that don't break compatibility, and suggestions for features that break compatibility are welcome, saved for the next major release (2.0.0). The next feature I'm planning is detection for 2D and 3D primitives (circles, lines and triangles, both 2D and 3D). Pointers vs. Values There are two versions of the same function, one that take pointer arguments and other that take value arguments:
Other examples in the GitHub page. Taking pointers is certainly faster, but you can use the function that take values if performance is not critical for you, as they are more readable. Single Vector Structure There's only one vector structure, used for 2D vectors, 3D vectors and quaternions. When I had to use 2D vectors, sometimes I would want to use them as 3D vectors and viceversa. So I decided to use the same structure to make this possible. Easing Functions The easing functions are great for animations: it makes easier to make smooth and organic motions. Why another math library? This is not intended to be a competitor with other math libraries, but a small and simple alternative. CGDFW  C Game Development Framework  MATHC  Math library for 2D and 3D programming 
ratchetfreak
351 posts

#13547
MATHC  Pure C math library for 2D and 3D programming 5 months, 1 week ago
A few comments about the quaternion part:
The null quaternion is 0,0,0,1 instead of all 0. There is no construction function for that. The way to get the shortest rotation between 2 vectors can be faster if you skip the acos into sincos by doing:
Your quat to matrix codes expects normalized quaternions, if you replace the 1.0f with the length squared or divide the xx, yy, zz, etd. with that you can fix that. 
ferreiradaselva
Pengo 6 posts
Biologist (genomics); C programmer; Game development and art as hobbies. 
#13548
MATHC  Pure C math library for 2D and 3D programming 5 months, 1 week ago ratchetfreak Thanks for those inputs (and the ones on GitHub)! I will work on the fix for that :) CGDFW  C Game Development Framework  MATHC  Math library for 2D and 3D programming 
ratchetfreak
351 posts

#13549
MATHC  Pure C math library for 2D and 3D programming 5 months, 1 week ago
one more comment, the reason most slerp implementations use 0.95 as the cutoff for switching to normalized lerp. Is because there is a pole of inaccuracy when the input of acos nears 1 and less bits have useful information.
I've derived that using the normalized lerp to 0.5 is the exact same as the slerp to 0.5. So you can binary search into that for up to 5 iterations and then lerp to finish off. The 5 is based on how quickly the 2 boundaries converge from nearly opposite (dot~1) to above the traditional cutoff (dot~0.95). 
mmozeiko
Mārtiņš Možeiko 1638 posts
1 project

#13555
MATHC  Pure C math library for 2D and 3D programming 5 months, 1 week ago
I don't think this is link to what you want: http://reference.md/

raysan5
Ray 37 posts
1 project
I teach videogames programming. 
#13570
MATHC  Pure C math library for 2D and 3D programming 5 months ago 
ferreiradaselva
Pengo 6 posts
Biologist (genomics); C programmer; Game development and art as hobbies. 
#13575
MATHC  Pure C math library for 2D and 3D programming 5 months ago ratchetfreak And I thought that was something arbitrary! :P Thanks for the info, I fixed that. mmozeiko Fixed. raysan5 Thanks! I will make some comparisons, indeed 😄 raysan5 We both used the same reference 😄 I'm really thinking about expanding that list of easing functions. I currently use some of the functions in a game I'm making and they are great to add some juicyness to the game! CGDFW  C Game Development Framework  MATHC  Math library for 2D and 3D programming 
ferreiradaselva
Pengo 6 posts
Biologist (genomics); C programmer; Game development and art as hobbies. 
#13576
MATHC  Pure C math library for 2D and 3D programming 5 months ago
UPDATE
Added some functions to test if a pointer is inside or outside a circle or triangle:
I will soon add some functions to test circlecircle, circletriangle, triangletriangle intersection both 2D and 3D (sphere in the case of 3D). That's how far I will go with intersections, because I want to provide only test with primitives. CGDFW  C Game Development Framework  MATHC  Math library for 2D and 3D programming 