Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples or docs #15

Open
eriksvedang opened this issue Dec 24, 2014 · 5 comments
Open

Examples or docs #15

eriksvedang opened this issue Dec 24, 2014 · 5 comments

Comments

@eriksvedang
Copy link

Hi, thanks for the library! I have searched for some example code using the library (or docs). Does anyone know of anything?

Thanks,
Erik

@datenwolf
Copy link
Owner

Well, linmath.h was a header I added to whenever I needed, I copied it around a lot and unfortunately I have a number of variants on my system, which I really have to merge into a single version eventually. When it comes to documentation, well, this was the least priority for the thing. When releasing this I hoped the function prototypes themself would be self explanatory. The essential idea is that for non-scalar types the first parameter points to where the result goes and the other parameters are the operands. Scalar results are delivered through the function return value.

@eriksvedang
Copy link
Author

OK, that makes sense, thanks for the answer! Perhaps you can tell me if this is a good way of using the functions or if there is a better method?

    mat4x4 M;
    mat4x4_identity(M);

    mat4x4 M2;
    mat4x4_identity(M2);

    mat4x4_rotate(M2, M, 0.0f, 0.0f, 1.0f, angle);

@papa-agoo
Copy link

@eriksvedang: this is perfectly valid, since you are passing arrays to the functions. an array is in fact just a pointer to the first element of that array.

int a[3] = { 1, 3, 9 }; // a[2] == *(a+2)

as you can see, a is just a pointer to the first element of an array of 3 ints.

@eriksvedang
Copy link
Author

Mhm, I was just worried that I'm creating an unnecessary amount of matrices (M and M2), perhaps it could be done with just a single one?

@papa-agoo
Copy link

Just think of M as a non identity Matrix. Your own example is just a bit misleading. :)

mat4x4_rotate() expects an input matrix (M) which may contain other transform operations. On the other hand you keep your matrices separated which can be used individually later on.

// good
mat4x4 model, view, projection;
... 

// bad
mat4x4 mvp;
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants