Swiftpack.co - Package - recp/cglm

πŸŽ₯ OpenGL Mathematics (glm) for C

Build Status Build status Documentation Status Coverage Status codecov Codacy Badge Backers on Open Collective Sponsors on Open Collective

Documentation

Almost all functions (inline versions) and parameters are documented inside the corresponding headers.
Complete documentation: http://cglm.readthedocs.io

Note for previous versions:

  • _dup (duplicate) is changed to _copy. For instance glm_vec_dup -> glm_vec3_copy
  • OpenGL related functions are dropped to make this lib platform/third-party independent
  • make sure you have latest version and feel free to report bugs, troubles
  • [bugfix] euler angles was implemented in reverse order (extrinsic) it was fixed, now they are intrinsic. Make sure that you have the latest version
  • [major change] by starting v0.4.0, quaternions are stored as [x, y, z, w], it was [w, x, y, z] in v0.3.5 and earlier versions
  • [api rename] by starting v0.4.5, glm_simd functions are renamed to glmm_
  • [new option] by starting v0.4.5, you can disable alignment requirement, check options in docs.
  • [major change] by starting v0.5.0, vec3 functions use glm_vec3_ namespace, it was glm_vec_ until v0.5.0
  • [major change] by starting v0.5.1, built-in alignment is removed from vec3 and mat3 types
  • [major change] by starting v0.7.3, inline print functions are disabled in release/production mode to eliminate print costs (see options in documentation). Print output also improved. You can disable colors if you need (see documentation)

Note for C++ developers:

If you are not aware of the original GLM library yet, you may also want to look at: https://github.com/g-truc/glm

Note for new comers (Important):

  • vec4 and mat4 variables must be aligned. (There will be unaligned versions later)
  • in and [in, out] parameters must be initialized (please). But [out] parameters not, initializing out param is also redundant
  • All functions are inline if you don't want to use pre-compiled versions with glmc_ prefix, you can ignore build process. Just include headers.
  • if your debugger takes you to cglm headers then make sure you are not trying to copy vec4 to vec3 or alig issues...
  • Welcome!

Note for experienced developers:

  • Since I'm testing this library in my projects, sometimes bugs occurs; finding that bug[s] and making improvements would be more easy with multiple developer/contributor and their projects or knowledge. Consider to make some tests if you suspect something is wrong and any feedbacks, contributions and bug reports are always welcome.

Allocations?

cglm doesn't alloc any memory on heap. So it doesn't provide any allocator. You should alloc memory for out parameters too if you pass pointer of memory location. Don't forget that vec4 (also quat/versor) and mat4 must be aligned (16-bytes), because cglm uses SIMD instructions to optimize most operations if available.

Returning vector or matrix... ?

cglm supports both ARRAY API and STRUCT API, so you can return structs if you utilize struct api (glms_).

Other APIs like Vulkan, Metal, Dx?

Currently cglm uses default clip space configuration (-1, 1) for camera functions (perspective, extract corners...), in the future other clip space configurations will be supported


Like some other graphics libraries (especially OpenGL) this library use Column-Major layout to keep matrices in the memory.
 
In the future the library may support an option to use row-major layout, CURRENTLY if you need to row-major layout you will need to transpose it.

Features

  • array api and struct api, you can use arrays or structs.
  • general purpose matrix operations (mat4, mat3)
  • chain matrix multiplication (square only)
  • general purpose vector operations (cross, dot, rotate, proj, angle...)
  • affine transformations
  • matrix decomposition (extract rotation, scaling factor)
  • optimized affine transform matrices (mul, rigid-body inverse)
  • camera (lookat)
  • projections (ortho, perspective)
  • quaternions
  • euler angles / yaw-pitch-roll to matrix
  • extract euler angles
  • inline or pre-compiled function call
  • frustum (extract view frustum planes, corners...)
  • bounding box (AABB in Frustum (culling), crop, merge...)
  • bounding sphere
  • project, unproject
  • easing functions
  • curves
  • curve interpolation helpers (SMC, deCasteljau...)
  • helpers to convert cglm types to Apple's simd library to pass cglm types to Metal GL without packing them on both sides
  • ray intersection helpers
  • and others...

