Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MathC - a pure C math library for 2D and 3D programming

70 views
Skip to first unread message

Felipe Ferreira

unread,
Oct 11, 2017, 7:34:24 PM10/11/17
to
Hello, y'all (first time posting here)!

As I was making my C game engine, I decided to decouple my math sources into its own library.

It's licensed under ZLIB.

Github link: https://github.com/ferreiradaselva/mathc

:)

Ben Bacarisse

unread,
Oct 11, 2017, 9:08:53 PM10/11/17
to
Felipe Ferreira <felip...@gmail.com> writes:

> Hello, y'all (first time posting here)!

Welcome.

> As I was making my C game engine, I decided to decouple my math
> sources into its own library.
>
> It's licensed under ZLIB.
>
> Github link: https://github.com/ferreiradaselva/mathc

Can you say why someone might be interested in this library? What does
it include? What are its most interesting features? These question may
be answered at that link, but people prefer to discuss what's posted
here. (It helps with quoting and attribution.)

--
Ben.

Felipe Ferreira

unread,
Oct 11, 2017, 10:43:50 PM10/11/17
to
On Wednesday, October 11, 2017 at 10:08:53 PM UTC-3, Ben Bacarisse wrote:
> Welcome.

Thanks :)

On Wednesday, October 11, 2017 at 10:08:53 PM UTC-3, Ben Bacarisse wrote:
> Can you say why someone might be interested in this library? What does
> it include? What are its most interesting features? These question may
> be answered at that link, but people prefer to discuss what's posted
> here. (It helps with quoting and attribution.)

It's mainly for development with OpenGL.

It has support for math with 2D, 3D vectors, quaternions, matrices and has the easing functions described in this site (http://easings.net), useful for smooth animations.

I tried to keep as clean as possible. For projects that need performance, you can use the functions that take the structures as pointer, instead of as value.

Rick C. Hodgin

unread,
Oct 11, 2017, 10:51:59 PM10/11/17
to
Did you follow the link Felipe provided, Ben? It contains this
information about his project, plus much more detail:

MathC is a simple math library for 2D and 3D programming. It
contains implementations for:

2D vectors
3D vectors
Quaternions
Matrices
Easing functions

It support C99 standard or later.

--
Thank you,
Rick C. Hodgin

Joe Pfeiffer

unread,
Oct 11, 2017, 11:01:35 PM10/11/17
to
"Rick C. Hodgin" <rick.c...@gmail.com> writes:

> On Wednesday, October 11, 2017 at 9:08:53 PM UTC-4, Ben Bacarisse wrote:
>> Felipe Ferreira <felip...@gmail.com> writes:
>>
>> > Hello, y'all (first time posting here)!
>>
>> Welcome.
>>
>> > As I was making my C game engine, I decided to decouple my math
>> > sources into its own library.
>> >
>> > It's licensed under ZLIB.
>> >
>> > Github link: https://github.com/ferreiradaselva/mathc
>>
>> Can you say why someone might be interested in this library? What does
>> it include? What are its most interesting features? These question may
>> be answered at that link, but people prefer to discuss what's posted
>> here. (It helps with quoting and attribution.)
>
> Did you follow the link Felipe provided, Ben? It contains this
> information about his project, plus much more detail:

<snip>

I think Ben's point (which I agree with) is that it would have beeen
nice to have been provided with some reason to follow the link.

Rick C. Hodgin

unread,
Oct 11, 2017, 11:26:57 PM10/11/17
to
On Wednesday, October 11, 2017 at 11:01:35 PM UTC-4, Joe Pfeiffer wrote:
> >> Felipe Ferreira <felip...@gmail.com> writes:
> >> > Hello, y'all (first time posting here)!
> >> >
> >> > As I was making my C game engine, I decided to decouple my math
> >> > sources into its own library.
> >> >
> >> > It's licensed under ZLIB.
> >> >
> >> > Github link: https://github.com/ferreiradaselva/mathc
>
> I think Ben's point (which I agree with) is that it would have beeen
> nice to have been provided with some reason to follow the link.

I saw some reasons to follow the link. It's based on what he gave
us in the first post:

(1) The thread topic. He wrote, "MathC - a pure C math library
for 2D and 3D programming."

A-ha! A math library! For gaming!

(2) The description. He wrote, "As I was making my C game engine,
I decided to decouple my math sources into its own library."

I was then able to conclude: "This must be a fairly robust math
library for 2D / 3D gaming." It made me curious to see what was there.
I was able to follow the link and satiate my curiosity. It wasn't even
that hard to do to find out for certain. I mean, I just clicked the
link and ... all of my remaining questions were answered.

-----
I'm not sure what else to say there. I guess we just have different
applications of what "some reason to follow the link" actually means.

If knowing it's (1) a pure C math library, (2) designed to support a
2D/3D gaming engine, (3) decoupled into its own thing, isn't enough...
what would it have taken? Maybe up to (5) or (6) ???

Ben Bacarisse

unread,
Oct 12, 2017, 6:41:00 AM10/12/17
to
That's much more helpful, thanks. You might get more people to try it
out (that's presumably the reason for posting) in a graphics group. I
don't read any myself so I can't give details but I think there are a
couple that are not overrun with nonsense posts.

If you want people to comment on the code, that's another matter. This
can be a scary place for code reviews so buckle up if that's why you
were posting!!

--
Ben.

bartc

unread,
Oct 12, 2017, 7:01:42 AM10/12/17
to
I've glanced at the code and it looks remarkably clean and simple (and
you know I can be fussy). It's also just one .c file and one .h file.

--
bartc

Rick C. Hodgin

unread,
Oct 12, 2017, 8:09:57 AM10/12/17
to
On Thursday, October 12, 2017 at 7:01:42 AM UTC-4, Bart wrote:
> I've glanced at the code and it looks remarkably clean and simple (and
> you know I can be fussy). It's also just one .c file and one .h file.

