mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-06-04 20:46:29 +03:00
Math module improvements.
--HG-- branch : dev
This commit is contained in:
@@ -65,10 +65,10 @@ class EE_API Interpolation {
|
||||
const Float& getRealPos() const;
|
||||
|
||||
/** @return If movement interpolation is a loop */
|
||||
const bool& loop() const;
|
||||
const bool& getLoop() const;
|
||||
|
||||
/** Set if loop the movement interpolation */
|
||||
void loop( const bool& loop );
|
||||
void setLoop( const bool& loop );
|
||||
|
||||
/** Clear all the points */
|
||||
void clearWaypoints();
|
||||
@@ -77,15 +77,15 @@ class EE_API Interpolation {
|
||||
const bool& ended() const;
|
||||
|
||||
/** Set the current interpolation speed */
|
||||
void speed( const Float speed );
|
||||
void setSpeed( const Float speed );
|
||||
|
||||
/** Get the current interpolation speed */
|
||||
const Float& speed() const;
|
||||
const Float& getSpeed() const;
|
||||
|
||||
/** @return If enabled */
|
||||
const bool& enabled() const;
|
||||
const bool& isEnabled() const;
|
||||
|
||||
void enabled( const bool& enabled );
|
||||
void setEnabled( const bool& enabled );
|
||||
|
||||
/** Instead if setting the time between every waypoing, this set a total time for all the movement interpolation. */
|
||||
void setTotalTime( const Time& TotTime );
|
||||
@@ -106,10 +106,10 @@ class EE_API Interpolation {
|
||||
const Float& getEndPos();
|
||||
|
||||
/** Set the type of interpolation to be used */
|
||||
void type( Ease::Interpolation InterpolationType );
|
||||
void setType( Ease::Interpolation InterpolationType );
|
||||
|
||||
/** @return The type of the interpolation */
|
||||
const int& type() const;
|
||||
const int& getType() const;
|
||||
protected:
|
||||
int mType;
|
||||
bool mEnable;
|
||||
|
||||
@@ -84,34 +84,34 @@ class EE_API MTRand {
|
||||
MTRand& operator=( const MTRand& o );
|
||||
|
||||
/** @return integer in [0,2^32-1] */
|
||||
Uint32 randi();
|
||||
Uint32 getRandi();
|
||||
|
||||
/** @return integer in [0,n] for n < 2^32 */
|
||||
Uint32 randi( const Uint32 n );
|
||||
Uint32 getRandi( const Uint32 n );
|
||||
|
||||
/** @return real number in [0,1] */
|
||||
double rand();
|
||||
double getRand();
|
||||
|
||||
/** @return real number in [0,n] */
|
||||
double rand( const double n );
|
||||
double getRand( const double n );
|
||||
|
||||
/** Set a new seed */
|
||||
void seed( const Uint32 oneSeed );
|
||||
void setSeed( const Uint32 oneSeed );
|
||||
|
||||
/** Set the default seed */
|
||||
void seed();
|
||||
void setSeed();
|
||||
|
||||
/** @return float number in [0,1] */
|
||||
Float randf();
|
||||
Float getRandf();
|
||||
|
||||
/** @return float number in [0,n] */
|
||||
Float randf( const Float n );
|
||||
Float getRandf( const Float n );
|
||||
|
||||
/** @return int number in [Min,Max] */
|
||||
int randRange( int Min, int Max );
|
||||
int getRandFromRange( int Min, int Max );
|
||||
|
||||
/** @return float number in [Min,Max] */
|
||||
Float randRange( Float Min, Float Max );
|
||||
Float getRandFromRange( Float Min, Float Max );
|
||||
|
||||
/** Save the state to an allocated array */
|
||||
void save( Uint32* saveArray ) const;
|
||||
|
||||
@@ -23,31 +23,31 @@ class EE_API PerlinNoise {
|
||||
void init();
|
||||
|
||||
/** @return The noise value for the 2D coordinates */
|
||||
Float perlinNoise2D(Float x, Float y);
|
||||
Float getPerlinNoise2D(Float x, Float y);
|
||||
|
||||
void octaves( const int& octaves ) { mOctaves = octaves; }
|
||||
void setOctaves( const int& octaves ) { mOctaves = octaves; }
|
||||
|
||||
void persistence( const Float& pers) { mPersistence = pers; }
|
||||
void setPersistence( const Float& pers) { mPersistence = pers; }
|
||||
|
||||
void frequency( const Float& freq ) { mFrequency = freq; }
|
||||
void setFrequency( const Float& freq ) { mFrequency = freq; }
|
||||
|
||||
void amplitude( const Float& amp ) { mAmplitude = amp; }
|
||||
void setAmplitude( const Float& amp ) { mAmplitude = amp; }
|
||||
|
||||
void frequencyOctaveDep( const bool& dep ) { mFreqOctaveDep = dep; }
|
||||
void setFrequencyOctaveDep( const bool& dep ) { mFreqOctaveDep = dep; }
|
||||
|
||||
void amplitudeOctaveDep( const bool& dep ) { mAmpOctaveDep = dep; }
|
||||
void setAmplitudeOctaveDep( const bool& dep ) { mAmpOctaveDep = dep; }
|
||||
|
||||
int octaves() const { return mOctaves; }
|
||||
int getOctaves() const { return mOctaves; }
|
||||
|
||||
Float persistence() const { return mPersistence; }
|
||||
Float getPersistence() const { return mPersistence; }
|
||||
|
||||
Float frequency() const { return mFrequency; }
|
||||
Float getFrequency() const { return mFrequency; }
|
||||
|
||||
Float amplitude() const { return mAmplitude; }
|
||||
Float getAmplitude() const { return mAmplitude; }
|
||||
|
||||
bool frequencyOctaveDep() const { return mFreqOctaveDep; }
|
||||
bool getFrequencyOctaveDep() const { return mFreqOctaveDep; }
|
||||
|
||||
bool amplitudeOctaveDep() const { return mAmpOctaveDep; }
|
||||
bool getAmplitudeOctaveDep() const { return mAmpOctaveDep; }
|
||||
protected:
|
||||
Float noise2D(Int32 x, Int32 y);
|
||||
|
||||
|
||||
@@ -60,28 +60,28 @@ class Polygon2 {
|
||||
}
|
||||
|
||||
/** @return The number of vectors of the polygon */
|
||||
std::size_t size() const;
|
||||
std::size_t getSize() const;
|
||||
|
||||
/** @return The position of the polygon ( also known as the offset of the polygon ) */
|
||||
Vector2<T> position() { return Vector2<T>(OffsetX, OffsetY); }
|
||||
Vector2<T> getPosition() { return Vector2<T>(OffsetX, OffsetY); }
|
||||
|
||||
/** Move the polygon Vector2s, add to every point the distance specified */
|
||||
void move( Vector2<T> dist );
|
||||
|
||||
/** @return The X position of the polygon ( the X-axis Offset ) */
|
||||
T x() const { return OffsetX; }
|
||||
T getX() const { return OffsetX; }
|
||||
|
||||
/** @return The Y position of the polygon ( the Y-axis Offset ) */
|
||||
T y() const { return OffsetY; }
|
||||
T getY() const { return OffsetY; }
|
||||
|
||||
/** @return The position of the polygon ( the offset )*/
|
||||
void position( const Vector2<T>& V ) { OffsetX = V.x; OffsetY = V.y; }
|
||||
void setPosition( const Vector2<T>& V ) { OffsetX = V.x; OffsetY = V.y; }
|
||||
|
||||
/** Set the new position of the x-axis ( the x-axis offset ) */
|
||||
T x( const T& x ) { OffsetX = x; }
|
||||
T setX( const T& x ) { OffsetX = x; }
|
||||
|
||||
/** Set the new position of the y-axis ( the y-axis offset ) */
|
||||
T y( const T& y ) { OffsetY = y; }
|
||||
T setY( const T& y ) { OffsetY = y; }
|
||||
|
||||
/** @return True if the polygons intersect */
|
||||
bool intersect( const Polygon2<T>& p1 );
|
||||
@@ -192,7 +192,7 @@ const Vector2<T>& Polygon2<T>::operator[] ( const Uint32& Pos ) const {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::size_t Polygon2<T>::size() const {
|
||||
std::size_t Polygon2<T>::getSize() const {
|
||||
return Vector.size();
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
||||
template<typename T>
|
||||
bool Polygon2<T>::pointInside( const Vector2<T>& point ) {
|
||||
int i, j, c = 0;
|
||||
int nvert = (int)size();
|
||||
int nvert = (int)getSize();
|
||||
|
||||
for ( i = 0, j = nvert - 1; i < nvert; j = i++ ) {
|
||||
if ( ( ( Vector[i].y > point.y ) != ( Vector[j].y > point.y ) ) &&
|
||||
@@ -313,19 +313,19 @@ template <typename T>
|
||||
bool Polygon2<T>::intersect( const Polygon2<T>& p1 ) {
|
||||
T min0, max0, min1, max1, sOffset, t;
|
||||
Vector2<T> vAxis, vOffset;
|
||||
unsigned int i = 0, j = 0, n, size = this->size();
|
||||
unsigned int i = 0, j = 0, n, size = this->getSize();
|
||||
|
||||
vOffset = Vector2<T>( x() - p1.x(), y() - p1.y() );
|
||||
vOffset = Vector2<T>( getX() - p1.getX(), getY() - p1.getY() );
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
n = i + 1;
|
||||
if ( n >= this->size() ) n = 0;
|
||||
if ( n >= this->getSize() ) n = 0;
|
||||
|
||||
vAxis = Line2<T>( Vector[i], Vector[n] ).getNormal();
|
||||
|
||||
min0 = vAxis.Dot( Vector[0] );
|
||||
max0 = min0;
|
||||
for (j = 1; j < this->size(); j++) {
|
||||
for (j = 1; j < this->getSize(); j++) {
|
||||
t = vAxis.Dot( Vector[j] );
|
||||
if (t < min0) min0 = t;
|
||||
if (t > max0) max0 = t;
|
||||
@@ -333,7 +333,7 @@ bool Polygon2<T>::intersect( const Polygon2<T>& p1 ) {
|
||||
|
||||
min1 = vAxis.Dot( p1[0] );
|
||||
max1 = min1;
|
||||
for (j = 1; j < p1.size(); j++) {
|
||||
for (j = 1; j < p1.getSize(); j++) {
|
||||
t = vAxis.Dot( p1[j] );
|
||||
if (t < min1) min1 = t;
|
||||
if (t > max1) max1 = t;
|
||||
@@ -348,15 +348,15 @@ bool Polygon2<T>::intersect( const Polygon2<T>& p1 ) {
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < p1.size(); i++) {
|
||||
for (i = 0; i < p1.getSize(); i++) {
|
||||
n = i + 1;
|
||||
if ( n >= p1.size() ) n = 0;
|
||||
if ( n >= p1.getSize() ) n = 0;
|
||||
|
||||
vAxis = Line2<T>( p1[i], p1[n] ).getNormal();
|
||||
|
||||
min0 = vAxis.Dot( Vector[0] );
|
||||
max0 = min0;
|
||||
for (j = 1; j < this->size(); j++) {
|
||||
for (j = 1; j < this->getSize(); j++) {
|
||||
t = vAxis.Dot( Vector[j] );
|
||||
if (t < min0) min0 = t;
|
||||
if (t > max0) max0 = t;
|
||||
@@ -364,7 +364,7 @@ bool Polygon2<T>::intersect( const Polygon2<T>& p1 ) {
|
||||
|
||||
min1 = vAxis.Dot( p1[0] );
|
||||
max1 = min1;
|
||||
for (j = 1; j < p1.size(); j++) {
|
||||
for (j = 1; j < p1.getSize(); j++) {
|
||||
t = vAxis.Dot( p1[j] );
|
||||
if (t < min1) min1 = t;
|
||||
if (t > max1) max1 = t;
|
||||
@@ -389,8 +389,8 @@ bool Polygon2<T>::intersectQuad2( const Quad2<T>& q0, const Quad2<T>& q1, const
|
||||
Polygon2<T> Tmp1 = Polygon2<T>( q0 );
|
||||
Polygon2<T> Tmp2 = Polygon2<T>( q1 );
|
||||
|
||||
Tmp1.position( q0Pos );
|
||||
Tmp1.position( q1Pos );
|
||||
Tmp1.setPosition( q0Pos );
|
||||
Tmp1.setPosition( q1Pos );
|
||||
|
||||
return Tmp1.intersect( Tmp2 );
|
||||
}
|
||||
|
||||
@@ -49,15 +49,15 @@ class tRECT {
|
||||
|
||||
Vector2<T> wrapVector( const Vector2<T>& Vect );
|
||||
|
||||
Vector2<T> pos();
|
||||
Vector2<T> getPosition();
|
||||
|
||||
Vector2<T> center();
|
||||
Vector2<T> getCenter();
|
||||
|
||||
tSize<T> size();
|
||||
tSize<T> getSize();
|
||||
|
||||
T width();
|
||||
T getWidth();
|
||||
|
||||
T height();
|
||||
T getHeight();
|
||||
|
||||
void scale( T scale, const Vector2<T>& center );
|
||||
|
||||
@@ -148,8 +148,8 @@ template <typename T>
|
||||
tRECT<T>::tRECT( const Vector2<T>& Pos, const tSize<T>& Size ) {
|
||||
Left = Pos.x;
|
||||
Top = Pos.y;
|
||||
Right = Left + Size.width();
|
||||
Bottom = Top + Size.height();
|
||||
Right = Left + Size.getWidth();
|
||||
Bottom = Top + Size.getHeight();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -171,27 +171,27 @@ bool tRECT<T>::contains( const Vector2<T>& Vect ) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> tRECT<T>::pos() {
|
||||
Vector2<T> tRECT<T>::getPosition() {
|
||||
return Vector2<T>( Left, Top );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> tRECT<T>::center() {
|
||||
Vector2<T> tRECT<T>::getCenter() {
|
||||
return Vector2<T>( Left + ( ( Right - Left ) * 0.5 ), Top + ( ( Bottom - Top ) * 0.5 ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
tSize<T> tRECT<T>::size() {
|
||||
tSize<T> tRECT<T>::getSize() {
|
||||
return tSize<T>( eeabs( Right - Left ), eeabs( Bottom - Top ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T tRECT<T>::width() {
|
||||
T tRECT<T>::getWidth() {
|
||||
return eeabs( Right - Left );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T tRECT<T>::height() {
|
||||
T tRECT<T>::getHeight() {
|
||||
return eeabs( Bottom - Top );
|
||||
}
|
||||
|
||||
@@ -303,12 +303,12 @@ void tRECT<T>::scale( T scale, const Vector2<T>& center ) {
|
||||
|
||||
template <typename T>
|
||||
void tRECT<T>::scale( T scale ) {
|
||||
scale( scale, center() );
|
||||
scale( scale, getCenter() );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void tRECT<T>::scale( Vector2<T> scale ) {
|
||||
scale( scale, center() );
|
||||
scale( scale, getCenter() );
|
||||
}
|
||||
|
||||
typedef tRECT<unsigned int> Rectu;
|
||||
|
||||
@@ -23,16 +23,16 @@ class tSize : public Vector2<T>
|
||||
tSize( const Vector2<T>& Vec );
|
||||
|
||||
/** @return The size width */
|
||||
const T& width() const;
|
||||
const T& getWidth() const;
|
||||
|
||||
/** @return The size height */
|
||||
const T& height() const;
|
||||
const T& getHeight() const;
|
||||
|
||||
/** Set a new width */
|
||||
void width( const T& width );
|
||||
void setWidth( const T& width );
|
||||
|
||||
/** Set a new height */
|
||||
void height( const T& height );
|
||||
void setHeight( const T& height );
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
@@ -49,7 +49,7 @@ tSize<T>::tSize( const T& Width, const T& Height ) :
|
||||
|
||||
template <typename T>
|
||||
tSize<T>::tSize( const tSize<T>& Size ) :
|
||||
Vector2<T>( Size.width(), Size.height() )
|
||||
Vector2<T>( Size.getWidth(), Size.getHeight() )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -60,22 +60,22 @@ tSize<T>::tSize( const Vector2<T>& Vec ) :
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T& tSize<T>::width() const {
|
||||
const T& tSize<T>::getWidth() const {
|
||||
return this->x;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T& tSize<T>::height() const {
|
||||
const T& tSize<T>::getHeight() const {
|
||||
return this->y;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void tSize<T>::width( const T& width ) {
|
||||
void tSize<T>::setWidth( const T& width ) {
|
||||
this->x = width;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void tSize<T>::height( const T& height ) {
|
||||
void tSize<T>::setHeight( const T& height ) {
|
||||
this->y = height;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,10 +66,10 @@ class EE_API Waypoints {
|
||||
const Vector2f& getPos();
|
||||
|
||||
/** @return If movement interpolation is a loop */
|
||||
bool loop() const;
|
||||
bool getLoop() const;
|
||||
|
||||
/** Set if loop the movement interpolation */
|
||||
void loop( const bool& loop );
|
||||
void setLoop( const bool& loop );
|
||||
|
||||
/** Clear all the waypoints */
|
||||
void clearWaypoints();
|
||||
@@ -93,22 +93,22 @@ class EE_API Waypoints {
|
||||
const std::vector<Waypoint>& getWaypoints() const;
|
||||
|
||||
/** Set the current interpolation speed ( This will destroy the time of the interpolation and create one depending on the speed ) ( pixels per second ) */
|
||||
void speed( const Float& speed );
|
||||
void setSpeed( const Float& speed );
|
||||
|
||||
/** Get the current interpolation speed */
|
||||
const Float& speed() const;
|
||||
const Float& getSpeed() const;
|
||||
|
||||
/** @return If enabled */
|
||||
const bool& enabled() const;
|
||||
const bool& isEnabled() const;
|
||||
|
||||
/** Set it enabled or not */
|
||||
void enabled( const bool& enabled );
|
||||
void setEnabled( const bool& enabled );
|
||||
|
||||
/** Set the type of interpolation to be used */
|
||||
void type( Ease::Interpolation InterpolationType );
|
||||
void setType( Ease::Interpolation InterpolationType );
|
||||
|
||||
/** @return The type of the interpolation */
|
||||
const int& type() const;
|
||||
const int& getType() const;
|
||||
protected:
|
||||
int mType;
|
||||
bool mEnable;
|
||||
|
||||
Reference in New Issue
Block a user