Added missing power

This commit is contained in:
arvid schröder 2022-11-06 20:29:24 +01:00
parent 48432337c6
commit f37b8bc9c6

View file

@ -12,8 +12,6 @@ Sphere::Sphere(Vector3d const &center, float radius, std::shared_ptr<Shader> con
// Primitive functions /////////////////////////////////////////////////////////
bool Sphere::intersect(Ray &ray) const {
// IMPLEMENT ME!
// Determine whether the ray intersects the sphere
float A = pow(ray.direction[Vector3d::Dimension::X], 2) +
pow(ray.direction[Vector3d::Dimension::Y], 2) +
@ -25,7 +23,8 @@ bool Sphere::intersect(Ray &ray) const {
);
float C = pow(ray.origin[Vector3d::Dimension::X], 2) +
pow(ray.origin[Vector3d::Dimension::Y], 2) +
pow(ray.origin[Vector3d::Dimension::Z], 2) - this->radius;
pow(ray.origin[Vector3d::Dimension::Z], 2) -
pow(this->radius, 2);
float t = INFINITY;