sphere point intersection

This commit is contained in:
Recep Aslantas
2018-06-09 18:21:29 +03:00
parent fc14cedf89
commit 857265b892
4 changed files with 33 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ Functions:
#. :c:func:`glm_sphere_transform`
#. :c:func:`glm_sphere_merge`
#. :c:func:`glm_sphere_sphere`
#. :c:func:`glm_sphere_point`
Functions documentation
~~~~~~~~~~~~~~~~~~~~~~~
@@ -63,3 +64,11 @@ Functions documentation
Parameters:
| *[in]* **s1** sphere
| *[in]* **s2** other sphere
.. c:function:: bool glm_sphere_point(vec4 s, vec3 point)
| check if sphere intersects with point
Parameters:
| *[in]* **s** sphere
| *[in]* **point** point

View File

@@ -29,4 +29,8 @@ CGLM_EXPORT
bool
glmc_sphere_sphere(vec4 s1, vec4 s2);
CGLM_EXPORT
bool
glmc_sphere_point(vec4 s, vec3 point);
#endif /* cglmc_sphere_h */

View File

@@ -82,4 +82,18 @@ glm_sphere_sphere(vec4 s1, vec4 s2) {
return glm_vec_distance2(s1, s2) <= glm_pow2(s1[3] + s2[3]);
}
/*!
* @brief check if sphere intersects with point
*
* @param[in] s sphere
* @param[in] point point
*/
CGLM_INLINE
bool
glm_sphere_point(vec4 s, vec3 point) {
float rr;
rr = s[3] * s[3];
return glm_vec_distance2(point, s) <= rr;
}
#endif /* cglm_sphere_h */

View File

@@ -31,3 +31,9 @@ bool
glmc_sphere_sphere(vec4 s1, vec4 s2) {
return glm_sphere_sphere(s1, s2);
}
CGLM_EXPORT
bool
glmc_sphere_point(vec4 s, vec3 point) {
return glm_sphere_point(s, point);
}