felselva / mathc

Pure C math library for 2D and 3D programming
zlib License
703 stars 56 forks source link

Suggestion: rename last two parameters of mat4_perspective in mathc.h to speaking names #40

Open ghost opened 4 years ago

ghost commented 4 years ago

I had to google around and check out libglm usage to see what parameters a perspective transformation commonly takes (and yes I'm familiar with clipping planes and all, I just never used lowlevel OpenGL directly before) to figure out what on earth n or f are. Turns out it's "near clipping" and "far clipping":

mfloat_t *mat4_perspective(mfloat_t *result, mfloat_t fov_y, mfloat_t aspect, mfloat_t n, mfloat_t f)

Therefore, I recommend renaming them to znear and zfar in the header since that will make it way easier both to guess and to google what they are used for. It may seem like a minor nitpick but this can really help a lot when there's otherwise no documentation available.

Edit: proposal updated due to @RandyGaul 's remark

RandyGaul commented 4 years ago

near and far are names taken by Windows.h, so any other names would be slightly simpler to use.

ghost commented 4 years ago

What do you mean with "taken by Windows.h"? If you rename them in the header only they aren't in anyone's scope, so that shouldn't be an issue on a technical level. (You can still keep the old parameter names in the mathc.c actual implementation file.) Or are you saying people would be confused by these names?

Edit: oh fascinating, seems like they're macros which is a problem. Good catch! What about znear and zfar then?