Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

MidpointSolver.cpp

00001 /*************************************************************************** 00002 * This file is part of OpenCAL: Open Computer Animation Library * 00003 * I created OpenCAL as my master's thesis Computer Science (multimedia) * 00004 * at the tUL university in Diepenbeek, Belgium * 00005 * * 00006 * Copyright (C) 2003-2004 by Jeroen Dierckx * 00007 * jeroen.dierckx@student.luc.ac.be * 00008 * * 00009 ***************************************************************************/ 00010 00011 // Includes 00012 #include "MidpointSolver.h" 00013 #include <OpenCAL/ODESource.h> 00014 using namespace OpenCAL; 00015 00016 using namespace std; 00017 00018 00019 /****************************** 00020 * Constructors and destructor * 00021 ******************************/ 00022 00023 MidpointSolver::MidpointSolver() 00024 { 00025 } 00026 00027 MidpointSolver::~MidpointSolver() 00028 { 00029 } 00030 00031 00032 /****************** 00033 * Other functions * 00034 ******************/ 00035 00041 void MidpointSolver::solve(float stepSize, ODESource *source) 00042 { 00043 source->fillState(); 00044 source->fillDerivative(); 00045 00046 PhaseSpace &state = *(source->getState()); 00047 PhaseSpace &deriv = *(source->getDerivative()); 00048 00049 // Copy the original state 00050 PhaseSpace x0 = state; 00051 00052 // First, evaluate an Euler step at half the stepSize 00053 state.add(deriv, stepSize * 0.5f); 00054 00055 // Recalculate the derivative 00056 source->fromState(); 00057 source->fillDerivative(); 00058 00059 // Then, take a step using these values 00060 state = x0; 00061 state.add(deriv, stepSize); 00062 00063 source->fromState(); 00064 }

Generated on Sun Aug 15 19:19:22 2004 for OpenCAL: Open Computer Animation Library by doxygen 1.3.8