diff --git a/src/pe/raytracing/Intersects.h b/src/pe/raytracing/Intersects.h
index a1fdb7c657d7e09bda33fd9f30448aebd84e1eb1..08ef13b657c3cf8f010dd1b8cf8f2c9727352689 100644
--- a/src/pe/raytracing/Intersects.h
+++ b/src/pe/raytracing/Intersects.h
@@ -45,6 +45,7 @@ inline bool intersects(const AABB& aabb, const Ray& ray, real_t& t, real_t paddi
 inline bool intersects(const SphereID sphere, const Ray& ray, real_t& t, Vec3& n);
 inline bool intersects(const PlaneID plane, const Ray& ray, real_t& t, Vec3& n);
 inline bool intersects(const BoxID box, const Ray& ray, real_t& t, Vec3& n);
+inline bool intersects(const CapsuleID capsule, const Ray& ray, real_t& t, Vec3& n);
 
 struct IntersectsFunctor
 {
@@ -122,7 +123,7 @@ inline bool intersects(const PlaneID plane, const Ray& ray, real_t& t, Vec3& n)
 }
 
 inline bool intersects(const BoxID box, const Ray& ray, real_t& t, Vec3& n) {
-   Ray transformedRay(box->pointFromWFtoBF(ray.getOrigin()), box->vectorFromWFtoBF(ray.getDirection()));
+   Ray transformedRay = ray.transformedToBF(box);
    
    const Vec3& lengths = box->getLengths();
    const Vec3 lengthsHalved = lengths/real_t(2);
diff --git a/src/pe/raytracing/Ray.h b/src/pe/raytracing/Ray.h
index c3e5d28d63291f4864667ac3144379ffe83c924c..65079d9ff5e78d6242aa55cc94fc10859c01d9db 100644
--- a/src/pe/raytracing/Ray.h
+++ b/src/pe/raytracing/Ray.h
@@ -117,6 +117,14 @@ public:
       sign_[1] = int8_c(inv_direction_[1] < 0);
       sign_[2] = int8_c(inv_direction_[2] < 0);
    }
+   
+   /*!\brief Transforms the ray to the body frame.
+    *
+    * \return Ray transformed to the body frame.
+    */
+   Ray transformedToBF(const BodyID body) const {
+      return Ray(body->pointFromWFtoBF(getOrigin()), body->vectorFromWFtoBF(getDirection()));
+   }
    //@}
 };