You have two option to call a function/operation: inline or library call (link) Almost all functions are marked inline (always_inline) so compiler will probably inline. To call pre-compiled version, just use glmc_ (c stands for 'call') instead of glm_.

  #include <cglm/cglm.h>   /* for inline */
  #include <cglm/call.h>   /* for library call (this also includes cglm.h) */

  mat4 rot, trans, rt;
  /* ... */
  glm_mul(trans, rot, rt);  /* inline */
  glmc_mul(trans, rot, rt); /* call from library */

Most of math functions are optimized manualy with SSE2 if available, if not? Dont worry there are non-sse versions of all operations

You can pass matrices and vectors as array to functions rather than get address.

  mat4 m = {
    1, 0, 0, 0,
    0, 1, 0, 0,
    0, 0, 1, 0,
    0, 0, 0, 1
  };

  glm_translate(m, (vec3){1.0f, 0.0f, 0.0f});

Library contains general purpose mat4 mul and inverse functions, and also contains some special forms (optimized) of these functions for affine transformations' matrices. If you want to multiply two affine transformation matrices you can use glm_mul instead of glm_mat4_mul and glm_inv_tr (ROT + TR) instead glm_mat4_inv

/* multiplication */
mat4 modelMat;
glm_mul(T, R, modelMat);

/* othonormal rot + tr matrix inverse (rigid-body) */
glm_inv_tr(modelMat);

Struct API

The struct API works as follows, note the s suffix on types, the glms_ prefix on functions and the GLMS_ prefix on constants:

#include <cglm/struct.h>

mat4s mat = GLMS_MAT4_IDENTITY_INIT;
mat4s inv = glms_mat4_inv(mat);

Struct functions generally take their parameters as values and return their results, rather than taking pointers and writing to out parameters. That means your parameters can usually be const, if you're into that.

The types used are actually unions that allow access to the same data multiple ways. One of those ways involves anonymous structures, available since C11. MSVC also supports it for earlier C versions out of the box and GCC/Clang do if you enable -fms-extensions. To explicitly enable these anonymous structures, #define CGLM_USE_ANONYMOUS_STRUCT to 1, to disable them, to 0. For backward compatibility, you can also #define CGLM_NO_ANONYMOUS_STRUCT (value is irrelevant) to disable them. If you don't specify explicitly, cglm will do a best guess based on your compiler and the C version you're using.

Build

CMake (All platforms)

$ mkdir build
$ cd build
$ cmake .. # [Optional] -DCGLM_SHARED=ON
$ make
$ sudo make install # [Optional]
Cmake options with Defaults:
option(CGLM_SHARED "Shared build" ON)
option(CGLM_STATIC "Static build" OFF)
option(CGLM_USE_C99 "" OFF) #Β C11 
option(CGLM_USE_TEST "Enable Tests" OFF) #Β for make check - make test

Use with your CMake project

  • Example:
cmake_minimum_required(VERSION 3.8.2)

project(<Your Project Name>)

add_executable(${PROJECT_NAME} src/main.c)
target_link_libraries(${LIBRARY_NAME} PRIVATE
  cglm)

add_subdirectory(external/cglm/)

# or you can use find_package to configure cglm

Meson (All platforms)

$ meson build # [Optional] --default-library=static
$ cd build
$ ninja
$ sudo ninja install # [Optional]
Meson options with Defaults:
c_std=c11
buildtype=release
default_library=shared
enable_tests=false #Β to run tests: ninja test

Use with your Meson project

  • Example:
# Clone cglm or create a cglm.wrap under <source_root>/subprojects
project('name', 'c')

cglm_dep = dependency('cglm', fallback : 'cglm', 'cglm_dep')

executable('exe', 'src/main.c', dependencies : cglm_dep)

Swift (Swift Package Manager)

Currently only default build options are supported. Add cglm dependency to your project:

...
Package( 
  ...
  dependencies: [
    ...
    .package(url: "https://github.com/recp/cglm", .branch("master")),
  ]
  ...
)

