17 # pragma GCC diagnostic push
18 # pragma GCC diagnostic ignored "-Wpedantic"
20 #if defined(__clang__)
21 # pragma clang diagnostic push
22 # pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
23 # pragma clang diagnostic ignored "-Wnested-anon-types"
26 #include <vsg/maths/vec3.h>
27 #include <vsg/maths/vec4.h>
47 value_type x, y, z, r;
58 value{0.0, 0.0, 0.0, -1.0} {}
61 value{s[0], s[1], s[2], s[3]} {}
67 value{
static_cast<value_type
>(s[0]),
static_cast<value_type
>(s[1]),
static_cast<value_type
>(s[2]),
static_cast<value_type
>(s[3])} {}
71 value{
static_cast<value_type
>(c.x),
static_cast<value_type
>(c.y),
static_cast<value_type
>(c.z), rad} {}
74 constexpr
t_sphere(R sx, R sy, R sz, R sd) :
75 value{sx, sy, sz, sd} {}
77 constexpr std::size_t size()
const {
return 4; }
79 value_type& operator[](std::size_t i) {
return value[i]; }
80 value_type operator[](std::size_t i)
const {
return value[i]; }
85 value[0] =
static_cast<value_type
>(rhs[0]);
86 value[1] =
static_cast<value_type
>(rhs[1]);
87 value[2] =
static_cast<value_type
>(rhs[2]);
88 value[3] =
static_cast<value_type
>(rhs[3]);
92 void set(value_type in_x, value_type in_y, value_type in_z, value_type in_r)
103 x =
static_cast<value_type
>(c.x);
104 y =
static_cast<value_type
>(c.y);
105 z =
static_cast<value_type
>(c.z);
109 bool valid()
const {
return radius >= 0.0; }
111 explicit operator bool()
const noexcept {
return valid(); }
113 T* data() {
return value; }
114 const T* data()
const {
return value; }
118 center.set(0.0, 0.0, 0.0);
132 return (lhs.center == rhs.center) && (lhs.radius == rhs.radius);
136 constexpr
bool operator!=(
const t_sphere<T>& lhs,
const t_sphere<T>& rhs)
138 return (lhs.center != rhs.center) || (lhs.radius != rhs.radius);
142 constexpr
bool operator<(
const t_sphere<T>& lhs,
const t_sphere<T>& rhs)
144 if (lhs.center < rhs.center)
return true;
145 if (rhs.center < lhs.center)
return false;
146 return lhs.radius < rhs.radius;
151 #if defined(__clang__)
152 # pragma clang diagnostic pop
154 #if defined(__GNUC__)
155 # pragma GCC diagnostic pop
template sphere class
Definition: sphere.h:34
t_vec3 template class that represents a 3D vector
Definition: vec3.h:34
t_vec4 template class that represents a 4D vector
Definition: vec4.h:35