Files
NazaraEngine/include/Nazara/Math/Sphere.hpp
Gawaboumga 676ed6c9d8 Correction of mathematical functions.
BoundingVolume: Add of constructor and setter OrientedBox. Extend is now
up to date.
Box: Use of <T>. Return this
Frustrum: Use of <T>
Matrix: Use of <T>
OrientedBox: m_corners is up to date
Rect: Add of operators /= and /. Return this
Sphere: Add of Intersect and Contains with box. Little corrections.
Vector2: Return

TaskSchedulerImpl: Add of include header cstdlib to compile because of
std::div
HardwareInfo/main: use of accentAigu

Former-commit-id: a5a7f8e8c45448e5683eb13bff453d6f67478d03
2014-06-14 22:10:37 +02:00

88 lines
2.3 KiB
C++

// Copyright (C) 2014 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 <Nazara/Core/String.hpp>
#include <Nazara/Math/Box.hpp>
#include <Nazara/Math/Vector3.hpp>
template<typename T>
class NzBox;
template<typename T>
class NzSphere
{
public:
NzSphere() = default;
NzSphere(T X, T Y, T Z, T Radius);
//NzSphere(const NzCircle<T>& circle);
NzSphere(const NzVector3<T>& center, T Radius);
NzSphere(const T sphere[4]);
template<typename U> explicit NzSphere(const NzSphere<U>& sphere);
NzSphere(const NzSphere& sphere) = default;
~NzSphere() = default;
bool Contains(T X, T Y, T Z) const;
bool Contains(const NzBox<T>& box) const;
bool Contains(const NzVector3<T>& point) const;
T Distance(T X, T Y, T Z) const;
T Distance(const NzVector3<T>& point) const;
NzSphere& ExtendTo(T X, T Y, T Z);
NzSphere& ExtendTo(const NzVector3<T>& point);
NzVector3<T> GetNegativeVertex(const NzVector3<T>& normal) const;
NzVector3<T> GetPosition() const;
NzVector3<T> GetPositiveVertex(const NzVector3<T>& normal) const;
bool Intersect(const NzBox<T>& box) const;
bool Intersect(const NzSphere& sphere) const;
bool IsValid() const;
NzSphere& MakeZero();
NzSphere& Set(T X, T Y, T Z, T Radius);
//NzSphere& Set(const NzCircle<T>& rect);
NzSphere& Set(const NzSphere& sphere);
NzSphere& Set(const NzVector3<T>& center, T Radius);
NzSphere& Set(const T sphere[4]);
template<typename U> NzSphere& Set(const NzSphere<U>& sphere);
T SquaredDistance(T X, T Y, T Z) const;
T SquaredDistance(const NzVector3<T>& point) const;
NzString ToString() const;
T& operator[](unsigned int i);
T operator[](unsigned int i) const;
NzSphere operator*(T scalar) const;
NzSphere& operator*=(T scalar);
bool operator==(const NzSphere& sphere) const;
bool operator!=(const NzSphere& sphere) const;
static NzSphere Lerp(const NzSphere& from, const NzSphere& to, T interpolation);
static NzSphere Zero();
T x, y, z, radius;
};
template<typename T>
std::ostream& operator<<(std::ostream& out, const NzSphere<T>& sphere);
typedef NzSphere<double> NzSphered;
typedef NzSphere<float> NzSpheref;
#include <Nazara/Math/Sphere.inl>
#endif // NAZARA_SPHERE_HPP