<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Integration Basics</title>
	<atom:link href="http://gafferongames.com/game-physics/integration-basics/feed/" rel="self" type="application/rss+xml" />
	<link>http://gafferongames.com</link>
	<description>Glenn Fiedler&#039;s Game Development Articles and Tutorials</description>
	<lastBuildDate>Tue, 31 Jan 2012 03:56:23 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: stx</title>
		<link>http://gafferongames.com/game-physics/integration-basics/#comment-33646</link>
		<dc:creator>stx</dc:creator>
		<pubDate>Tue, 10 Jan 2012 15:51:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.gaffer.org/wordpress/integration-basics/#comment-33646</guid>
		<description>Thanks a lot for article :)
Everywhere on web there&#039;s only a lot of empty equations and theory with no easy-to-understand samples provided, thanks, now I fully understand RK4 ;)</description>
		<content:encoded><![CDATA[<p>Thanks a lot for article <img src='http://gafferongames.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Everywhere on web there&#8217;s only a lot of empty equations and theory with no easy-to-understand samples provided, thanks, now I fully understand RK4 <img src='http://gafferongames.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glenn Fiedler</title>
		<link>http://gafferongames.com/game-physics/integration-basics/#comment-27938</link>
		<dc:creator>Glenn Fiedler</dc:creator>
		<pubDate>Fri, 09 Dec 2011 08:07:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.gaffer.org/wordpress/integration-basics/#comment-27938</guid>
		<description>Yes</description>
		<content:encoded><![CDATA[<p>Yes</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glenn Fiedler</title>
		<link>http://gafferongames.com/game-physics/integration-basics/#comment-27937</link>
		<dc:creator>Glenn Fiedler</dc:creator>
		<pubDate>Fri, 09 Dec 2011 08:06:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.gaffer.org/wordpress/integration-basics/#comment-27937</guid>
		<description>Sounds about right but for particle simulations with lots of bodies you may find Verlet integration easier to implement. cheers</description>
		<content:encoded><![CDATA[<p>Sounds about right but for particle simulations with lots of bodies you may find Verlet integration easier to implement. cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glenn Fiedler</title>
		<link>http://gafferongames.com/game-physics/integration-basics/#comment-24105</link>
		<dc:creator>Glenn Fiedler</dc:creator>
		<pubDate>Tue, 08 Nov 2011 16:13:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.gaffer.org/wordpress/integration-basics/#comment-24105</guid>
		<description>That&#039;s just the default constructor. It&#039;s a C++ syntax that says, pass in a &quot;default&quot; version of the derivative object. In this case, I use that to pass in an initial derivative of zero.</description>
		<content:encoded><![CDATA[<p>That&#8217;s just the default constructor. It&#8217;s a C++ syntax that says, pass in a &#8220;default&#8221; version of the derivative object. In this case, I use that to pass in an initial derivative of zero.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bruce Croxall</title>
		<link>http://gafferongames.com/game-physics/integration-basics/#comment-23995</link>
		<dc:creator>Bruce Croxall</dc:creator>
		<pubDate>Mon, 07 Nov 2011 16:13:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.gaffer.org/wordpress/integration-basics/#comment-23995</guid>
		<description>I have the same question as Anonymous but likely just don&#039;t understand your response. In the &quot;integrate&quot; function, why is &quot;Derivative()&quot; being pass to the &quot;evaluate&quot; function to calculate &quot;a&quot;? I undestand that Derivative is a struct but it is seemingly being passed as a function. Is this a C++ specific thing?</description>
		<content:encoded><![CDATA[<p>I have the same question as Anonymous but likely just don&#8217;t understand your response. In the &#8220;integrate&#8221; function, why is &#8220;Derivative()&#8221; being pass to the &#8220;evaluate&#8221; function to calculate &#8220;a&#8221;? I undestand that Derivative is a struct but it is seemingly being passed as a function. Is this a C++ specific thing?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ScottB</title>
		<link>http://gafferongames.com/game-physics/integration-basics/#comment-19329</link>
		<dc:creator>ScottB</dc:creator>
		<pubDate>Sat, 10 Sep 2011 02:14:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.gaffer.org/wordpress/integration-basics/#comment-19329</guid>
		<description>Hi Glenn,

This article is great, especially having some code to mull and reuse! Thank you.

(Sorry for this long post)

I&#039;m doing a 3-space n-body gravitational sim and am starting to come to the unpleasant conclusion that with RK4 I&#039;m going to have to compute the effects due to all n bodies on each other all at once inside evaluate() and acceleration(), because I can&#039;t isolate the effects of each as I could with Euler or a modifed Euler. If I don&#039;t update all the bodies in each evaluate() call, I&#039;ll see the 2nd, 3rd, and 4th evaluate() calls start to accumulate excess error because the other body positions are stale. Your comment above for the damped spring:

&gt; you integrate both bodies together, ideally you have a single method that returns an array of forces to apply to the points — you cant update each body independently with RK4

seems to support this gloomy conclusion. In a high-gradient field, i.e. when near another massive body, this will become quite important I suspect. I&#039;ll have to fully compute updated state for each of the other n-1 bodies including  inside each of the 4 evaluate() calls in integrate(), much as you describe above for the spring case. So I end up doing them all at once.

evaluate() and accelerate() look like becoming much more complex, and computationally quite expensive for large n. integrate() will have some loops, but will not be especially troublesome, I believe.

I think the changes needed, in rough outline, are:

- turn State and Derivative into arrays[n] of structs, each struct containing 6 components (x, y, z, vx, vy, vz), with n being the number of bodies, and have caller pass states[] into integrate() along with t and dt, also making available masses[] and G somehow, maybe as parameters. More on integrate() later.

- accelerate() needs to compute G*mj/r^2 (to get acceleration mi on body bi) for each pair of bodies  with masses  and return the results in outputs[n]

- evaluate() needs to update all the elements of states[] with the initial.x + d.dx*dt and initial.vx + d.dv*dt computations for each of the 3 axes, initialize outputs[].dx, .dy, and.dz, then invoke acceleration() on states[], which will copy results to outputs[] for evaluate().

- integrate() needs to make the 4 calls to evaluate(), starting with a Derivatives[] initialized to {0.0, 0.0, 0.0, 0.0, 0.0, 0.0} in each array element. Then it can serially (at last, no parallel computations!) compute the dxdt, dydt, dzdt, dvxdt, dvydt, and dvzdt values for each array element and update that element&#039;s state. values.

Does this sound about right?</description>
		<content:encoded><![CDATA[<p>Hi Glenn,</p>
<p>This article is great, especially having some code to mull and reuse! Thank you.</p>
<p>(Sorry for this long post)</p>
<p>I&#8217;m doing a 3-space n-body gravitational sim and am starting to come to the unpleasant conclusion that with RK4 I&#8217;m going to have to compute the effects due to all n bodies on each other all at once inside evaluate() and acceleration(), because I can&#8217;t isolate the effects of each as I could with Euler or a modifed Euler. If I don&#8217;t update all the bodies in each evaluate() call, I&#8217;ll see the 2nd, 3rd, and 4th evaluate() calls start to accumulate excess error because the other body positions are stale. Your comment above for the damped spring:</p>
<p>&gt; you integrate both bodies together, ideally you have a single method that returns an array of forces to apply to the points — you cant update each body independently with RK4</p>
<p>seems to support this gloomy conclusion. In a high-gradient field, i.e. when near another massive body, this will become quite important I suspect. I&#8217;ll have to fully compute updated state for each of the other n-1 bodies including  inside each of the 4 evaluate() calls in integrate(), much as you describe above for the spring case. So I end up doing them all at once.</p>
<p>evaluate() and accelerate() look like becoming much more complex, and computationally quite expensive for large n. integrate() will have some loops, but will not be especially troublesome, I believe.</p>
<p>I think the changes needed, in rough outline, are:</p>
<p>- turn State and Derivative into arrays[n] of structs, each struct containing 6 components (x, y, z, vx, vy, vz), with n being the number of bodies, and have caller pass states[] into integrate() along with t and dt, also making available masses[] and G somehow, maybe as parameters. More on integrate() later.</p>
<p>- accelerate() needs to compute G*mj/r^2 (to get acceleration mi on body bi) for each pair of bodies  with masses  and return the results in outputs[n]</p>
<p>- evaluate() needs to update all the elements of states[] with the initial.x + d.dx*dt and initial.vx + d.dv*dt computations for each of the 3 axes, initialize outputs[].dx, .dy, and.dz, then invoke acceleration() on states[], which will copy results to outputs[] for evaluate().</p>
<p>- integrate() needs to make the 4 calls to evaluate(), starting with a Derivatives[] initialized to {0.0, 0.0, 0.0, 0.0, 0.0, 0.0} in each array element. Then it can serially (at last, no parallel computations!) compute the dxdt, dydt, dzdt, dvxdt, dvydt, and dvzdt values for each array element and update that element&#8217;s state. values.</p>
<p>Does this sound about right?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nitin</title>
		<link>http://gafferongames.com/game-physics/integration-basics/#comment-15201</link>
		<dc:creator>nitin</dc:creator>
		<pubDate>Thu, 14 Jul 2011 14:24:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.gaffer.org/wordpress/integration-basics/#comment-15201</guid>
		<description>really fantastic</description>
		<content:encoded><![CDATA[<p>really fantastic</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://gafferongames.com/game-physics/integration-basics/#comment-14527</link>
		<dc:creator>John</dc:creator>
		<pubDate>Fri, 01 Jul 2011 14:00:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.gaffer.org/wordpress/integration-basics/#comment-14527</guid>
		<description>Fantastic explanation!
Thank you so much.

Greetings from Germany</description>
		<content:encoded><![CDATA[<p>Fantastic explanation!<br />
Thank you so much.</p>
<p>Greetings from Germany</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SHiNKiROU</title>
		<link>http://gafferongames.com/game-physics/integration-basics/#comment-13720</link>
		<dc:creator>SHiNKiROU</dc:creator>
		<pubDate>Wed, 15 Jun 2011 03:46:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.gaffer.org/wordpress/integration-basics/#comment-13720</guid>
		<description>A visual explanation of Euler and RK4 http://www.youtube.com/watch?v=LbKKzMag5Rc</description>
		<content:encoded><![CDATA[<p>A visual explanation of Euler and RK4 <a href="http://www.youtube.com/watch?v=LbKKzMag5Rc" rel="nofollow">http://www.youtube.com/watch?v=LbKKzMag5Rc</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glenn Fiedler</title>
		<link>http://gafferongames.com/game-physics/integration-basics/#comment-10615</link>
		<dc:creator>Glenn Fiedler</dc:creator>
		<pubDate>Tue, 12 Apr 2011 23:56:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.gaffer.org/wordpress/integration-basics/#comment-10615</guid>
		<description>Generally you do 4 RK4 steps for every &quot;real&quot; physics step each frame. This is the bit you are missing! This also makes RK4 pretty expensive in real world situations so you&#039;d want to try a few other integrators first, I think. cheers</description>
		<content:encoded><![CDATA[<p>Generally you do 4 RK4 steps for every &#8220;real&#8221; physics step each frame. This is the bit you are missing! This also makes RK4 pretty expensive in real world situations so you&#8217;d want to try a few other integrators first, I think. cheers</p>
]]></content:encoded>
	</item>
</channel>
</rss>

