mirror of
https://github.com/recp/cglm.git
synced 2025-10-03 08:41:55 +00:00
ray: point along a ray at a parameter t
This commit is contained in:
@@ -29,6 +29,10 @@ glmc_ray_sphere(vec3 origin,
|
||||
float * __restrict t1,
|
||||
float * __restrict t2);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ray_at(vec3 orig, vec3 dir, float t, vec3 point);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -18,6 +18,7 @@
|
||||
vec4 s,
|
||||
float * __restrict t1,
|
||||
float * __restrict t2)
|
||||
CGLM_INLINE void glm_ray_at(vec3 orig, vec3 dir, float t, vec3 point);
|
||||
*/
|
||||
|
||||
#ifndef cglm_ray_h
|
||||
@@ -144,4 +145,20 @@ glm_ray_sphere(vec3 origin,
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief point using t by 𝐏(𝑡)=𝐀+𝑡𝐛
|
||||
*
|
||||
* @param[in] orig origin of ray
|
||||
* @param[in] dir direction of ray
|
||||
* @param[in] t parameter
|
||||
* @param[out] point point at t
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ray_at(vec3 orig, vec3 dir, float t, vec3 point) {
|
||||
vec3 dst;
|
||||
glm_vec3_scale(dir, t, dst);
|
||||
glm_vec3_add(orig, dst, point);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -56,4 +56,20 @@ glms_ray_(sphere)(vec3s origin,
|
||||
return glm_ray_sphere(origin.raw, dir.raw, s.raw, t1, t2);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief point using t by 𝐏(𝑡)=𝐀+𝑡𝐛
|
||||
*
|
||||
* @param[in] orig origin of ray
|
||||
* @param[in] dir direction of ray
|
||||
* @param[in] t parameter
|
||||
* @returns point point at t
|
||||
*/
|
||||
CGLM_INLINE
|
||||
vec3s
|
||||
glms_ray_(at)(vec3s orig, vec3s dir, float t) {
|
||||
vec3s r;
|
||||
glm_ray_at(orig.raw, orig.raw, t, r.raw);
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif /* cglms_ray_h */
|
||||
|
Reference in New Issue
Block a user