I had the same thought. I might use some shorter names for common use
tokens, but apart from that, at first glance, it looked very nice. I
was impressed with such a nice offering to people.

fir

unread,
Oct 12, 2017, 9:04:15 AM10/12/17
to
seems ok, esp if you are sure no bugs there - as removing bugs is much more toresome in writing such pieces, and you wouldnt want to fight bugs in this later

besides probably writing engine you will not needed
a lot of this and you will needed other things (mainly geometrical intersections comes to my mind)
that you not got here

Rick C. Hodgin

unread,
Oct 12, 2017, 9:09:33 AM10/12/17
to
EPIC Games has made their Unreal Tournament game engine freely
available for development:

https://www.unrealengine.com/en-US/what-is-unreal-engine-4

Here's an example of a project being worked on in it:

https://www.youtube.com/watch?v=hRi4Uwp2FVg

Warning: At one point they included some audio of Data using
profanity on one of the controls in the turbolift.
I asked them on their Facebook page if they had any
plans to remove it, and they said possibly, but nothing
specific. I stopped following the project at that
point, but the project remains an amazing work in that
UT game engine.

Felipe Ferreira

unread,
Oct 12, 2017, 10:03:04 AM10/12/17
to
Thanks, everyone! The feedback is welcome.

Ben Bacarisse:
> You might get more people to try it out (that's presumably the reason for posting) in a graphics group.

I found comp.graphics.algorithms, I will post there, later.

Ben Bacarisse:
> If you want people to comment on the code, that's another matter. This can be a scary place for code reviews so buckle up if that's why you were posting!!

Code review would be cool, actually :D

Bart:
> I've glanced at the code and it looks remarkably clean and simple (and you know I can be fussy). It's also just one .c file and one .h file

Thanks. I tried to

Rick C. Hodgin:
> I had the same thought. I might use some shorter names for common use tokens, but apart from that, at first glance, it looked very nice.

Yeah, the vector/quaternion/matrix functions could use names vec/quat/mat, for example. I didn't thought of that when I started, and I kept it going to not break a bunch of code depending on it.

Rick C. Hodgin:
> I was impressed with such a nice offering to people.

There's a lack of that kind of API for pure C. There's the "linmath.h" library, but missing a lot of features (also very noisy with all that use of macros for my taste). I had to gather references from many different places, since I'm not really a math guy.

fir:
> a lot of this and you will needed other things (mainly geometrical intersections comes to my mind)

I will probably work on that later. Triangle intersection can be useful. I'm not sure yet if it would be part of the same library.

Felipe Ferreira

unread,
Oct 12, 2017, 10:07:34 AM10/12/17
to
One of the replies was cut off

Bart:
> I've glanced at the code and it looks remarkably clean and simple (and you know I can be fussy). It's also just one .c file and one .h file

Thanks. I tried to keep as simple as possible, but offer some flexibility for pointers, since some people really need that performance.

Rick C. Hodgin

unread,
Oct 12, 2017, 10:10:02 AM10/12/17
to
On Thursday, October 12, 2017 at 10:03:04 AM UTC-4, Felipe Ferreira wrote:
> Rick C. Hodgin:
> > I had the same thought. I might use some shorter names for common use tokens, but apart from that, at first glance, it looked very nice.
>
> Yeah, the vector/quaternion/matrix functions could use names vec/quat/mat, for example. I didn't thought of that when I started, and I kept it going to not break a bunch of code depending on it.

If you have access to Windows and Visual Studio, there is a tool
called Visual Assist X which is an add-on for Visual Studio (all
versions). They have a feature (alt+shift+r or ctrl+shift+r, I
can't remember) which is refactor.

If you position your flashing caret on a structure name, then you
can press that key combination and it will bring up a dialogue
showing you all places it's used in code, and you can replace them
all by typing in a new name.

It will refactor everywhere. You can use it on most everything,
including function names, global or local variables, etc. You can
see an example of it used here:

http://www.visual-freepro.org/videos/2014_02_13__demonstrate_x86_debugger.ogv

If you can't view the video, use VLC (http://www.videolan.org).

> Rick C. Hodgin:
> > I was impressed with such a nice offering to people.
>
> There's a lack of that kind of API for pure C. There's the "linmath.h" library, but missing a lot of features (also very noisy with all that use of macros for my taste). I had to gather references from many different places, since I'm not really a math guy.

It's excellent work and will benefit many people. You are to be
commended for such a thing. Very nicely done, Felipe.

Rick C. Hodgin

unread,
Oct 12, 2017, 10:13:13 AM10/12/17
to
On Thursday, October 12, 2017 at 10:10:02 AM UTC-4, Rick C. Hodgin wrote:
> On Thursday, October 12, 2017 at 10:03:04 AM UTC-4, Felipe Ferreira wrote:
> > Rick C. Hodgin:
> > > I had the same thought. I might use some shorter names for common use tokens, but apart from that, at first glance, it looked very nice.
> >
> > Yeah, the vector/quaternion/matrix functions could use names vec/quat/mat, for example. I didn't thought of that when I started, and I kept it going to not break a bunch of code depending on it.
>
> If you have access to Windows and Visual Studio, there is a tool
> called Visual Assist X which is an add-on for Visual Studio (all
> versions). They have a feature (alt+shift+r or ctrl+shift+r, I
> can't remember) which is refactor.
>
> If you position your flashing caret on a structure name, then you
> can press that key combination and it will bring up a dialogue
> showing you all places it's used in code, and you can replace them
> all by typing in a new name.
>
> It will refactor everywhere. You can use it on most everything,
> including function names, global or local variables, etc. You can
> see an example of it used here:
>
> http://www.visual-freepro.org/videos/2014_02_13__demonstrate_x86_debugger.ogv

It's at 8:30 in the video. That feature uses Visual Assist X, which
you can see is installed on the menu bar. All versions of Visual
Studio operate pretty much the same way with Visual Assist X. A
few differences here and there based on what has to be exposed in
their own code, versus what already exists in VS's add-on API.
0 new messages