// Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_SPHERE_HPP #define NAZARA_SPHERE_HPP #include #include namespace Nz { struct SerializationContext; template class Box; template class Sphere { public: Sphere() = default; Sphere(T X, T Y, T Z, T Radius); //Sphere(const Circle& circle); Sphere(const Vector3& center, T Radius); Sphere(const T sphere[4]); template explicit Sphere(const Sphere& sphere); Sphere(const Sphere& sphere) = default; ~Sphere() = default; bool Contains(T X, T Y, T Z) const; bool Contains(const Box& box) const; bool Contains(const Vector3& point) const; T Distance(T X, T Y, T Z) const; T Distance(const Vector3& point) const; Sphere& ExtendTo(T X, T Y, T Z); Sphere& ExtendTo(const Vector3& point); Vector3 GetNegativeVertex(const Vector3& normal) const; Vector3 GetPosition() const; Vector3 GetPositiveVertex(const Vector3& normal) const; bool Intersect(const Box& box) const; bool Intersect(const Sphere& sphere) const; bool IsValid() const; Sphere& MakeUnit(); Sphere& MakeZero(); Sphere& Set(T X, T Y, T Z, T Radius); //Sphere& Set(const Circle& rect); Sphere& Set(const Sphere& sphere); Sphere& Set(const Vector3& center, T Radius); Sphere& Set(const T sphere[4]); template Sphere& Set(const Sphere& sphere); T SquaredDistance(T X, T Y, T Z) const; T SquaredDistance(const Vector3& point) const; String ToString() const; T& operator[](unsigned int i); T operator[](unsigned int i) const; Sphere operator*(T scalar) const; Sphere& operator*=(T scalar); bool operator==(const Sphere& sphere) const; bool operator!=(const Sphere& sphere) const; static Sphere Lerp(const Sphere& from, const Sphere& to, T interpolation); static Sphere Unit(); static Sphere Zero(); T x, y, z, radius; }; typedef Sphere Sphered; typedef Sphere Spheref; template bool Serialize(SerializationContext& context, const Sphere& sphere); template bool Unserialize(SerializationContext& context, Sphere* sphere); } template std::ostream& operator<<(std::ostream& out, const Nz::Sphere& sphere); #include #endif // NAZARA_SPHERE_HPP