<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Nerd Alert</title>
	<atom:link href="http://gertcant.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://gertcant.wordpress.com</link>
	<description>Allerlei begrippen i.v.m. programmeren, in begrijpelijk Nederlands</description>
	<lastBuildDate>Sun, 06 Feb 2011 20:54:41 +0000</lastBuildDate>
	<language>nl</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='gertcant.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Nerd Alert</title>
		<link>http://gertcant.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://gertcant.wordpress.com/osd.xml" title="Nerd Alert" />
	<atom:link rel='hub' href='http://gertcant.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Polyformisme in ActionScript 2</title>
		<link>http://gertcant.wordpress.com/2008/02/19/polyformisme-in-actionscript-2/</link>
		<comments>http://gertcant.wordpress.com/2008/02/19/polyformisme-in-actionscript-2/#comments</comments>
		<pubDate>Tue, 19 Feb 2008 10:41:03 +0000</pubDate>
		<dc:creator>gert</dc:creator>
				<category><![CDATA[Actionscript2]]></category>
		<category><![CDATA[Object Oriented]]></category>
		<category><![CDATA[programmeertechnieken]]></category>

		<guid isPermaLink="false">http://gertcant.wordpress.com/?p=35</guid>
		<description><![CDATA[ActionScript ondersteunt ook polyformisme, zij het in een eenvoudiger vorm dan in programmeertalen als Java bvb. Dit voorbeeld maak ik in FlashDevelop 3 beta 6. Wat is polyformisme? Polyformisme is één van de belangrijkste pijlers van OO programmeren. Het is een toepassing van overerving, waarbij dezelfde methode in de superklasse en de subklassen, een andere [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gertcant.wordpress.com&amp;blog=1456202&amp;post=35&amp;subd=gertcant&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>ActionScript ondersteunt ook polyformisme, zij het in een eenvoudiger vorm dan in programmeertalen als Java bvb.</p>
<p>Dit voorbeeld maak ik in <i>FlashDevelop 3 beta 6.</i></p>
<h2>Wat is polyformisme?</h2>
<p>Polyformisme is één van de belangrijkste pijlers van OO programmeren. Het is een toepassing van <i>overerving</i>, waarbij dezelfde methode in de superklasse en de subklassen, een andere implementatie krijgen.</p>
<h3>Overerving</h3>
<p>Ik maak twee testklassen.</p>
<blockquote><p>class Class1 {<br />
public function talk():Void {<br />
trace(&#8220;Hello world 1&#8243;) ;<br />
}<br />
}</p>
<p>class Class2 extends Class1 {<br />
public function count():Void {<br />
trace(&#8220;2&#8243;)<br />
}<br />
}</p></blockquote>
<p>Class2 overerft Class1 en voegt een count() functie toe.</p>
<p>De Application klasse zal Class1 en Class2 implementeren. Let op de static functie &#8216;main() &#8216; (! case-sensitive). Default zal FlashDevelop deze functie gebruiken als startpunt voor de swf. Je hebt dan geen Flash IDE nodig.</p>
<blockquote><p>class Application {<br />
public static function main() {<br />
var c1_1:Class1 = new Class1()<br />
c1_1.talk() ;</p>
<p>var c2_2:Class2 = new Class2()<br />
c2_2.talk() ;<br />
c2_2.count() ;<br />
}<br />
}</p></blockquote>
<p>We testen de movie en krijgen de volgende output:</p>
<blockquote><p>Hello world 1<br />
Hello world 1<br />
2</p></blockquote>
<p>Class2 gebruikt de functie talk() die geïmplementeerd is in Class1. Als je met overerving werkt, moet je dus niet alleen de functies kennen van de klasse waarin je werkt, maar ook van al de superklassen. Een goede IDE als FlashDevelop zal je snel naar deze functies leiden (via F4).</p>
<h3>Een functie overschrijven</h3>
<p>Je kan nu in Class2 de functie &#8216;talk()&#8217; van de superklasse, overschrijven en op een andere manier implementeren.</p>
<blockquote><p>class Class2 extends Class1 {<br />
public function count():Void {<br />
trace(&#8220;2&#8243;)<br />
}<br />
public function talk():Void {<br />
trace(&#8220;Hello world 2&#8243;) ;<br />
}<br />
}</p></blockquote>
<p>We testen de movie. De output is nu:</p>
<blockquote><p>Hello world 1<br />
Hello world<b> 2</b><br />
2</p></blockquote>
<h3>Polyformisme</h3>
<p>Afhankelijk van de implementatie, kan een object van een bepaald datatype, zich &#8216;anders&#8217; gedragen. Voeg de volgende regels toe aan de Application klasse:</p>
<blockquote><p>var c2_1:Class1 = new Class2()<br />
c2_1.talk() ;</p></blockquote>
<p>Wat zal de output nu zij, &#8220;Hello world 1&#8243; of &#8220;Hello world 2&#8243;? We testen de movie.</p>
<blockquote><p>Hello world 1<br />
Hello world 2<br />
2<br />
<b>Hello world 2 </b></p></blockquote>
<p>c2_1 wordt gedeclareerd als van het datatype Class1, maar geïnstantieerd met Class2.</p>
<p>Omdat Class1 een Class2 is (zie bovenstaande regels), is dit geldig. De compiler genereert geen fout.<i> At runtime</i>, zal c2_1 een object toegewezen krijgen van het datatype Class2 en de implementatie van de functie &#8216;talk&#8217; van de klasse Class2 uitvoeren.</p>
<h3>Opmerking i.v.m. overerving</h3>
<p><i>Overerving </i>van klassen is essentieel binnen OO programmeren. Maar wordt meestal te snel toegepast, zodat je aan flexibiliteit inboet. Je mag pas een klasse overerven, indien de subklasse voldoet aan de volgende 2 eenvoudige, maar zeer belangrijke regels:</p>
<ol>
<li>De subklasse voldoet aan de &#8220;<b>is een&#8230;</b>&#8220;-regel. Bvb. een student is een persoon.</li>
<li>De subklasse implementeert <b>alle </b>functies van de superklasse waarvan ze wil overerven.</li>
</ol>
<p>In alle ander gevallen dient <i>compositie </i>i.p.v. overerving gebruikt te worden. Overerving is zeer verlijderlijk omdat het initieel (type)werk bespaart, maar het wordt moeilijker om terug te vinden, welke klasse een bepaalde functie implementeert.</p>
<blockquote><p>In ActionScript wordt er &#8211; naar mijn mening &#8211; veel te snel een MovieClip overgeërft en daarmee gezondigd tegen bovenstaande regels (vooral de eerste). Ik zal voor het gebruik van een MovieClip in een klasse, altijd compositie gebruiken, waarbij ik meestal de MovieClip meegeef in de constructor.</p></blockquote>
<h3>Besluit</h3>
<p>Met polyformisme wordt bedoeld dat een bepaald datatype, zich kan &#8216;gedragen&#8217; als een datatype van de subklassen, omdat deze subklassen een functie van de superklasse anders implementeren.</p>
<blockquote>
<blockquote></blockquote>
</blockquote>
<blockquote></blockquote>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gertcant.wordpress.com/35/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gertcant.wordpress.com/35/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gertcant.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gertcant.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gertcant.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gertcant.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gertcant.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gertcant.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gertcant.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gertcant.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gertcant.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gertcant.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gertcant.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gertcant.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gertcant.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gertcant.wordpress.com/35/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gertcant.wordpress.com&amp;blog=1456202&amp;post=35&amp;subd=gertcant&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gertcant.wordpress.com/2008/02/19/polyformisme-in-actionscript-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b767aba3f1c06a7901322477a5c4c73a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gert</media:title>
		</media:content>
	</item>
		<item>
		<title>Expressies, wat zijn het?</title>
		<link>http://gertcant.wordpress.com/2008/02/16/expressies-wat-zijn-het/</link>
		<comments>http://gertcant.wordpress.com/2008/02/16/expressies-wat-zijn-het/#comments</comments>
		<pubDate>Sat, 16 Feb 2008 18:59:33 +0000</pubDate>
		<dc:creator>gert</dc:creator>
				<category><![CDATA[programmeertechnieken]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://gertcant.wordpress.com/?p=34</guid>
		<description><![CDATA[Wat is een expressie? Een expressie is een verwijzing naar een waarde. vb.: dim s as String &#8216;Dit is geen expressie, maar een initialisatie. s = &#8220;Hello Word&#8221; &#8216;Dit zijn 2 expressies s is een expressie. Inderdaad, het verwijst naar een waarde. s = &#8220;Hello World&#8221; is ook expressie. Het toekennen van een waarde is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gertcant.wordpress.com&amp;blog=1456202&amp;post=34&amp;subd=gertcant&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>Wat is een expressie?</h3>
<p>Een  expressie is een verwijzing naar een waarde.</p>
<h5>vb.:</h5>
<blockquote><p>dim  s as String &#8216;Dit is geen expressie, maar een initialisatie.<br />
s = &#8220;Hello Word&#8221; &#8216;Dit zijn 2 expressies</p></blockquote>
<ol>
<li>s is een expressie. Inderdaad, het verwijst naar een waarde.</li>
<li>s = &#8220;Hello World&#8221; is ook expressie. Het toekennen van een waarde is zowiezo een expressie.</li>
</ol>
<h5>Vb.:</h5>
<p>Dim s As Persoon = new Student()</p>
<p>Dit zijn 3 expressies</p>
<ol>
<li>new Persoon() verwijst naar een Persoon object</li>
<li>= new Persoon() is een toekenning</li>
<li>s verwijst naar een Student object</li>
</ol>
<h5>Vb.:</h5>
<p>a &lt; b &#8216;een booleaanse expressie.<br />
a = 5 &#8216;een integer expressie<br />
a = &#8220;yo de manne&#8221; &#8216;een string expressie</p>
<p>enz.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gertcant.wordpress.com/34/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gertcant.wordpress.com/34/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gertcant.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gertcant.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gertcant.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gertcant.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gertcant.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gertcant.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gertcant.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gertcant.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gertcant.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gertcant.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gertcant.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gertcant.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gertcant.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gertcant.wordpress.com/34/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gertcant.wordpress.com&amp;blog=1456202&amp;post=34&amp;subd=gertcant&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gertcant.wordpress.com/2008/02/16/expressies-wat-zijn-het/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b767aba3f1c06a7901322477a5c4c73a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gert</media:title>
		</media:content>
	</item>
		<item>
		<title>Arguments van function</title>
		<link>http://gertcant.wordpress.com/2008/02/07/arguments-van-function/</link>
		<comments>http://gertcant.wordpress.com/2008/02/07/arguments-van-function/#comments</comments>
		<pubDate>Thu, 07 Feb 2008 13:50:57 +0000</pubDate>
		<dc:creator>gert</dc:creator>
				<category><![CDATA[Actionscript2]]></category>

		<guid isPermaLink="false">http://gertcant.wordpress.com/?p=32</guid>
		<description><![CDATA[Het keyword arguments Je weet niet altijd op voorhand hoeveel parameters je moet voorzien in een functie. Alle argumenten van een functie worden bijgehouden in de array arguments van die functie, een gereserveerd keyword. Voorbeeld: het gemiddelde berekenen van een aantal getallen trace(gemiddelde(1,2,3,4,5,6,7)) function gemiddelde() : Number{ var som:Number = 0; for (var i:Number = [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gertcant.wordpress.com&amp;blog=1456202&amp;post=32&amp;subd=gertcant&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>Het keyword arguments</h3>
<p>Je weet niet altijd op voorhand hoeveel parameters je moet voorzien in een functie.</p>
<p>Alle argumenten van een functie worden bijgehouden in de array <i>arguments </i>van die functie, een gereserveerd keyword.</p>
<h3>Voorbeeld: het gemiddelde berekenen van een aantal getallen</h3>
<blockquote><p>trace(gemiddelde(1,2,3,4,5,6,7))</p>
<p>function gemiddelde() : Number{<br />
var som:Number = 0;<br />
for (var i:Number = 0; i &lt; arguments.length; i++) {<br />
som += arguments[i];<br />
}<br />
return som / arguments.length ;<br />
}</p></blockquote>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gertcant.wordpress.com/32/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gertcant.wordpress.com/32/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gertcant.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gertcant.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gertcant.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gertcant.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gertcant.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gertcant.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gertcant.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gertcant.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gertcant.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gertcant.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gertcant.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gertcant.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gertcant.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gertcant.wordpress.com/32/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gertcant.wordpress.com&amp;blog=1456202&amp;post=32&amp;subd=gertcant&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gertcant.wordpress.com/2008/02/07/arguments-van-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b767aba3f1c06a7901322477a5c4c73a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gert</media:title>
		</media:content>
	</item>
		<item>
		<title>Circle- circle collision detection</title>
		<link>http://gertcant.wordpress.com/2008/02/07/circle-circle-collision-detection/</link>
		<comments>http://gertcant.wordpress.com/2008/02/07/circle-circle-collision-detection/#comments</comments>
		<pubDate>Thu, 07 Feb 2008 11:50:42 +0000</pubDate>
		<dc:creator>gert</dc:creator>
				<category><![CDATA[Collision detection]]></category>

		<guid isPermaLink="false">http://gertcant.wordpress.com/?p=30</guid>
		<description><![CDATA[Een botsing tussen twee cirkels detecteren, is niet zo eenvoudig. Het vraagt een goede basis van Wiskunde. Even diep ademhalen&#8230; daar gaan we. Doel We berekenen of er een botsing zal optreden tussen twee cirkels, na een bepaalde tijd, in memory. Daarvoor hebben we nodig: de plaats van de cirkels: x1, y1, x2, y2 de [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gertcant.wordpress.com&amp;blog=1456202&amp;post=30&amp;subd=gertcant&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Een botsing tussen twee cirkels detecteren, is niet zo eenvoudig. Het vraagt een goede basis van Wiskunde. Even diep ademhalen&#8230; daar gaan we.</p>
<h3>Doel</h3>
<p>We berekenen of er een botsing zal optreden tussen twee  cirkels, na een bepaalde tijd, in memory. Daarvoor hebben we nodig:</p>
<ul>
<li>de plaats van de cirkels: x1, y1, x2, y2</li>
<li>de snelheid waarmee ze bewegen: x1Mov, y1Mov, x2Mov, y2Mov</li>
<li>de tijd waarnaar we rekenen: t</li>
</ul>
<h3>Wanneer is er een botsing?</h3>
<p><i>Twee cirkels botsen als de som van hun stralen kleiner of gelijk is aan de afstand tussen de cirkels.</i></p>
<div align="left">
<blockquote><p> <a href="http://gertcant.files.wordpress.com/2008/02/circle-circle-collision.gif" title="circle-circle-collision.gif"><img src="http://gertcant.files.wordpress.com/2008/02/circle-circle-collision.gif?w=500" alt="circle-circle-collision.gif" /></a></p></blockquote>
</div>
<h3> We berekenen</h3>
<blockquote><p>snelheid = afstand / tijd<br />
afstand = snelheid * tijd</p></blockquote>
<p>x1 = xo1 + x1Mov * t<i> -&gt; xo1 is de oude x1</i><br />
y1 = yo1 + y1Mov * t<br />
x2 = xo2 + x2Mov * t<br />
y2 = yo2 + y2Mov * t</p>
<p>afstand = Math.sqrt((x1 &#8211; x2)² + (y1 &#8211; y2)²)   <i>-&gt;  Pythagoras</i><br />
afstand = R1 + R2 = d  <i>-&gt;  zie tekening</i></p>
<p>d² = (x1 &#8211; x2)² + (y1 &#8211; y2)²<br />
d² = x1² &#8211; 2*x1*x2 + x2² + y1² &#8211; 2*y1*y2 + y2²</p>
<h4><i>De afstand berekenen na een bepaalde tijd</i><i> </i></h4>
<p>x1² =  ( xo1 + x1Mov * t)²<br />
x1² = xo1² + 2*xo1*x1Mov * t + x1Mov²*t²</p>
<p>-2*x1*x2 = -2*(xo1 + x1Mov * t)*(xo2 + x2Mov * t)<br />
-2*x1*x2 = -2*(xo1*xo2 + xo1*x2Mov*t + x1Mov*t*xo2 + x1Mov*x2Mov*t²)<br />
-2*x1*x2 = (-2* x1Mov*x2Mov)*t² + (-2*xo1*x2Mov -2*xo2* x1Mov) *t &#8211; 2*xo1*xo2</p>
<p>x2² =  ( xo2 + x2Mov * t)²<br />
x2² = xo2² + 2*xo2*x2Mov * t + x2Mov²*t²</p>
<p>y1² =  ( yo1 + y1Mov * t)²<br />
y1² = yo1² + 2*yo1*y1Mov * t + y1Mov²*t²</p>
<p>-2*y1*y2 = -2*(yo1 + y1Mov * t)*(yo2 + y2Mov * t)<br />
-2*y1*y2 = -2*(yo1*yo2 + yo1*y2Mov*t + y1Mov*t*yo2 + y1Mov*y2Mov*t²)<br />
-2*y1*y2 = (-2* y1Mov*y2Mov)*t² + (-2*yo1*y2Mov -2*yo2* y1Mov) *t &#8211; 2*yo1*yo2</p>
<p>y2² =  ( yo2 + y2Mov * t)²<br />
y2² = yo2² + 2*yo2*y2Mov * t + y2Mov²*t²</p>
<h4>We vereenvoudigen door constanten in te voegen</h4>
<p>Om tot een kwadratische functie te komen, voegen we de factoren van t² en t, samen.</p>
<p><b>Voor x </b></p>
<p>ax = x1Mov² -2* x1Mov*x2Mov + x2Mov² <i>-&gt; t²</i><br />
bx = 2*xo1*x1Mov -2*xo1*x2Mov -2*xo2* x1Mov + 2*xo2*x2Mov <i>-&gt; t</i><br />
cx = xo1² &#8211; 2*xo1*xo2 +  xo2² <i>-&gt; geen t</i></p>
<p><b>Voor y</b></p>
<p>ay = y1Mov² -2* y1Mov*y2Mov + y2Mov² <i>-&gt; t²</i><br />
by = 2*yo1*y1Mov -2*yo1*y2Mov -2*yo2* y1Mov + 2*yo2*y2Mov <i>-&gt; t</i><br />
cy = yo1² &#8211; 2*yo1*yo2 +  yo2² <i>-&gt; geen t</i></p>
<p><b>x en y samentellen </b></p>
<p>a = ax + ay<br />
b = bx + by<br />
c = cx + cy &#8211; d² (zie hoger)</p>
<h4>Alles samenvoegen</h4>
<p>a*t² + b*t + c = 0</p>
<h3>Berekenen van de tijd</h3>
<p>Met deze <a href="http://nl.wikipedia.org/wiki/Kwadratische_vergelijking" target="_blank">kwadratische </a>vergelijking kunnen we de tijd berekenen, nadat een bepaalde afstand is afgelegd.</p>
<p>t =  -b +/- Math.sqrt(b² &#8211; 4ac)/2a</p>
<p>Dit levert 2 oplossingen op. Inderdaad, als twee cirkels naar elkaar toe bewegen, zullen ze exact 2 maal raken: als ze elkaar tegenkomen en als ze elkaar verlaten.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gertcant.wordpress.com/30/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gertcant.wordpress.com/30/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gertcant.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gertcant.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gertcant.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gertcant.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gertcant.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gertcant.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gertcant.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gertcant.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gertcant.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gertcant.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gertcant.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gertcant.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gertcant.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gertcant.wordpress.com/30/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gertcant.wordpress.com&amp;blog=1456202&amp;post=30&amp;subd=gertcant&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gertcant.wordpress.com/2008/02/07/circle-circle-collision-detection/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b767aba3f1c06a7901322477a5c4c73a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gert</media:title>
		</media:content>

		<media:content url="http://gertcant.files.wordpress.com/2008/02/circle-circle-collision.gif" medium="image">
			<media:title type="html">circle-circle-collision.gif</media:title>
		</media:content>
	</item>
		<item>
		<title>Wrijving, niet correct, maar wel voldoende</title>
		<link>http://gertcant.wordpress.com/2008/02/06/wrijving-niet-correct-maar-wel-voldoende/</link>
		<comments>http://gertcant.wordpress.com/2008/02/06/wrijving-niet-correct-maar-wel-voldoende/#comments</comments>
		<pubDate>Wed, 06 Feb 2008 16:46:02 +0000</pubDate>
		<dc:creator>gert</dc:creator>
				<category><![CDATA[Actionscript2]]></category>
		<category><![CDATA[Game physics]]></category>

		<guid isPermaLink="false">http://gertcant.wordpress.com/?p=29</guid>
		<description><![CDATA[In de meeste gevallen zien correcte wrijvingsberekeningen een beetje overkill. Het onderstaande script ziet er ook goed uit en is eenvoudiger (KISS). Het script var xMov:Number = 15; var wrijving:Number = 0.95 ; onEnterFrame = function () { xMov *= wrijving ; bal_mc._x += xMov; };<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gertcant.wordpress.com&amp;blog=1456202&amp;post=29&amp;subd=gertcant&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In de meeste gevallen zien correcte wrijvingsberekeningen een beetje overkill. Het onderstaande script ziet er ook goed uit en is eenvoudiger (KISS).</p>
<h3>Het script</h3>
<blockquote><p>var xMov:Number = 15;<br />
var wrijving:Number = 0.95 ;</p>
<p>onEnterFrame = function () {<br />
xMov *= wrijving ;<br />
bal_mc._x += xMov;<br />
};</p></blockquote>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gertcant.wordpress.com/29/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gertcant.wordpress.com/29/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gertcant.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gertcant.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gertcant.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gertcant.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gertcant.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gertcant.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gertcant.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gertcant.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gertcant.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gertcant.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gertcant.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gertcant.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gertcant.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gertcant.wordpress.com/29/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gertcant.wordpress.com&amp;blog=1456202&amp;post=29&amp;subd=gertcant&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gertcant.wordpress.com/2008/02/06/wrijving-niet-correct-maar-wel-voldoende/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b767aba3f1c06a7901322477a5c4c73a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gert</media:title>
		</media:content>
	</item>
		<item>
		<title>Wrijving</title>
		<link>http://gertcant.wordpress.com/2008/02/06/wrijving/</link>
		<comments>http://gertcant.wordpress.com/2008/02/06/wrijving/#comments</comments>
		<pubDate>Wed, 06 Feb 2008 16:40:54 +0000</pubDate>
		<dc:creator>gert</dc:creator>
				<category><![CDATA[Actionscript2]]></category>
		<category><![CDATA[Game physics]]></category>

		<guid isPermaLink="false">http://gertcant.wordpress.com/?p=28</guid>
		<description><![CDATA[Als objecten de neiging te hebben om in hun toestand te blijven (eeuwig te blijven voortbewegen bvb.), waarom vallen ze dan stil? Wrijving! Wrijving Objecten verliezen energie in de vorm van warmte omdat ze in contact staan met een ander object. Bvb.: als je koude handen hebt, dan wrijf je ze over elkaar en ze [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gertcant.wordpress.com&amp;blog=1456202&amp;post=28&amp;subd=gertcant&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Als objecten de neiging te hebben om in hun toestand te blijven (eeuwig te blijven voortbewegen bvb.), waarom vallen ze dan stil? Wrijving!</p>
<h3>Wrijving</h3>
<p>Objecten verliezen energie in de vorm van warmte omdat ze in contact staan met een ander object.<br />
Bvb.: als je koude handen hebt, dan wrijf je ze over elkaar en ze worden warm.<br />
Wrijving is een kracht in de tegenovergestelde richting van het object.</p>
<h3>De formule</h3>
<p><i>F = u * massa * zwaartekracht </i></p>
<p>u is hier de coëfficiënt van de wrijving van een bepaald materiaal. Het is steeds een getal tussen 0 en 1. Bvb.: ijs heeft een wrijvingscoëfficiënt van 0.01, terwijl hout een wrijvingscoëfficiënt van 0.2 kan hebben.</p>
<p>Om te berekenen hoeveel de wrijving een bepaald object vertraagt, rekenen we uit:</p>
<blockquote><p>F = m * a = u * m * zwaartekracht<br />
a = u * zwaartekracht</p></blockquote>
<h3>De code</h3>
<blockquote><p>var xMov:Number = 15;<br />
var zwaartekracht:Number = 2;<br />
var u:Number = 0.2;<br />
var a:Number = u * zwaartekracht;<br />
//<br />
onEnterFrame = function () {<br />
xMov -= a;<br />
trace(xMov)<br />
if (xMov &lt;= 0) {<br />
delete onEnterFrame;<br />
}<br />
bal_mc._x += xMov;<br />
};</p></blockquote>
<p><a href="http://gertcant.wordpress.com/2008/02/06/wrijving-niet-correct-maar-wel-voldoende/">Zie ook </a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gertcant.wordpress.com/28/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gertcant.wordpress.com/28/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gertcant.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gertcant.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gertcant.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gertcant.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gertcant.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gertcant.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gertcant.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gertcant.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gertcant.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gertcant.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gertcant.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gertcant.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gertcant.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gertcant.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gertcant.wordpress.com&amp;blog=1456202&amp;post=28&amp;subd=gertcant&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gertcant.wordpress.com/2008/02/06/wrijving/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b767aba3f1c06a7901322477a5c4c73a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gert</media:title>
		</media:content>
	</item>
		<item>
		<title>Zwaartekracht, niet correct, maar voldoende</title>
		<link>http://gertcant.wordpress.com/2008/02/06/zwaartekracht-niet-correct-maar-voldoende/</link>
		<comments>http://gertcant.wordpress.com/2008/02/06/zwaartekracht-niet-correct-maar-voldoende/#comments</comments>
		<pubDate>Wed, 06 Feb 2008 16:05:47 +0000</pubDate>
		<dc:creator>gert</dc:creator>
				<category><![CDATA[Actionscript2]]></category>
		<category><![CDATA[Game physics]]></category>

		<guid isPermaLink="false">http://gertcant.wordpress.com/?p=27</guid>
		<description><![CDATA[In veel gevallen is het niet nodig om de wetten van Newton toe te passen. Als je game zich gewoon op de grond bevindt, kan je voor de zwaartekracht eenvoudig een constante gebruiken, waarmee je de beweging over de y-as verhoogd. Een voorbeeld var yMov:Number = 0; var zwaartekracht:Number = 2; // onEnterFrame = function [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gertcant.wordpress.com&amp;blog=1456202&amp;post=27&amp;subd=gertcant&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In veel gevallen is het niet nodig om de wetten van Newton toe te passen. Als je game zich gewoon op de grond bevindt, kan je voor de zwaartekracht eenvoudig een constante gebruiken, waarmee je de beweging over de y-as verhoogd.</p>
<h3>Een voorbeeld</h3>
<p>var yMov:Number = 0;<br />
var zwaartekracht:Number = 2;<br />
//<br />
onEnterFrame = function () {<br />
yMov += zwaartekracht;<br />
bal_mc._y += yMov;<br />
if (bal_mc._y &gt; Stage.height &#8211; bal_mc._height / 2) {<br />
yMov *= -1;<br />
}<br />
};</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gertcant.wordpress.com/27/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gertcant.wordpress.com/27/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gertcant.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gertcant.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gertcant.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gertcant.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gertcant.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gertcant.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gertcant.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gertcant.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gertcant.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gertcant.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gertcant.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gertcant.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gertcant.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gertcant.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gertcant.wordpress.com&amp;blog=1456202&amp;post=27&amp;subd=gertcant&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gertcant.wordpress.com/2008/02/06/zwaartekracht-niet-correct-maar-voldoende/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b767aba3f1c06a7901322477a5c4c73a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gert</media:title>
		</media:content>
	</item>
		<item>
		<title>Zwaartekracht Correct</title>
		<link>http://gertcant.wordpress.com/2008/02/06/zwaartekracht/</link>
		<comments>http://gertcant.wordpress.com/2008/02/06/zwaartekracht/#comments</comments>
		<pubDate>Wed, 06 Feb 2008 15:54:38 +0000</pubDate>
		<dc:creator>gert</dc:creator>
				<category><![CDATA[Actionscript2]]></category>
		<category><![CDATA[Game physics]]></category>

		<guid isPermaLink="false">http://gertcant.wordpress.com/?p=26</guid>
		<description><![CDATA[Zwaartekracht zal het realiteitsgehalte van je game sterk verhogen. Hieronder vind je de correcte berekening. In veel gevallen voldoet een simpel truukje. De formule We gebruiken de volgende formule om de aantrekkingskracht tussen twee objecten te berekenen: F = G * (massa1 * massa2) / afstand² G is hier de gravitale constante. Onze games zullen [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gertcant.wordpress.com&amp;blog=1456202&amp;post=26&amp;subd=gertcant&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Zwaartekracht zal het realiteitsgehalte van je game sterk verhogen. Hieronder vind je de correcte berekening.</p>
<p>In veel gevallen voldoet een <a href="http://gertcant.wordpress.com/2008/02/06/zwaartekracht-niet-correct-maar-voldoende/">simpel truukje</a>.</p>
<h3>De formule</h3>
<p>We gebruiken de volgende formule om de aantrekkingskracht tussen twee objecten te berekenen:</p>
<blockquote><p>F = G * (massa1 * massa2) / afstand²</p></blockquote>
<p>G is hier de <a href="http://en.wikipedia.org/wiki/Gravitational_constant" target="_blank">gravitale constante</a>. Onze games zullen er niet onder lijden indien we deze constante gelijk stellen met 1, of een andere waarde om de presentatie te verbeteren.</p>
<h3>Een voorbeeld</h3>
<p>// teken 3 planeten op de stage en plaats ze in een MovieClip<br />
aarde_mc.massa = 60;<br />
maan_mc.massa = 10;<br />
mars_mc.massa = 20;<br />
var planeten:Array = new Array(aarde_mc, maan_mc, mars_mc);<br />
// de graviteitsconstante (fictief)<br />
var G:Number = 200;<br />
//<br />
function animate() {<br />
var len:Number = planeten.length;<br />
for (var i:Number = 0; i &lt; len ; i++) {<br />
for (var j:Number = 0; j &lt; len; j++) {<br />
if (i == j) {<br />
continue; // planeten niet t.o.v. zichzelf berekenen<br />
}<br />
var distance:Number = Math.sqrt(Math.pow(planeten[i]._x &#8211; planeten[j]._x, 2) + Math.pow(planeten[i]._y &#8211; planeten[j]._y, 2));<br />
var F:Number = G * planeten[i].massa * planeten[j].massa / Math.pow(distance, 2);<br />
// F = ma<br />
var a1:Number = F / planeten[i].massa;<br />
var a2:Number = F / planeten[j].massa;<br />
//<br />
var angle:Number = Math.atan2(planeten[i]._y &#8211; planeten[j]._y, planeten[i]._x &#8211; planeten[j]._x);<br />
// de krachten zijn tegengesteld, vandaar + en -<br />
planeten[i]._x -= a1 * Math.cos(angle);<br />
planeten[i]._y -= a1 * Math.cos(angle);<br />
planeten[j]._x += a2 * Math.cos(angle);<br />
planeten[j]._y += a2 * Math.sin(angle);<br />
}<br />
}<br />
}<br />
onEnterFrame = animate;</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gertcant.wordpress.com/26/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gertcant.wordpress.com/26/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gertcant.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gertcant.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gertcant.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gertcant.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gertcant.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gertcant.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gertcant.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gertcant.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gertcant.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gertcant.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gertcant.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gertcant.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gertcant.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gertcant.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gertcant.wordpress.com&amp;blog=1456202&amp;post=26&amp;subd=gertcant&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gertcant.wordpress.com/2008/02/06/zwaartekracht/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b767aba3f1c06a7901322477a5c4c73a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gert</media:title>
		</media:content>
	</item>
		<item>
		<title>De wetten van Newton</title>
		<link>http://gertcant.wordpress.com/2008/02/06/de-wetten-van-newton/</link>
		<comments>http://gertcant.wordpress.com/2008/02/06/de-wetten-van-newton/#comments</comments>
		<pubDate>Wed, 06 Feb 2008 13:19:38 +0000</pubDate>
		<dc:creator>gert</dc:creator>
				<category><![CDATA[Actionscript2]]></category>
		<category><![CDATA[Game physics]]></category>

		<guid isPermaLink="false">http://gertcant.wordpress.com/?p=25</guid>
		<description><![CDATA[De basiswetten van Newton i.v.m. beweging, zijn handig, als je realistische games wil maken. Alleen de tweede wet is rechtstreeks interessant voor ActionScript. Maar voor de volledigheid, geef ik de drie wetten. De eerste wet van Newton Een lichaam in rust, wil in rust blijven. Een lichaam in beweging, wil in beweging blijven. Dat betekent [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gertcant.wordpress.com&amp;blog=1456202&amp;post=25&amp;subd=gertcant&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>De basiswetten van Newton i.v.m. beweging, zijn handig, als je realistische games wil maken. Alleen de tweede wet is rechtstreeks interessant voor ActionScript. Maar voor de volledigheid, geef ik de drie wetten.</p>
<h3>De eerste wet van Newton</h3>
<blockquote><p><i> Een lichaam in rust, wil in rust blijven. Een lichaam in beweging, wil in beweging blijven</i>.</p></blockquote>
<p>Dat betekent dat als je geen externe kracht uitoefent op een object, het in zijn huidige toestand blijft (stilstaand of bewegend tegen een bepaalde snelheid).</p>
<p>Bvb.: een astronaut hangt in de ruimte en wat hij ook doet, hij blijft daar ten ewigen dage hangen.</p>
<h3>De tweede wet van Newton</h3>
<blockquote><p><i>De versnelling van een object is omgekeerd evenredig met zijn massa en evenredig tot het totaal van alle krachten die erop inwerken. </i></p></blockquote>
<blockquote><p>F = m * a</p></blockquote>
<p>Dit is een interessante formule. Als we de krachten kennen die op een object worden uitgeoefend, kunnen we ook de versnelling berekenen.</p>
<h4>Een voorbeeld: een zwevende ballon</h4>
<blockquote><p>var yMov:Number = 0;<br />
var massa:Number = 2;<br />
var g:Number = 9.81; // de valversnelling op aarde</p>
<p>var kracht1:Number = massa * g; // het gewicht van de ballon<br />
var kracht2:Number = -20; // de opwaartse kracht van de ballon<br />
var totaleKracht:Number = kracht1 + kracht2;</p>
<p>var yAccel:Number = totaleKracht / massa;</p>
<p>onEnterFrame = function() {<br />
yMov += yAccel;<br />
<b>this.balloon_mc._y += yMov;</b><br />
};</p></blockquote>
<h3>De derde wet van Newton</h3>
<blockquote><p><i>Voor elke kracht die wordt uitgeoefend, is er een gelijke en tegengestelde reactie. </i></p></blockquote>
<p>Vb.: als je zit op een stoel, duwt de stoel je naar boven met een kracht die gelijk is aan je gewicht. Daarom blijf je zitten.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gertcant.wordpress.com/25/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gertcant.wordpress.com/25/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gertcant.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gertcant.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gertcant.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gertcant.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gertcant.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gertcant.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gertcant.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gertcant.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gertcant.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gertcant.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gertcant.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gertcant.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gertcant.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gertcant.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gertcant.wordpress.com&amp;blog=1456202&amp;post=25&amp;subd=gertcant&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gertcant.wordpress.com/2008/02/06/de-wetten-van-newton/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b767aba3f1c06a7901322477a5c4c73a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gert</media:title>
		</media:content>
	</item>
		<item>
		<title>Muisvolger</title>
		<link>http://gertcant.wordpress.com/2008/02/06/muisvolger/</link>
		<comments>http://gertcant.wordpress.com/2008/02/06/muisvolger/#comments</comments>
		<pubDate>Wed, 06 Feb 2008 10:52:07 +0000</pubDate>
		<dc:creator>gert</dc:creator>
				<category><![CDATA[Actionscript2]]></category>

		<guid isPermaLink="false">http://gertcant.wordpress.com/?p=24</guid>
		<description><![CDATA[Oriënteren van een MovieClip Het is erg eenvoudig om een MovieClip naar een bepaald punt te laten &#8216;kijken&#8217;, bvb. naar de muis. We moeten de hoek berekenen die deze mc maakt t.o.v. dit punt. Dit gaat zeer snel met de functie atan2 van het Math object. Deze functie geeft de hoek van een driehoek terug, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gertcant.wordpress.com&amp;blog=1456202&amp;post=24&amp;subd=gertcant&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>Oriënteren van een MovieClip</h3>
<p align="left">Het is erg eenvoudig om een MovieClip naar een bepaald punt te laten &#8216;kijken&#8217;, bvb. naar de muis.</p>
<p align="left">We moeten de hoek berekenen die deze mc maakt t.o.v. dit punt. Dit gaat zeer snel met de functie <b>atan2</b> van het <b>Math </b>object. Deze functie geeft de hoek van een driehoek terug, via de <a href="http://nl.wikipedia.org/wiki/Arctangens" title="Boogtangens" target="_blank">boogtangens</a>.<br />
<img src="http://gertcant.files.wordpress.com/2008/02/pijl.gif?w=500" alt="pijl.gif" /></p>
<h3>Het script</h3>
<blockquote><p>onMouseMove = function () {<br />
var x:Number = this.pijl_mc._x &#8211; _xmouse;<br />
var y:Number = this.pijl_mc._y &#8211; _ymouse;<br />
var angle:Number = Math.atan2(y, x);<br />
angle = angle * 180 / Math.PI ;<br />
this.pijl_mc._rotation = angle;<br />
};</p></blockquote>
<h3>De implementatie</h3>
<ul>
<li>Plaats dit script op het eerste frame van de _root.</li>
<li>Teken een pijl die naar links wijst in een MovieClip en noem hem &#8216;pijl_mc&#8217;.</li>
</ul>
<h3>Analyse</h3>
<ul>
<li>De plaats van de muis en het registratiepunt van de mc maken een driehoek, via de x- en y-coördinaat. De overstaande en de aanliggende zijden van deze driehoek worden in de functie atan() geplaatst.</li>
<li>De hoek wordt teruggegeven in radialen en wordt geconverteerd naar graden, de eenheid van _property.</li>
</ul>
<h3>Conclusie</h3>
<p>De atan2 functie kan gebruikt worden om allerlei objecten (auto&#8217;s, raketten, &#8230;)  naar een bepaald punt te draaien.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gertcant.wordpress.com/24/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gertcant.wordpress.com/24/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gertcant.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gertcant.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gertcant.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gertcant.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gertcant.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gertcant.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gertcant.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gertcant.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gertcant.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gertcant.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gertcant.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gertcant.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gertcant.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gertcant.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gertcant.wordpress.com&amp;blog=1456202&amp;post=24&amp;subd=gertcant&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gertcant.wordpress.com/2008/02/06/muisvolger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b767aba3f1c06a7901322477a5c4c73a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gert</media:title>
		</media:content>

		<media:content url="http://gertcant.files.wordpress.com/2008/02/pijl.gif" medium="image">
			<media:title type="html">pijl.gif</media:title>
		</media:content>
	</item>
	</channel>
</rss>