Now add cgml as a dependency to your target. Product choices are:

  • cglm for inlined version of the library which can be linked only statically
  • cglmc for a compiled version of the library with no linking limitation
...
.target(
  ...
  dependencies: [
    ...
    .product(name: "cglm", package: "cglm"),
  ]
  ...
)
...

Unix (Autotools)

$ sh autogen.sh
$ ./configure
$ make
$ make check # [Optional]
$ [sudo] make install # [Optional]

This will also install pkg-config files so you can use pkg-config --cflags cglm and pkg-config --libs cglm to retrieve compiler and linker flags.

The files will be installed into the given prefix (usually /usr/local by default on Linux), but your pkg-config may not be configured to actually check there. You can figure out where it's looking by running pkg-config --variable pc_path pkg-config and change the path the files are installed to via ./configure --with-pkgconfigdir=/your/path. Alternatively, you can add the prefix path to your PKG_CONFIG_PATH environment variable.

Windows (MSBuild)

Windows related build file and project files are located in win folder, make sure you are inside cglm/win folder. Code Analysis is enabled, so it may take awhile to build.

$ cd win
$ .\build.bat

if msbuild won't work (because of multi version VS) then try to build with devenv:

$ devenv cglm.sln /Build Release

Running Tests on Windows

You can see test project in same visual studio solution file. It is enough to run that project to run tests.

Building Docs

First you need install Sphinx: http://www.sphinx-doc.org/en/master/usage/installation.html then:

$ cd docs
$ sphinx-build source build

it will compile docs into build folder, you can run index.html inside that function.

How to use

If you want to use the inline versions of functions, then include the main header

#include <cglm/cglm.h>

the header will include all headers. Then call the func you want e.g. rotate vector by axis:

glm_vec3_rotate(v1, glm_rad(45), (vec3){1.0f, 0.0f, 0.0f});

some functions are overloaded :) e.g you can normalize vector:

glm_vec3_normalize(vec);

this will normalize vec and store normalized vector into vec but if you will store normalized vector into another vector do this:

glm_vec3_normalize_to(vec, result);

like this function you may see _to postfix, this functions store results to another variables and save temp memory

to call pre-compiled versions include header with c postfix, c means call. Pre-compiled versions are just wrappers.

#include <cglm/call.h>

this header will include all headers with c postfix. You need to call functions with c posfix:

glmc_vec3_normalize(vec);

Function usage and parameters are documented inside related headers. You may see same parameter passed twice in some examples like this:

glm_mat4_mul(m1, m2, m1);

/* or */
glm_mat4_mul(m1, m1, m1);

the first two parameter are [in] and the last one is [out] parameter. After multiplying m1 and m2, the result is stored in m1. This is why we send m1 twice. You may store the result in a different matrix, this is just an example.

Example: Computing MVP matrix

Option 1

mat4 proj, view, model, mvp;

/* init proj, view and model ... */

glm_mat4_mul(proj, view, viewProj);
glm_mat4_mul(viewProj, model, mvp);

Option 2

mat4 proj, view, model, mvp;

/* init proj, view and model ... */

glm_mat4_mulN((mat4 *[]){&proj, &view, &model}, 3, mvp);

How to send matrix to OpenGL

mat4 is array of vec4 and vec4 is array of floats. glUniformMatrix4fv functions accecpts float* as value (last param), so you can cast mat4 to float* or you can pass first column of matrix as beginning of memory of matrix:

Option 1: Send first column

glUniformMatrix4fv(location, 1, GL_FALSE, matrix[0]);

/* array of matrices */
glUniformMatrix4fv(location, 1, GL_FALSE, matrix[0][0]);

Option 2: Cast matrix to pointer type (also valid for multiple dimensional arrays)

glUniformMatrix4fv(location, 1, GL_FALSE, (float *)matrix);

You can pass matrices the same way to other APIs e.g. Vulkan, DX...

Notes

  • This library uses float types only, does not support Integers, Double... yet
  • If headers are not working properly with your compiler, IDE please open an issue, because I'm using GCC and clang to test it maybe sometimes MSVC

