Header: cglm/sphere.h

Definition of sphere:

Sphere Representation in cglm is vec4: [center.x, center.y, center.z, radii]

You can call any vec3 function by passing sphere. Because first three elements defines center of sphere.

Table of contents (click to go):


  1. glm_sphere_radii()

  2. glm_sphere_transform()

  3. glm_sphere_merge()

  4. glm_sphere_sphere()

  5. glm_sphere_point()

Functions documentation

float glm_sphere_radii(vec4 s)
helper for getting sphere radius
[in] s sphere

returns radii

void glm_sphere_transform(vec4 s, mat4 m, vec4 dest)
apply transform to sphere, it is just wrapper for glm_mat4_mulv3
[in] s sphere
[in] m transform matrix
[out] dest transformed sphere
void glm_sphere_merge(vec4 s1, vec4 s2, vec4 dest)
merges two spheres and creates a new one

two sphere must be in same space, for instance if one in world space then the other must be in world space too, not in local space.

[in] s1 sphere 1
[in] s2 sphere 2
[out] dest merged/extended sphere
bool glm_sphere_sphere(vec4 s1, vec4 s2)
check if two sphere intersects
[in] s1 sphere
[in] s2 other sphere
bool glm_sphere_point(vec4 s, vec3 point)
check if sphere intersects with point
[in] s sphere
[in] point point