first commit

This commit is contained in:
2026-06-22 11:49:35 +02:00
commit d805f2ba86
619 changed files with 126873 additions and 0 deletions

View File

@ -0,0 +1,49 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NRANGE__
#define __NRANGE__
#include "math/nrange.h"
namespace GS {
/*!
@short Range.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
template <class T> struct Range
{
T start, end;
T valueRange() const { return end - start; }
bool inRange(const T &v) const { return (start < end) ? ((v >= start) && (v < end)) : ((v >= end) && (v < start)); }
void sort() { if (start > end) { T t = start; start = end; end = t; } }
static Range Intersection(const Range <T> &a, const Range <T> &b)
{
if ((a.end < b.start) || (a.start > b.end))
return Range <T> ();
return Range(a.start > b.start ? a.start : b.start, a.end < b.end ? a.end : b.end);
}
static Range Union(const Range &a, const Range &b)
{ return Range(a.start < b.start ? a.start : b.start, a.end > b.end ? a.end : b.end); }
void Set(const T &s, const T &e) { start = s; end = e; }
template <class N> Range <N> convert() const
{ return Range <N> (N(start), N(end)); }
Range(const T &s, const T &e) : start(s), end(e) {}
Range() : start(0), end(0) {}
};
} // GS
#endif // __NRANGE__