TODO:

  • ☐ Unit tests (In Progress)
  • ☐ Unit tests for comparing cglm with glm results
  • β˜‘ Add version info
  • ☐ Unaligned operations (e.g. glm_umat4_mul)
  • β˜‘ Extra documentation
  • ☐ ARM Neon Arch (In Progress)

Contributors

This project exists thanks to all the people who contribute. [Contribute].

Backers

Thank you to all our backers! πŸ™ [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

License

MIT. check the LICENSE file

Github

link
Stars: 740

Dependencies

Used By

Total: 0

Releases

v0.7.8: Meson Build + Bugfixes - 2020-08-09 14:35:04

New Features:

  • build: meson build support ( thanks to @randy408 ) https://github.com/recp/cglm/pull/154

Bugfixes and Improvements:

  • win32: fix symbol exports, drop CGLM_DLL, add CGLM_STATIC... ( thanks to @randy408 )
    • CGLM_EXPORTS - building a shared library (dllexport)
    • CGLM_STATIC - required for cglm\call headers with statically built library (no attributes)
    • No defines - assume dynamic (dllimport)
  • win32, test: don't link 'm' with msvc ( thanks to @randy408 )
  • gcc: fix some warnings ( thanks to @randy408 )
  • io: make options changeable by user, define colors as empty macro to remove colors from prints
  • io: add documentation to io.h header
  • io: deprecate CGLM_NO_PRINTS_NOOP
  • documentation improvements and fixes

v0.7.7: 2D Affine Transforms Update - 2020-07-31 17:22:16

New Features:

2D Affine Transforms

Now we have 2D Affine Transform functions. 2D Transform functions are suffixed with 2d, functions that don't have any suffixes are 3D. For instance glm_translate2d() is 2D and glm_translate() is 3D.

New Functions:

Translate2D:

  • glm_translate2d()
  • glm_translate2d_to()
  • glm_translate2d_x()
  • glm_translate2d_y()
  • glm_translate2d_make()

Scale2D:

  • glm_scale2d_to()
  • glm_scale2d_make()
  • glm_scale2d()
  • glm_scale2d_uni()

Rotate2D:

  • glm_rotate2d_make()
  • glm_rotate2d()
  • glm_rotate2d_to()

All these functions are documented at https://cglm.readthedocs.io/en/latest/affine2d.html . Rotate functions are rotating around Z axes. SIMD optimizations will be applied in the future releases.

Bugfixes and Improvements:

  • mat3_mulv: function behaviour to match with mat4 ( thanks to @Terri00 )
  • mat2: don't use vec4 directly on mat2 because of alignment requirements may be different
  • define CGLM_DEFINE_PRINTS macro for test targets to see printed results
  • documentation fixes

Build:

  • build: update CFLAGS (-O3 -std=gnu11) for check/test target to match the main target
  • build: remove RTC1 from CMake build for Windows/MSVC

v0.7.6: Critical bugfix for ARM/NEON and Improvements - 2020-06-12 20:42:09

Critical Bugfix:

  • neon: fix vec4_muladds (critical): https://github.com/recp/cglm/commit/f49e8f99914e9739fef1daf47f58748cb749877d

Bugfixes and Improvements:

Core
  • Use epsilon to compare vec2/vec3/vec4_eq_all
  • mat2: suppress warnings for initializing mat2 sruct
Build
  • Build: Improve CMake build integration
  • Build: Update CMake to export Config to use find_package()
  • Build: Drop pedantic from C Flags and allow extensions
Tests
  • tests: add option to disable colors in test output
  • tests: add test for frustum

New Features:

  • Option to override FLT_EPSILON with GLM_FLT_EPSILON

v0.7.4: Critical [Build] Bugfix for ARM/NEON - 2020-05-16 18:17:06

Critical Bugfix:

  • fix arm neon build; to negating vectors, NEON gives single intrinsic: https://github.com/recp/cglm/commit/269bdb3dbd07001b4345d8b9c88f235b27d4804a

Improvements:

  • io: in release mode, make print functions macro to suppress unused parameter warnings
  • build, cmake: use PROJECT_VERSION_** to set so version instead of custom variables

v0.7.3: Print Functions Update - 2020-04-30 22:24:05

Bugfixes and Improvements:

  • suppress documentation warnings
  • remove redundant typedef
  • fix print functions to align column correctly

New Features:

Print Functions Improvements

  • While printing, mis-alignment of columns are fixed: larger numbers are printed via %g and others are printed via %f Column withs are calculated before print.

  • Now values are colorful ;)

    Screen Shot 2020-05-01 at 1 17 48 AM
  • New options with default values:

    #define CGLM_PRINT_PRECISION    5
    #define CGLM_PRINT_MAX_TO_SHORT 1e5
    #define CGLM_PRINT_COLOR        "\033[36m"
    #define CGLM_PRINT_COLOR_RESET  "\033[0m"
  • Inline prints are only enabled in DEBUG mode and if CGLM_DEFINE_PRINTS is defined.
  • You can still call library-print functions e.g. glmc_print...

