CGII/framework/include/cgv/media/sphere.h
2018-05-17 15:50:03 +02:00

34 lines
628 B
C++

#pragma once
#include <cgv/math/vec.h>
namespace cgv {
namespace media {
/**
* A sphere data structure. The sphere is defined by a homogeneous vector
which keeps the center point in the first components and the radius in
the last component.
*/
template <typename T,int N>
class sphere
{
public:
cgv::math::vec<T> h;
///create a unit sphere
sphere() : h(0,0,0,1)
{
}
/// construct from center and radius
sphere(const cgv::math::vec<T>& c, const T& radius)
{
h.resize(c.size()+1);
for (unsigned int i=0; i<c.size(); ++i)
h(i) = c(i);
h(c.size()) = radius;
}
};
}
}