aabb box size and radius
@@ -177,4 +177,26 @@ glm_aabb_isvalid(vec3 box[2]) {
&& glm_vec_min(box[1]) != -FLT_MAX;
}
+/*!
+ * @brief distance between of min and max
+ *
+ * @param[in] box bounding box
+ */
+CGLM_INLINE
+float
+glm_aabb_size(vec3 box[2]) {
+ return glm_vec_distance(box[0], box[1]);
+}
+
+/*!
+ * @brief radius of sphere which surrounds AABB
+ *
+ * @param[in] box bounding box
+ */
+CGLM_INLINE
+float
+glm_aabb_radius(vec3 box[2]) {
+ return glm_aabb_size(box) * 0.5f;
+}
+
#endif /* cglm_box_h */
