src/tools/tPolynomial.h File Reference

#include "tError.h"
#include <math.h>
#include "tArray.h"
#include <iostream>
#include <string>

Include dependency graph for tPolynomial.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  tPolynomial< T >
 mathematical function (to be moved into tools sometime, and currently limited to linear functions) More...

Defines

#define REAL   float
#define MAX(a, b)   ((a>b)?a:b)
#define MIN(a, b)   ((a<b)?a:b)
#define DELTA   1e-3
#define TPOLYNOMIAL_DELIMITER   ';'

Functions

template<typename T>
T & operator<< (T &m, tPolynomial< T > const &f)
template<typename T>
T & operator>> (T &m, tPolynomial< T > &f)
 function network message writing operator
template<typename T>
bool operator== (const tPolynomial< T > &left, const tPolynomial< T > &right)
 function network message reading operator
template<typename T>
bool operator!= (const tPolynomial< T > &left, const tPolynomial< T > &right)


Define Documentation

#define DELTA   1e-3

Definition at line 248 of file tPolynomial.h.

Referenced by operator==(), and tPolynomialTest::testEvaluateAndBaseArgument().

#define MAX ( a,
b   )     ((a>b)?a:b)

Definition at line 39 of file tPolynomial.h.

#define MIN ( a,
b   )     ((a<b)?a:b)

Definition at line 40 of file tPolynomial.h.

Referenced by operator==().

#define REAL   float

Definition at line 38 of file tPolynomial.h.

