{"id":20128528,"url":"https://github.com/cococry/cml","last_synced_at":"2025-04-09T15:50:43.329Z","repository":{"id":53927490,"uuid":"499529841","full_name":"cococry/cml","owner":"cococry","description":"C Linear Algebra Library","archived":false,"fork":false,"pushed_at":"2022-11-05T10:39:58.000Z","size":262,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-23T18:05:26.896Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cococry.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-03T13:52:37.000Z","updated_at":"2024-09-19T17:10:05.000Z","dependencies_parsed_at":"2023-01-22T02:49:20.454Z","dependency_job_id":null,"html_url":"https://github.com/cococry/cml","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cococry%2Fcml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cococry%2Fcml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cococry%2Fcml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cococry%2Fcml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cococry","download_url":"https://codeload.github.com/cococry/cml/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248063857,"owners_count":21041854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T20:27:55.410Z","updated_at":"2025-04-09T15:50:43.300Z","avatar_url":"https://github.com/cococry.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CML - C Math Library\n\u003cimage src=\"git-assets/logo.png\" alt=\"logo\" width=515px\u003e\u003c/image\u003e\n\n## Overview\nCML ( C Math Library ) is a linear algebra library for c and developed mainly for graphics development. \nThe main purpose of the creation of CML was to improve on [cglm](https://github.com/recp/cglm) in the way i needed it. \nOf cource cglm is a very good library in a lot of ways and they have my full respect. \nCML is a lightweight, easy to use and to compile library. The library only constists of .c and .h files which makes compilation a lot easier. \nThe library does not build a lib or a dll file and runns on any C compiler (gcc, clang, mingw etc.). \n\n***\n\n## 🛬 Building\n\nTo correctly build the library, just compile all .c files in the repository (folder [cml](https://github.com/cococry/cml/tree/main/cml)). And of course, include\nall the .h files in order to use the library. \n\nThat's it! \n\n## 💥Features\n\n- Full vector support (operations, scalers, cross, dot, normalize etc.)\n- Full matrices support (operations, scalers, identity, transpose, etc.)\n- Radians implementation\n- Matrix transformations (translate, rotate, scale)\n- Camera function (look_at)\n- Projections perspective, ortho ect.)\n- Accessing matrcies by rows and columns\n- Row echelon form \u0026 Reduces row echelon form (matrices)\n\nAs you can see, features like quanternions and euler angles are not featured in this list. This is because the library is still a \nwork in progress and its being improved on.\n\n## Notes\n\nThis library is not a highly optimised bleeding edge library like glm or something. I am developing this library mostly for personal use and did not try to\nreplace any other library on the market. The main reason for the library is, that C does not have a lot of linear algebra libraries with whom i can work\nunhindered.\n\n## Brief documentation\n\n- **Vectors**\n\nIn CML, vectors are defined by a dimension and a array of values. There is no such thing as vec2, vec3, vec4 like in other libraries like glm.\nVectors can have any dimension, in CML. The values of the vector are assigned with variadic arguments in a macro function. The dimension is being\ncalculated internally by another macro \"NUM_OF_ARGS\". \n\n**WARNING**:\nAll values of the vector that is being intialized have to be float values. Internally, the macro function does only accept float values. This\nhas to be statet explicitly (4 is not valid, 4.0f is valid).\n\n```C\n vector v = cml_vector(4.0f, -2.0f, 1.0f);\n cml_vec_mult_with_vec(\u0026v, cml_vector(2.0f, 10.0f, 10.0f);\n \n cml_vector_print(v);\n```\n\nFunctions return vectors that can be assigned:\n\n```C\n  vector v1 = cml_vector(2.0f, 3.0f, 4.0f);\n  \n  vector v2 = cml_vector_normalized(cml_vector_scaler_addition(v1, 4.0f));\n  \n  v2 = cml_cross(v1, cml_vector(10.0f, 20.0f, 30.0f);\n```\n\nOther functions access and modify the vector itself:\n\n```C\n  vector v1 = cml_vector(2.0f, 3.0f, 4.0f);\n  cml_vector_print(v1);\n  \n  cml_vector_normalize(\u0026v1);\n  cml_vector_print(v1);\n```\n\n- **Matrices**\n\nMatrices are defined by a number of columns, a number of rows and their values. Again, their is no such thing like mat3 or mat4, instead the dimension\n(rows and columns) are specified at creation.\n\nAssigning the values of the matrix yourself:\n\n```C\n  matrix m = cml_matrix(2, 2, \n                        5.0f, 10.0f,\n                        7.0f, 3.0f);\n                        \n  cml_matrix_print(m);\n```\n\nOr the common way, letting the library create the matrices:\n\n```C\n  matrix m = cml_identity(4);\n  \n  matrix m2 = cml_translate(m, cml_vector(2.0f, 3.0f, 5.0f));\n  \n  cml_matrix_print(m);\n```\n\n- **Projections and camera**\n\nDealing with projection, view and model matrix is a very importent task when working with computer graphics. Translation, rotation projection etc. is internally\nand API-wise handled pretty much the same way as its handled by [glm](https://github.com/g-truc/glm).\n\n```C\n  matrix m = cml_mat_mat_mult(\n                          cml_translate(cml_matrix_identity(4), cml_vector(1.0f, 2.0f, 3.0f)), \n                          cml_rotate(cml_matrix_identity(4), cml_radians(45.0f), cml_vector(0.0f, 0.0f, 1.0f)));\n  \n  matrix m2 = cml_scale(cml_matrix_identity(4), cml_vector(0.0f, 2.0f, 0.0f));\n  \n  matrix m2 = cml_perspective(cml_radians(45.0f), 1920.0f / 1080.0f, 0.1f, 1000.0f);\n  \n  matrix m3 = cml_ortho(0.0f, 1920.0f, 0.0f, 1080.0f);\n```\n\n***\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcococry%2Fcml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcococry%2Fcml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcococry%2Fcml/lists"}