|
|
|
@ -26,6 +26,8 @@ void Sphere::applyTransformation(const Matrix4& transformation) { |
|
|
|
bool Sphere::collides(const AbstractShape* other) const { |
|
|
|
bool Sphere::collides(const AbstractShape* other) const { |
|
|
|
if(other->type() == Type::Point) |
|
|
|
if(other->type() == Type::Point) |
|
|
|
return *this % *static_cast<const Point*>(other); |
|
|
|
return *this % *static_cast<const Point*>(other); |
|
|
|
|
|
|
|
if(other->type() == Type::Sphere) |
|
|
|
|
|
|
|
return *this % *static_cast<const Sphere*>(other); |
|
|
|
|
|
|
|
|
|
|
|
return AbstractShape::collides(other); |
|
|
|
return AbstractShape::collides(other); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -35,4 +37,9 @@ bool Sphere::operator%(const Point& other) const { |
|
|
|
Math::pow<2>(transformedRadius()); |
|
|
|
Math::pow<2>(transformedRadius()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Sphere::operator%(const Sphere& other) const { |
|
|
|
|
|
|
|
return (other.transformedPosition()-transformedPosition()).lengthSquared() < |
|
|
|
|
|
|
|
Math::pow<2>(transformedRadius()+other.transformedRadius()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}} |
|
|
|
}} |
|
|
|
|