Skip to content
Extraits de code Groupes Projets
Valider b5390ebb rédigé par Acheroufkebir Yacine's avatar Acheroufkebir Yacine
Parcourir les fichiers

shape.cpp

parent 224f1475
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -19,10 +19,11 @@ class Ray3f
Vector3f origin() const;
Vector3f direction() const;
std::ostream & operator<<(std::ostream & st, const Ray3f & v);
};
std::ostream & operator<<(std::ostream & st, const Ray3f & v);
#endif
......@@ -12,7 +12,16 @@ Sphere::Sphere(Material matter, Vector3f origin, float radius) : Shape(matter)
bool Sphere::is_hit(const Ray3f ray)
{
Vector3f D = ray.origin()-origin_;
Vector3f u = ray.direction();
if (D<radius_){return false;}
if (D*u<0) {return false;}
if((D^u).norm()/u.norm<radius_){return false;}
return true;
}
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter