mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-13 04:42:12 +03:00
Some minor fixes.
--HG-- branch : dev
This commit is contained in:
@@ -308,23 +308,23 @@ bool Polygon2<T>::intersect( const Polygon2<T>& p1 ) {
|
||||
|
||||
vAxis = Line2<T>( Vector[i], Vector[n] ).getNormal();
|
||||
|
||||
min0 = vAxis.Dot( Vector[0] );
|
||||
min0 = vAxis.dot( Vector[0] );
|
||||
max0 = min0;
|
||||
for (j = 1; j < this->getSize(); j++) {
|
||||
t = vAxis.Dot( Vector[j] );
|
||||
t = vAxis.dot( Vector[j] );
|
||||
if (t < min0) min0 = t;
|
||||
if (t > max0) max0 = t;
|
||||
}
|
||||
|
||||
min1 = vAxis.Dot( p1[0] );
|
||||
min1 = vAxis.dot( p1[0] );
|
||||
max1 = min1;
|
||||
for (j = 1; j < p1.getSize(); j++) {
|
||||
t = vAxis.Dot( p1[j] );
|
||||
t = vAxis.dot( p1[j] );
|
||||
if (t < min1) min1 = t;
|
||||
if (t > max1) max1 = t;
|
||||
}
|
||||
|
||||
sOffset = vAxis.Dot( vOffset );
|
||||
sOffset = vAxis.dot( vOffset );
|
||||
min0 += sOffset;
|
||||
max0 += sOffset;
|
||||
|
||||
@@ -339,23 +339,23 @@ bool Polygon2<T>::intersect( const Polygon2<T>& p1 ) {
|
||||
|
||||
vAxis = Line2<T>( p1[i], p1[n] ).getNormal();
|
||||
|
||||
min0 = vAxis.Dot( Vector[0] );
|
||||
min0 = vAxis.dot( Vector[0] );
|
||||
max0 = min0;
|
||||
for (j = 1; j < this->getSize(); j++) {
|
||||
t = vAxis.Dot( Vector[j] );
|
||||
t = vAxis.dot( Vector[j] );
|
||||
if (t < min0) min0 = t;
|
||||
if (t > max0) max0 = t;
|
||||
}
|
||||
|
||||
min1 = vAxis.Dot( p1[0] );
|
||||
min1 = vAxis.dot( p1[0] );
|
||||
max1 = min1;
|
||||
for (j = 1; j < p1.getSize(); j++) {
|
||||
t = vAxis.Dot( p1[j] );
|
||||
t = vAxis.dot( p1[j] );
|
||||
if (t < min1) min1 = t;
|
||||
if (t > max1) max1 = t;
|
||||
}
|
||||
|
||||
sOffset = vAxis.Dot( vOffset );
|
||||
sOffset = vAxis.dot( vOffset );
|
||||
min0 += sOffset;
|
||||
max0 += sOffset;
|
||||
|
||||
|
||||
@@ -258,7 +258,7 @@ bool tRECT<T>::intersectsSegment( const Vector2<T>& a, const Vector2<T>& b ) {
|
||||
Vector2<T> offset( ( a.x + b.x - Right - Left ), ( a.y + b.y - Bottom - Top ) );
|
||||
Vector2<T> extents( Right - Left, Bottom - Top );
|
||||
|
||||
return ( eeabs( axis.Dot( offset ) ) < eeabs( axis.x * extents.x ) + eeabs( axis.y * extents.y ) );
|
||||
return ( eeabs( axis.dot( offset ) ) < eeabs( axis.x * extents.x ) + eeabs( axis.y * extents.y ) );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -24,10 +24,10 @@ class Vector2 {
|
||||
Vector2<T> copy();
|
||||
|
||||
/** @return The Dot product of the 2D vectors. */
|
||||
T Dot( const Vector2<T>& V2 );
|
||||
T dot( const Vector2<T>& V2 );
|
||||
|
||||
/** @return The Cross product of the 2D vectors. */
|
||||
T Cross( const Vector2<T>& V2 );
|
||||
T cross( const Vector2<T>& V2 );
|
||||
|
||||
/** @return The perpendicular vector */
|
||||
Vector2<T> perp();
|
||||
@@ -92,6 +92,10 @@ class Vector2 {
|
||||
/** Scales the vector position against another vector */
|
||||
void scale( const T& scale, const Vector2<T>& Center );
|
||||
|
||||
Vector2<T> ceil();
|
||||
|
||||
Vector2<T> floor();
|
||||
|
||||
T x;
|
||||
T y;
|
||||
private:
|
||||
@@ -119,7 +123,7 @@ Vector2<T> Vector2<T>::lerpConst( const Vector2<T>& Vec, T Dist ) {
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> Vector2<T>::sphericalLerp( const Vector2<T>& Vec, T Time ) {
|
||||
T omega = eeacos( Dot( Vec ) );
|
||||
T omega = eeacos( dot( Vec ) );
|
||||
|
||||
if( omega ) {
|
||||
T denom = 1 / eesin( omega );
|
||||
@@ -132,7 +136,7 @@ Vector2<T> Vector2<T>::sphericalLerp( const Vector2<T>& Vec, T Time ) {
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> Vector2<T>::sphericalLerpConst( const Vector2<T>& Vec, T Angle ) {
|
||||
T angle = eeacos( Dot( Vec ) );
|
||||
T angle = eeacos( dot( Vec ) );
|
||||
return lerp( Vec, ( ( Angle < angle ) ? Angle : angle ) / angle );
|
||||
}
|
||||
|
||||
@@ -334,12 +338,12 @@ void Vector2<T>::scale( const T& scale, const Vector2<T>& Center ) {
|
||||
|
||||
|
||||
template <typename T>
|
||||
T Vector2<T>::Dot( const Vector2<T>& V2 ) {
|
||||
T Vector2<T>::dot( const Vector2<T>& V2 ) {
|
||||
return x * V2.x + y * V2.y;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T Vector2<T>::Cross( const Vector2<T>& V2 ) {
|
||||
T Vector2<T>::cross( const Vector2<T>& V2 ) {
|
||||
return x * V2.x - y * V2.y;
|
||||
}
|
||||
|
||||
@@ -365,12 +369,12 @@ Vector2<T> Vector2<T>::unrotate( const Vector2<T>& V2 ) {
|
||||
|
||||
template <typename T>
|
||||
T Vector2<T>::length() {
|
||||
return eesqrt( Dot( Vector2<T>( x , y ) ) );
|
||||
return eesqrt( dot( Vector2<T>( x , y ) ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T Vector2<T>::lengthSq() {
|
||||
return Dot( Vector2<T>( x , y ) );
|
||||
return dot( Vector2<T>( x , y ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -407,7 +411,7 @@ T Vector2<T>::distanceSq( const Vector2<T>& Vec ) {
|
||||
|
||||
template <typename T>
|
||||
void Vector2<T>::clamp( T len ) {
|
||||
if ( Dot( Vector2<T>( x, y ) ) > len * len ) {
|
||||
if ( dot( Vector2<T>( x, y ) ) > len * len ) {
|
||||
normalize();
|
||||
|
||||
x *= len;
|
||||
@@ -415,6 +419,16 @@ void Vector2<T>::clamp( T len ) {
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> Vector2<T>::ceil() {
|
||||
return Vector2<T>( eeceil( x ), eeceil( y ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Vector2<T> Vector2<T>::floor() {
|
||||
return Vector2<T>( eefloor( x ), eefloor( y ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool Vector2<T>::nearDist( const Vector2<T>& Vec, T Dist ) {
|
||||
return 0 != ( distanceSq( Vec ) < Dist * Dist );
|
||||
|
||||
Reference in New Issue
Block a user