ferreiradaselva
Pengo 11 posts
Biologist (genomics); C programmer; Game development and art as hobbies. 
#13545
MATHC  Pure C math library for 2D and 3D programming 7 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. 
ratchetfreak
366 posts

#13547
MATHC  Pure C math library for 2D and 3D programming 7 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 11 posts
Biologist (genomics); C programmer; Game development and art as hobbies. 
#13548
MATHC  Pure C math library for 2D and 3D programming 7 months, 1 week ago ratchetfreak Thanks for those inputs (and the ones on GitHub)! I will work on the fix for that :) 
ratchetfreak
366 posts

#13549
MATHC  Pure C math library for 2D and 3D programming 7 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 1693 posts
1 project

#13555
MATHC  Pure C math library for 2D and 3D programming 7 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 7 months ago 
ferreiradaselva
Pengo 11 posts
Biologist (genomics); C programmer; Game development and art as hobbies. 
#13575
MATHC  Pure C math library for 2D and 3D programming 7 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! 
ferreiradaselva
Pengo 11 posts
Biologist (genomics); C programmer; Game development and art as hobbies. 
#13576
MATHC  Pure C math library for 2D and 3D programming 7 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. 
ferreiradaselva
Pengo 11 posts
Biologist (genomics); C programmer; Game development and art as hobbies. 
#15378
MATHC  Pure C math library for 2D and 3D programming 1 month ago Edited by Pengo on May 24, 2018, 5:41 a.m.
I'm working on the second version of my library, if anyone is in need of a math library.
Github branch: https://github.com/ferreiradaselva/mathc/tree/mathc2 The updates are:
I covered almost all feedback that I got around, except for fixedpoint arithmetic. I probably will never add to the library, since it would escalate the maintenance requirements drastically. 