Referenced by _wrap_EGameObject_act(), _wrap_EGameObject_cam_rise(), _wrap_EGameObject_cam_z(), _wrap_EGameObject_death_time(), _wrap_EGameObject_edge_is_dangerous(), _wrap_EGameObject_get_max_lazy_lag(), _wrap_EGameObject_interact_with__SWIG_0(), _wrap_EGameObject_interact_with__SWIG_1(), _wrap_EGameObject_lag(), _wrap_EGameObject_lag_threshold(), _wrap_EGameObject_last_time(), _wrap_EGameObject_move__SWIG_0(), _wrap_EGameObject_move__SWIG_1(), _wrap_EGameObject_next_interesting_time(), _wrap_EGameObject_pass_edge__SWIG_0(), _wrap_EGameObject_pass_edge__SWIG_1(), _wrap_EGameObject_pathfinding_modifier(), _wrap_EGameObject_s_timestep(), _wrap_EGameObject_set_max_lazy_lag(), _wrap_EGameObject_speed(), _wrap_EGameObject_timestep(), _wrap_ENetGameObject_lag(), _wrap_ENetGameObject_lag_threshold(), _wrap_ENetGameObject_receive_control(), _wrap_ENetGameObject_send_control(), _wrap_ENetGameObject_timestep(), _wrap_ESensor_detect(), _wrap_ESensor_get_inverse_speed__SWIG_0(), _wrap_ESensor_get_inverse_speed__SWIG_1(), _wrap_ESensor_hit_get(), _wrap_ESensor_hit_set(), _wrap_ESensor_pass_edge__SWIG_0(), _wrap_ESensor_pass_edge__SWIG_1(), _wrap_ESensor_set_inverse_speed(), _wrap_GCycle_act(), _wrap_GCycle_correctDistanceSmooth_get(), _wrap_GCycle_correctDistanceSmooth_set(), _wrap_GCycle_die(), _wrap_GCycle_edge_is_dangerous(), _wrap_GCycle_explosion_radius(), _wrap_GCycle_heightFrontWheel_get(), _wrap_GCycle_heightFrontWheel_set(), _wrap_GCycle_heightRearWheel_get(), _wrap_GCycle_heightRearWheel_set(), _wrap_GCycle_interact_with__SWIG_0(), _wrap_GCycle_interact_with__SWIG_1(), _wrap_GCycle_max_walls_length(), _wrap_GCycle_pass_edge__SWIG_0(), _wrap_GCycle_pass_edge__SWIG_1(), _wrap_GCycle_pathfinding_modifier(), _wrap_GCycle_receive_control(), _wrap_GCycle_set_explosion_radius(), _wrap_GCycle_set_walls_length(), _wrap_GCycle_set_walls_stay_up_delay(), _wrap_GCycle_skew_get(), _wrap_GCycle_skew_set(), _wrap_GCycle_skewDot_get(), _wrap_GCycle_skewDot_set(), _wrap_GCycle_this_walls_length(), _wrap_GCycle_timestep(), _wrap_GCycle_timestep_core__SWIG_0(), _wrap_GCycle_timestep_core__SWIG_1(), _wrap_GCycle_wall_end_speed(), _wrap_GCycle_walls_length(), _wrap_GCycle_walls_stay_up_delay(), _wrap_GCycleMovement_can_make_turn__SWIG_1(), _wrap_GCycleMovement_edge_is_dangerous(), _wrap_GCycleMovement_get_acceleration(), _wrap_GCycleMovement_get_braking_reservoir__SWIG_0(), _wrap_GCycleMovement_get_braking_reservoir__SWIG_1(), _wrap_GCycleMovement_get_distance__SWIG_0(), _wrap_GCycleMovement_get_distance__SWIG_1(), _wrap_GCycleMovement_get_distance_since_last_turn(), _wrap_GCycleMovement_get_last_turn_time__SWIG_0(), _wrap_GCycleMovement_get_last_turn_time__SWIG_1(), _wrap_GCycleMovement_get_max_space_ahead(), _wrap_GCycleMovement_get_next_turn(), _wrap_GCycleMovement_get_rubber__SWIG_0(), _wrap_GCycleMovement_get_rubber__SWIG_1(), _wrap_GCycleMovement_get_rubber_malus__SWIG_0(), _wrap_GCycleMovement_get_rubber_malus__SWIG_1(), _wrap_GCycleMovement_get_turn_delay(), _wrap_GCycleMovement_get_turn_delay_db(), _wrap_GCycleMovement_move_safely(), _wrap_GCycleMovement_next_interesting_time(), _wrap_GCycleMovement_set_braking_reservoir(), _wrap_GCycleMovement_set_rubber(), _wrap_GCycleMovement_set_speed_multiplier(), _wrap_GCycleMovement_speed(), _wrap_GCycleMovement_timestep(), _wrap_GCycleMovement_turn__SWIG_0(), _wrap_GSensor_pass_edge__SWIG_0(), _wrap_GSensor_pass_edge__SWIG_1(), _wrap_GSimpleAI_do_think(), _wrap_GSimpleAI_think(), _wrap_UMenu_message__SWIG_0(), _wrap_UMenu_request_space_below(), _wrap_UMenu_set_bot(), _wrap_UMenu_set_center(), _wrap_UMenu_set_top(), _wrap_UMenuItem_render__SWIG_0(), _wrap_UMenuItem_render__SWIG_1(), _wrap_UMenuItem_render__SWIG_2(), _wrap_UMenuItem_space_right(), _wrap_UMenuItemAction_render__SWIG_0(), _wrap_UMenuItemAction_render__SWIG_1(), _wrap_UMenuItemAction_render__SWIG_2(), _wrap_UMenuItemExit_render__SWIG_0(), _wrap_UMenuItemExit_render__SWIG_1(), _wrap_UMenuItemExit_render__SWIG_2(), _wrap_UMenuItemInt_render__SWIG_0(), _wrap_UMenuItemInt_render__SWIG_1(), _wrap_UMenuItemInt_render__SWIG_2(), _wrap_UMenuItemString_render__SWIG_0(), _wrap_UMenuItemString_render__SWIG_1(), _wrap_UMenuItemString_render__SWIG_2(), _wrap_UMenuItemSubmenu_render__SWIG_0(), _wrap_UMenuItemSubmenu_render__SWIG_1(), _wrap_UMenuItemSubmenu_render__SWIG_2(), eCamera::Act(), gCycleChatBot::Activate(), gAIPlayer::ActOnData(), tPolynomial< T >::adaptToNewReferenceVarValue(), ePath::Add(), gHitData::AddHit(), gEnemyInfluence::AddWall(), gNetPlayerWall::Alpha(), gPlayerWall::Alpha(), gGame::Analysis(), gCycleMovement::ApplyAcceleration(), tRecorderSync< DATA >::Archive(), atan2f(), nServerLag::Balance(), nSpamProtection::BlockTime(), gNetPlayerWall::BlowHole(), eCamera::Bound(), gCycleMovement::CalculateAcceleration(), gCycle::CalculatePredictPosition(), cCockpit::cb_Framerate(), gPlayerWall::Check(), eChatSpamTester::Check(), CheckLoop(), nSpamProtection::CheckSpam(), tPolynomial< T >::clamp(), eRectangle::Clamp(), ClampForward(), ClampMovement(), eRectangle::Clip(), eAxis::ComputeWinding(), ConnectToServerCore(), gCycleMovement::CopyFrom(), gNetPlayerWall::CopyIntoGrid(), eFace::CorrectArea(), cosf(), eFace::Create(), eLag::Credit(), eHalfEdge::CrossesNewWall(), gAIPlayer::CycleBlocksWay(), DecaySmooth(), Delay(), gAISensor::DetectLoop(), gLogo::Display(), eGrid::display_simple(), uMenuItem::DisplayText(), DisplayText(), gCycleChatBot::Distance(), gCycleMovement::DistanceToDestination(), eVoteItemHarm::DoCheckValid(), gCycleChatBot::Sensor::DoExtraDetectionStuff(), nServerInfo::DoQueryAll(), SwigDirector_GSimpleAI::DoThink(), gCycleMovement::DoTurn(), gCycle::DoTurn(), draw_eWall(), eGrid::DrawLine(), gParser::DrawRim(), gCycleExtrapolator::EdgeIsDangerous(), gAIPlayer::EmergencySurvive(), ePlayer::ePlayer(), tPolynomialWithBase< T >::evaluate(), tPolynomial< T >::evaluate(), expf(), exponent(), gCycle::Extrapolate(), fabsf(), nBandwidthArbitrator::Fill(), eGameObject::FindCurrentFace(), eHalfEdge::FindPath(), eGrid::FindSurroundingFace(), finite_xy_plane(), nQueryMessageStats::FloodProtection(), floorf(), rTextField::FlushLine(), tStatFile::flushWrites(), gAIPlayer::gAIPlayer(), gAISensor::gAISensor(), GameLoop(), gGame::GameLoop(), tRandomizer::Get(), gCycleMovement::GetDestinationBefore(), nServerInfo::GetFromLAN(), nServerInfo::GetFromMaster(), gCycleMovement::GetMaxSpaceAhead(), gZone::GetRadius(), nServerInfo::GetRandomMaster(), gArena::GetRandomPos(), zZone::GetScale(), gCycleMovement::GetTurnDelay(), gFloor::glFloorColor(), gPlayerWall::GlobalToLocal(), gSpark::gSpark(), gWallRim_helper(), gCycleChatBot::Sensor::HitWallExtends(), gNetPlayerWall::IndexAlpha(), infinity_xy_plane(), eAxis::Init(), init_exp(), gNetPlayerWall::InitArray(), eFace::Insideness(), gZone::InteractWith(), eHalfEdge::IntersectWith(), eHalfEdge::IntersectWithCareless(), gNetPlayerWall::IsDangerousAnywhere(), gNetPlayerWall::IsDangerousApartFromHoles(), zShapePolygon::isInside(), zShapeCircle::isInteracting(), gArena::LeastDangerousSpawnPoint(), gAICharacter::Load(), rModel::Load(), gPlayerWall::LocalToGlobal(), logf(), eCameraSensor::LookAround(), eWavData::Loop(), tPolynomialMarshaler< T >::marshal(), gCycleMovement::MaximalSpeed(), gCycle::MaxWallsLength(), MenuBackground(), uMenu::Message(), eWavData::Mix(), eGameObject::Move(), glRenderer::MultMatrix(), eCamera::MyInit(), gCycle::MyInitAfterCreation(), eAxis::NearestWinding(), zShape::networkRead(), eCamera::nextDirIfGlancing(), gCycleMovement::NextInterestingTime(), Vec3::Norm(), nWaitForAck::nWaitForAck(), nNetObject::Object(), nBandwidthArbitrator::OnChange(), gCycle::OnDropTempWall(), uMenu::OnEnter(), gCycle::OnNotifyNewDestination(), gTextureCycle::OnSelect(), gBaseZoneHack::OnVanish(), tCoord::GrahamComparator::operator()(), nMessage::operator<<(), operator>>(), nMessage::operator>>(), paint_sr_lowerSky(), tPolynomial< T >::parse(), gParser::parseObstacleWall(), gParser::parseWall(), gParser::parseWallLine(), gParser::parseWallRect(), gCycle::PassEdge(), eSensor::PassEdge(), eCameraSensor::PassEdge(), rViewport::Perspective(), gNetPlayerWall::Pos(), gCycle::PreparePredictPosition(), eGrid::ProcessWallsInRange(), ProcessWallsRecursive(), tStatFile::read(), gNetPlayerWall::ReadSync(), gCycle::ReadSync(), eTimer::ReadSync(), gNetPlayerWall::real_Update(), gNetPlayerWall::RealWallReceived(), floattest::ReceiveControl(), eNetGameObject::ReceiveControlNet(), ePlayerNetID::RemoveChatbots(), uMenuItemSelection< bool >::Render(), uMenuItemInput::Render(), zShapePolygon::render(), zShapeCircle::render(), gZone::Render(), gSpark::Render(), gExplosion::Render(), gCycle::Render(), rFont::Render(), rConsole::Render(), zShapePolygon::render2d(), zShapeCircle::render2d(), gZone::Render2D(), gExplosion::Render2D(), ArmageTron_color_menuitem::RenderBackground(), gNetPlayerWall::RenderBegin(), gNetPlayerWall::RenderList(), gCycle::RenderName(), gNetPlayerWall::RenderNormal(), gWallRim::RenderReal(), nServerLag::Report(), nClientLag::ReportLag(), gCycle::RequestSyncAll(), gCycle::RequestSyncOwner(), eTimer::Reset(), gAIPlayer::RightBeforeDeath(), rotate(), rTextField::rTextField(), S_BlowHoles(), s_Timestep(), se_Clamp(), se_Clip(), se_GetPing(), se_MakeColorValid(), se_receiveLagMessage(), se_SanifyDisplacement(), eChannel::Set3d(), tPolynomial< T >::setAtSameReferenceVarValue(), uMenuItem::SetColor(), gNetPlayerWall::SetEndPos(), gNetPlayerWall::SetEndTime(), gZone::SetExpansionSpeed(), gZone::SetRotationAcceleration(), gAIPlayer::SetTraceSide(), sg_CycleWallLengthFromDist(), sg_FullscreenMessage(), sg_Gap(), sg_GetSensor(), sg_RubberValues(), sg_TopologyPoliceCheck(), eHalfEdge::Simplify(), sinf(), sn_GetTimeout(), sn_SendPlanned1(), sn_Statistics(), sn_Sync(), SwigDirector_UMenuItemAction::SpaceRight(), gCycleMovement::Speed(), gWallRim::Split(), sqrtf(), sr_MotionBlur(), sr_MotionBlurCore(), st_GetDifference(), su_GetSDLInput(), su_InputSync(), su_TransformEvent(), sync_msg_handler(), gCycle::SyncEnemy(), gCycle::SyncFromExtrapolator(), gCycle::SyncIsNew(), gGame::SyncState(), eTimer::SyncTime(), nServerLag::TakeCredit(), tanf(), tDECLARE_REFOBJ(), gAIPlayer::Think(), gAIPlayer::ThinkCloseCombat(), gAIPlayer::ThinkPath(), gAIPlayer::ThinkSurvive(), gAIPlayer::ThinkTrace(), gCycle::ThisWallsLength(), gNetPlayerWall::Time(), eTimer::TimeNoSync(), gBaseZoneHack::Timestep(), gZone::Timestep(), gSpark::Timestep(), gGame::Timestep(), gExplosion::Timestep(), gCycleMovement::Timestep(), gCycle::Timestep(), gAIPlayer::Timestep(), eNetGameObject::Timestep(), nClientLag::Timestep(), eCamera::Timestep(), gCycleMovement::TimestepCore(), gCycle::TimestepCore(), eGameObject::TimestepThis(), eGameObject::TimestepThisWrapper(), tString::ToFloat(), gCycle::TransferPositionCorrectionToDistanceCorrection(), tPolynomial< T >::translate(), gJoystick::Turn(), gServerMenu::Update(), update_settings(), ePlayerNetID::UpdateName(), rViewport::UpDownFOV(), ePlayerNetID::WaitToLeaveChat(), gCycle::WallEndSpeed(), welcome(), gCycle::WriteSync(), eTimer::WriteSync(), xfunc(), and zShape::zShape().