To make codes unbroken, cglm makes inline print functions to be empty-body (if DEBUG and CGLM_DEFINE_PRINTS are not defined):

CGLM_INLINE void glm_mat4_print(mat4 matrix, FILE *o) { }

compiler must eliminate this empty inline function calls. This also can be disabled by defining CGLM_NO_PRINTS_NOOP macro. πŸŽ‰

Define CGLM_PRINT_PRECISION to change print precision, default is increased to 5 from 4 ...

v0.7.2: CMake Integration and Ray Intersection Update - 2020-04-27 19:44:44

Bugfixes and Improvements:

  • fix glms_sphere_transform by using mat4s instead of mat4 (#121) ( thanks to @Zollerboy1 )
  • fix glms_vec2_rotate() by using a dest vec2s instead of taking an axis ( thanks to @Zollerboy1 )
  • fix some documentation mistakes ( thanks to @Uwila )
  • remove redundant forward decelerations
  • use glm_clamp_zo in some places to clamp between 0 and 1
  • make Github recognize header language as C (#127) ( thanks to @Uwila )
  • [README] link contributors' avatars to the correct page ( thanks to @Uwila )
  • and some forgotten big or small fixes maybe :) ( thanks to all )

New Features:

  • ray-triangle intersection ( many thanks to @Uwila )

  • CMake build support ( many thanks to @FMMazur and @realaltffour ) Now we can build cglm with CMake and can integrate with other CMake projects.

    CMake options:

  option(CGLM_SHARED "Shared build" ON)
  option(CGLM_STATIC "Static build" OFF)
  option(CGLM_USE_C99 "" OFF) # C11 
  option(CGLM_USE_TEST "Enable Tests" OFF) # for make check - make test

there may be some bugs in CMake configurations, it will be improved by time.

feel free to suggest new features, improvements and fix things by creating issues or pull requests.

v0.7.1: Critical Build Bugfix - 2020-03-02 07:12:24

  • build: add missing headers
  • helper to swap two float values

v0.7.0: vec2 and mat2 update - 2020-02-25 19:26:03

New Features:

  • Now vec2 and mat2 are officially supported (including struct api) πŸŽ‰ ( https://github.com/recp/cglm/pull/97 )
  • add forward vector as macro (vec3, RH)

Bugfixes and Improvements:

  • quat: fix quat_for and quat_forp implementations; These are identical to QuaternionLook / LookRotation in other frameworks/engines...
  • add notes for versor/quaternion type to describe memory layout
  • merge test sources into one C source
  • make plane zero if norm is zero after normalization
  • Add more tests

Since vec2 and mat2 are new features, bugs may occurs. Any feedback or help would be appreciated.

v0.6.2: Bug-fixes for Windows MSC compiler - 2020-01-17 21:07:35

  • Now tests can be run on Windows too. Just run cglm-test project.
  • Anonymous structs are enabled for MSC >=1900 (Visual Studio 2015+)
  • win: fix glms_quat_imagn if use_struct option is disabled

v0.6.1: Custom/Built-in Test Suite and Improvements - 2020-01-17 14:17:16

New Features:

  • Custom Built-in Unit Test Suite: Now we have custom test suite which don't require external dependencies. It is very cool and simple to implement
  • Helpers for apple's simd library (#107)
  • mat4: add zero for call

Bugfixes and Improvements:

  • Add more tests
  • Remove build-deps.sh
  • Remove cmocka from submodules and update docs
  • quat: fix glmc_quat_normalize()
  • vec: fix min/max for compiled vec3
  • arm: fix type castings for ARM Neon
  • vec4: fix parameter name for NEON
  • build: remove duplicate entry in makefile
  • Change empty prototypes to (void) ( @hartenfels )
  • Add a vec2s struct type for consistency ( @hartenfels )
  • Don't add default autoconf flags to build ( @hartenfels )
  • [major change] Use gnu11 instead of gnu99 ( @hartenfels )
  • and some other bugfixes and improvements made by @hartenfels
  • Fix spelling error in name of glms_rotate_x ( @jdolan )

Now cglm don't require external dependencies and it has very cool test suite πŸŽ‰

v0.6.0: Struct API and New Features - 2019-09-01 12:11:25

New API: Structs ( thanks to @acoto87 ) (https://github.com/recp/cglm/pull/80)

cglm now supports structs. To use struct api, just include cglm/struct.h header. You can also use struct api with array api. Struct api provides type-safety. Currently struct parameters are pass-by-value but in the future it may be pass-by-reference by using pointers (feedbacks are welcome by creating issues).

New Features and Improvements:

  • swizzling api: now cglm supports swizzling
  • Find post-build.sh even when not building in. ( @hartenfels )
  • quat: fix glm_quat_axis axis parameter type
  • win: remove optional DLLMain entry point
  • new name for euler sequence (#94) ( @superbigio )
  • squared distance with SIMD support (#96) ( @superbigio )
  • glm_lerpc(), glm_step(), glm_smoothstep(), glm_smoothinterp() (#98) ( @superbigio )
  • added glm_vec_fill() (#100) ( @superbigio )
  • swapped argument order in glmm_store3() (#102) ( @superbigio )
  • vec: some useful functions (#103) ( @superbigio )
  • quat: fix identity quat in glm_quat_normalize_to (#88) ( @yushli )
  • and some minor changes...

New glmm (SIMD) functions: (thanks to @superbigio )

  • glmm_norm2(v) squared l2 norm
  • glmm_vhmin(v) horizontal min
  • glmm_vhmax(v) horizontal max
  • glmm_norm_one(v) l1 norm
  • glmm_norm_inf(v) infinity norm

v0.5.4: Bug fixes and Improvements - 2019-04-30 11:00:36

Bug fixes and Improvements:

  • improve vec3 alignment ( @haxpor )
  • Add missing header for size_t ( @acoto87 )
  • move common headers to common.h
  • Fix glm_vec4_distance for armv7 and improve for SSE2 ( @haxpor )
  • ci: print test logs after failure
  • fix glm_quat_normalize_to ( @yushli )
  • improve docs
  • fix build scripts
    • fix linking cmocka
    • fix build script if folder names contain spaces

v0.5.3: memory and improvements - 2019-03-03 13:43:13

Improvements:

  • drop glm__memcpy, glm__memset and glm__memzero
    • copy matrix items manually in _ucopy functions
  • update docs

New Functions:

  • float glm_mat3_rmc(vec3 r, mat3 m, vec3 c) multiplies row vector, matrix and column vector and returns scalar.
  • glm_mat3_zero(mat3 mat), glm_mat4_zero(mat4 mat) make given matrix zero.

v0.5.2: SIMD Update + New Features - 2019-02-03 14:31:02

New Options:

  • CGLM_SSE4_DOT : Enable SSE4 dot product
  • CGLM_SSE3_DOT : Enable SSE3 dot product

New Functions:

  • glm_persp_move_far() extend frustum's far distance
  • void glm_vec4_cubic(float s, vec4 dest) fills vec4 as [s^3, s^2, s, 1.0]
  • float glm_mat4_rmc(vec4 r, mat4 m, vec4 c) multiplies row vector, matrix and column vector and returns scalar. This is good helper to get SMC result easily for curves.
  • float glm_smc(float s, mat4 m, vec4 c) calculates SMC multiplication by using glm_mat4_rmc()and glm_vec4_cubic()
  • float glm_bezier() cubic bezier equation
  • float glm_hermite() cubic hermite equation
  • float glm_decasteljau() solve cubic bezier equation using decasteljau

New glmm (SIMD) functions:

  • glmm_vhadds(v) horizontal add, returns register
  • glmm_hadd(v) horizontal add, returns scalar
  • glmm_vdots(a, b) dot product, single lane contain dot product to convert result to scalar
  • glmm_vdot(a, b) dot product, all lanes contain dot product to use result with other vector operations

Improvements:

  • glmm_ functions are moved to platform specific headers.
  • Now some glmm_ functions supports NEON
  • CGLM_SIMD_x86, CGLM_SIMD_ARM and CGLM_SIMD are defined if it is supported.

v0.5.1: type[s] update - 2019-01-02 06:58:24

New Features or Improvements:

  • [major change] builtin alignment (8-byte) is removed from vec3 and mat3 types
  • a helper to get normalized cross product (glm_vec3_crossn())
  • helpers to get trace of matrix

Bugfixes:

  • fix comparing two float values in tests

v0.5.0: vector update - 2018-12-02 18:44:29

New Features or Improvements:

  • [major change]: rename glm_vec_ namespace to glm_vec3_
  • new minadd, and maxadd functions for vectors
  • new negate functions e.g. glm_vec3_negate() , glm_vec4_negate()

Bugfixes:

  • fix versor alignment ( thanks to @sinisterchipmunk )
  • fix glm_vec3_angle() if cosine is out of range, now it does not return NaN and more stable.

DEPRECATED:

  • _flipsign and _inv functions for vectors are deprecated in favor of _negate function.

v0.4.9: Bug fixes and improvements - 2018-10-19 07:01:16

New Features or Improvements:

  • identiy helper for arrays (matrix/quaternion). This helpers will make each item of array identity matrix/quaternion.
  • define math constants in cglm header ( @hartenfels ). Now cglm does not depends on platform specific math constants

Bugfixes:

  • avx: replace binary constants with hex. Binary constants are GCC extensions ( thanks to @jonathanplatzer )
  • avx: fix glm_mul_avx().

v0.4.8: Easing functions and bug fixes - 2018-07-23 14:10:01

New Features or Improvements:

  • easing functions (experimental)
  • additional utils (see util.h)
    • add MIN and MAX macros
    • new version for clamp: clamp to zero and one
    • percentage
    • glm_eq to compare floats
  • unalignned version for vec4_copy: vec4_ucopy. Use this if you want to copy vector from external source
  • Add macro for automatic alignment of matrices (@jonathanplatzer)

Bugfixes:

  • Fix alignment issue when using AVX (@jonathanplatzer)

v0.4.7: AABB and Sphere - 2018-06-09 15:50:11

New Features or Improvements:

  • add support for spheres
  • aabb and sphere intersect functions
  • add squared distance for vec3; this will improve performance by avoiding calling sqrt function in some places

v0.4.6: Bugfix and Improvements - 2018-05-27 09:04:36

New Features or Improvements:

  • optimize glm_scale_make and glm_translate_make
  • align local variables on stack (because since v0.4.5, alignment is optional)
  • add missing call versions
  • helper for getting center of aabb (wrapper for vec_center)

Bug fixes:

  • fix glm_translate_to

API changes:

  • improve glm_mat4_mulv3 to apply translation too

v0.4.5: SIMD update - 2018-05-10 13:57:25

  • _MSC_VER is used instead of _WIN32 (Yatima1460)
  • header dependencies are fixed
  • New option for alignment; Alignment requirement is now OPTIONAL, check the docs to see options
  • New option for SSE/SSE2 shuffle operations
  • New namespace definition; now glmm_ is used for SIMD api
  • Alignment is disabled for older Visual Studio versions, this will fix alignment error for function params. Alignment is still required for Visual Studio 2017 15.6+ if it is not disabled.

- 2018-04-21 22:11:23

  • fix and improve build scripts
  • fix includes in public headers

Package Manager (Xcode):

  • add Cocoapod spec for iOS and macOS developers.

- 2018-04-18 19:31:50

  • fix build script

v0.4.2: transforms update - 2018-04-18 12:32:16

  • New rotation functions:
    • glm_rotate_at: rotate around point
    • glm_rotate_atm: make rotation around point
    • glm_quat_rotate_at: rotate around point using quaternion
    • glm_quat_rotate_atm: make rotate around point using quaternion
  • New mat4 multiplication function
    • glm_mul_rot: multiply matrix with rotation matrix
    • use this function for glm_rotate and glm_quat_rotate functions
  • Drop scale1, rotate_ndc transform functions
  • updates docs:
    • add clarifications for affine transforms
    • add troubleshooting
  • add some tests for affine transforms and for mat3

v0.4.1: vector update - 2018-04-15 10:13:34

  • optimize non-optimized with SIMD vec4 operations with SSE/SSE2
  • add one and zero helpers for vectors
  • fix scale_as for zero length vector: now it it returns zero
  • new functions for vec3 and vec4: (s suffix stands for scalar)
    • _mul: multiply two vector (replacement for _mulv)
    • _div: div two vector
    • _divs: div vector with scalar
    • adds: add scalar to each components of vec
    • subs: sub scalar from each components of vec
    • addadd, subadd, muladd, muladds helpers ( += )
  • optimize rotate vec3 using matrix4, add same function for mat3
  • add some tests for vectors
  • update docs for new apis

v0.4.0: Quaternion Update + Some Bugfixes and Features - 2018-04-11 13:58:23

  • invalidate axis-aligned boundng box util
  • aabb printer function
  • helper for check aabb is valid or not
  • get sign of float helper as -1, +1 and 0 for vec3, vec4 and for single floats
  • aabb box size and radius
  • project / unproject functions
  • isnan, isinf and isvalid heleprs for vectos
  • vector version of sqrt
  • lerp for numbers, vec3 and vec4
  • add call versions of vector extension
  • major quaternion update
    • change WXYZ order to XYZW
    • normalize quat in quat_mat4
    • normalize axis in quatv
    • quat to mat3
    • transposed versions of quat to mat4/mat3
    • quaternion version of look
    • quaternion version of rotate vector
    • quaternion version of rotate matrix
    • quaternion helpers; get conjugate, inv, angle, axis...
    • fix quaternion multiplication
    • SSE version for quaternion multiplication
    • fix slerp, add lerp
    • look rotation
    • quat to mat4 and quat to mat3
    • add tests, docs

and lots of improvements, bugfixes (and features) may not listed above!

- 2018-03-28 21:15:46

  • clamp functions
  • fix euler angles (extrinsic -> intrinsic)
  • optimize euler angles
  • improve build scripts

- 2018-03-03 15:23:37

  • frustum (extracting frustum corners, planes...)
  • bounding box (aabb)
  • possible orthogonal/perpendicular vector func
  • min and max vector
  • extract perspective parameters (size, fovy)
  • new wrappers for lookat (glm_look ...)
  • several improvements
  • complete documentation

- 2017-12-27 13:35:52

  • min and max for vectors
  • fix GLM_QUAT_IDENTITY_INIT (wxyz) instead of (xyzw). Addresses #10. (winduptoy)
  • rename near and far variable names (windows uses these names as macro)

- 2017-12-17 13:00:29

  • now accurate version matrix inversion is default
  • decompose projection matrix funcs
  • convenient macros for UP vector for lookAt
  • vec: helper / special macros for initializing white and black colors
  • inverse (opposite) of vectors
  • Fixed missing alignment on MinGW + GCC (smx-smx)