mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
reflect
This commit is contained in:
@@ -55,7 +55,7 @@
|
||||
CGLM_INLINE void glm_vec2_clamp(vec2 v, float minVal, float maxVal)
|
||||
CGLM_INLINE void glm_vec2_lerp(vec2 from, vec2 to, float t, vec2 dest)
|
||||
CGLM_INLINE void glm_vec2_make(float * restrict src, vec2 dest)
|
||||
|
||||
CGLM_INLINE void glm_vec2_reflect(vec2 I, vec2 N, vec2 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_vec2_h
|
||||
@@ -712,4 +712,19 @@ glm_vec2_make(const float * __restrict src, vec2 dest) {
|
||||
dest[0] = src[0]; dest[1] = src[1];
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief reflection vector using an incident ray and a surface normal
|
||||
*
|
||||
* @param[in] I incident vector
|
||||
* @param[in] N normalized normal vector
|
||||
* @param[out] dest destination vector for the reflection result
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_vec2_reflect(vec2 I, vec2 N, vec2 dest) {
|
||||
vec2 temp;
|
||||
glm_vec2_scale(N, 2.0f * glm_vec2_dot(I, N), temp);
|
||||
glm_vec2_sub(I, temp, dest);
|
||||
}
|
||||
|
||||
#endif /* cglm_vec2_h */
|
||||
|
||||
Reference in New Issue
Block a user