#define TPOLYNOMIAL_DELIMITER   ';'

Referenced by tPolynomial< T >::parse().


Function Documentation

template<typename T>
bool operator!= ( const tPolynomial< T > &  left,
const tPolynomial< T > &  right 
) [inline]

Definition at line 299 of file tPolynomial.h.

00300 {
00301     return !(left == right);
00302 }

template<typename T>
T & operator<< ( T &  m,
tPolynomial< T > const &  f 
) [inline]

Parameters:
m message to write to
f function to write
Returns:
reference to message for chaining

Definition at line 214 of file tPolynomial.h.

00215 {
00216     // write ID for compatibility with future extensions
00217     unsigned short ID = 1;
00218     m.Write( ID );
00219 
00220     return f.WriteSync(m);
00221 }

template<typename T>
bool operator== ( const tPolynomial< T > &  left,
const tPolynomial< T > &  right 
) [inline]

function network message reading operator

Definition at line 251 of file tPolynomial.h.

References tPolynomial< T >::adaptToNewReferenceVarValue(), tPolynomial< T >::coefs, DELTA, MAX, MIN, and tPolynomial< T >::referenceVarValue.

00252 {
00253     tPolynomial<T> tRebasedRight;
00254 
00255     // Do both polynomial have the same baseValue?
00256     if (false == ( fabs(left.referenceVarValue - right.referenceVarValue) < DELTA)) {
00257         // Bring back both polynomial to the same baseValue for easy comparision
00258         tRebasedRight = right.adaptToNewReferenceVarValue(left.referenceVarValue);
00259     }
00260     else {
00261         // They have similar baseValue, no need to adjust.
00262         tRebasedRight = right;
00263     }
00264 
00265 
00266     // If the length of the coefs array differ, then the extra elements should be 0
00267     int maxLength = MAX(left.coefs.Len(), right.coefs.Len());
00268     int minLength = MIN(left.coefs.Len(), right.coefs.Len());
00269 
00270     bool res = true;
00271 
00272     // Inspect the common coefficients (ie defined for both polynomial)
00273     for (int i=0; i<minLength; i++) {
00274         if ( fabs(left[i] - tRebasedRight[i]) >= DELTA ) {
00275             res = false;
00276             break;
00277         }
00278     }
00279 
00280     for (int i=minLength; i<maxLength; i++) {
00281         // The polynomial that is defined up to that length should have its elements set to 0.0
00282         if (left.coefs.Len()>tRebasedRight.coefs.Len()) {
00283             if (fabs(left[i]) >= DELTA) {
00284                 res = false;
00285                 break;
00286             }
00287         }
00288         else {
00289             if (fabs(tRebasedRight[i]) >= DELTA) {
00290                 res = false;
00291                 break;
00292             }
00293         }
00294     }
00295     return res;
00296 }

Here is the call graph for this function:

template<typename T>
T & operator>> ( T &  m,
tPolynomial< T > &  f 
) [inline]

function network message writing operator

Parameters:
m message to read from
f function to read to
Returns:
reference to message for chaining

Definition at line 235 of file tPolynomial.h.

References nMessage::Read(), tPolynomial< T >::ReadSync(), and tASSERT.

00236 {
00237     // write ID for compatibility with future extensions
00238     unsigned short ID;
00239     m.Read(ID);
00240     tASSERT( ID == 1 ) ;
00241 
00242     return f.ReadSync(m);
00243 }

Here is the call graph for this function:


Generated on Sat Mar 15 23:12:12 2008 for Armagetron Advanced by  doxygen 1.5.4