mirror of https://github.com/AxioDL/zeus.git
21 lines
501 B
C++
21 lines
501 B
C++
#pragma once
|
|
|
|
#include "zeus/CVector3f.hpp"
|
|
|
|
namespace zeus {
|
|
class CSphere {
|
|
public:
|
|
constexpr CSphere(const CVector3f& position, float radius) : position(position), radius(radius) {}
|
|
|
|
CVector3f getSurfaceNormal(const CVector3f& coord) const { return (coord - position).normalized(); }
|
|
|
|
bool intersects(const CSphere& other) {
|
|
float dist = (position - other.position).magnitude();
|
|
return dist < (radius + other.radius);
|
|
}
|
|
|
|
CVector3f position;
|
|
float radius;
|
|
};
|
|
} // namespace zeus
|