<?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: Exercise 5-9: Bouncing Ball</title>
	<atom:link href="http://www.learningprocessing.com/exercises/chapter-5/exercise-5-9/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learningprocessing.com</link>
	<description>A Beginner's Guide to Programming Images, Animation, and Interaction by Daniel Shiffman</description>
	<lastBuildDate>Fri, 10 Feb 2012 19:58:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: william</title>
		<link>http://www.learningprocessing.com/exercises/chapter-5/exercise-5-9/comment-page-1/#comment-20720</link>
		<dc:creator>william</dc:creator>
		<pubDate>Sat, 04 Feb 2012 17:20:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=1433#comment-20720</guid>
		<description>This sounds like two separate questions:
1. How do I constrain the ball in a smaller square area?
 -- Off the top, measure the radius of the ball and subtract that from the maximum x &amp; y value; add the radius value on any zero value for x and y.
2. How do I constrain the ball to a circle area?
 -- See shiffman&#039;s polar coordinates for constraining to a circle</description>
		<content:encoded><![CDATA[<p>This sounds like two separate questions:<br />
1. How do I constrain the ball in a smaller square area?<br />
 &#8211; Off the top, measure the radius of the ball and subtract that from the maximum x &amp; y value; add the radius value on any zero value for x and y.<br />
2. How do I constrain the ball to a circle area?<br />
 &#8211; See shiffman&#8217;s polar coordinates for constraining to a circle</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.learningprocessing.com/exercises/chapter-5/exercise-5-9/comment-page-1/#comment-20676</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Mon, 12 Dec 2011 02:10:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=1433#comment-20676</guid>
		<description>Check out the concept of Polar coordinates.

http://www.learningprocessing.com/examples/chapter-13/example-13-5-polar-to-cartesian/</description>
		<content:encoded><![CDATA[<p>Check out the concept of Polar coordinates.</p>
<p><a href="http://www.learningprocessing.com/examples/chapter-13/example-13-5-polar-to-cartesian/" rel="nofollow">http://www.learningprocessing.com/examples/chapter-13/example-13-5-polar-to-cartesian/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fame_frame</title>
		<link>http://www.learningprocessing.com/exercises/chapter-5/exercise-5-9/comment-page-1/#comment-20675</link>
		<dc:creator>Fame_frame</dc:creator>
		<pubDate>Fri, 09 Dec 2011 12:44:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=1433#comment-20675</guid>
		<description>i have also tried constraining the ball in a smaller square area of the screen so that the whole ball is visible at all times but I am having a nightmare time trying to restrict its movement within a circle...any ideas?</description>
		<content:encoded><![CDATA[<p>i have also tried constraining the ball in a smaller square area of the screen so that the whole ball is visible at all times but I am having a nightmare time trying to restrict its movement within a circle&#8230;any ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Readydot WeAre</title>
		<link>http://www.learningprocessing.com/exercises/chapter-5/exercise-5-9/comment-page-1/#comment-20592</link>
		<dc:creator>Readydot WeAre</dc:creator>
		<pubDate>Sat, 17 Sep 2011 07:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=1433#comment-20592</guid>
		<description>The constrain is just a measure to keep sure the ball is kept between the two states of the variable &quot;r&quot;, which are 32 and 64. The -2 adds a little animation to the shrinking of the ball, so it does not just change from 64 to 32, but after being 64, &quot;-2&quot; are subtracted a each redraw until it reaches 32. Replace the 2 by a 1 and the effect is far more obvious.</description>
		<content:encoded><![CDATA[<p>The constrain is just a measure to keep sure the ball is kept between the two states of the variable &#8220;r&#8221;, which are 32 and 64. The -2 adds a little animation to the shrinking of the ball, so it does not just change from 64 to 32, but after being 64, &#8220;-2&#8243; are subtracted a each redraw until it reaches 32. Replace the 2 by a 1 and the effect is far more obvious.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mi Dan</title>
		<link>http://www.learningprocessing.com/exercises/chapter-5/exercise-5-9/comment-page-1/#comment-20582</link>
		<dc:creator>Mi Dan</dc:creator>
		<pubDate>Fri, 02 Sep 2011 12:43:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=1433#comment-20582</guid>
		<description>What does &quot;r-2&quot; exactly do in the constrain function, in the last line? 
I&#039;ve searched Processing&#039;s help but it wasn&#039;t explained there either...</description>
		<content:encoded><![CDATA[<p>What does &#8220;r-2&#8243; exactly do in the constrain function, in the last line? <br />
I&#8217;ve searched Processing&#8217;s help but it wasn&#8217;t explained there either&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Shiffman</title>
		<link>http://www.learningprocessing.com/exercises/chapter-5/exercise-5-9/comment-page-1/#comment-8872</link>
		<dc:creator>Daniel Shiffman</dc:creator>
		<pubDate>Thu, 04 Feb 2010 01:52:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=1433#comment-8872</guid>
		<description>It would probably be easier to understand if I wrote the code like this:

&lt;pre&gt;
r = r - 2;
r = constrain(r,32,64);
&lt;/pre&gt;

In other words, we want r to always get smaller, but never go below 32 (or above 64).  The constrain function allows you to perform a mathematical operation at the same time and decrease the value or r, while constraining it.

&lt;pre&gt;
r = constrain(r-2,32,64);
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>It would probably be easier to understand if I wrote the code like this:</p>
<pre>
r = r - 2;
r = constrain(r,32,64);
</pre>
<p>In other words, we want r to always get smaller, but never go below 32 (or above 64).  The constrain function allows you to perform a mathematical operation at the same time and decrease the value or r, while constraining it.</p>
<pre>
r = constrain(r-2,32,64);
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: P3HO</title>
		<link>http://www.learningprocessing.com/exercises/chapter-5/exercise-5-9/comment-page-1/#comment-8834</link>
		<dc:creator>P3HO</dc:creator>
		<pubDate>Wed, 03 Feb 2010 08:51:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.learningprocessing.com/?page_id=1433#comment-8834</guid>
		<description>r = constrain(r-2,32,64);

I can&#039;t unterstand why the first value of constrain() is not &quot;r&quot; but &quot;r-2&quot;.
I changed the value &quot;r-2&quot; to &quot;r&quot;, then the ball size went up to 64 when it touch the screen and didn&#039;t come back to 32.
Please explain me.. the roll of constrain() in this example!</description>
		<content:encoded><![CDATA[<p>r = constrain(r-2,32,64);</p>
<p>I can&#8217;t unterstand why the first value of constrain() is not &#8220;r&#8221; but &#8220;r-2&#8243;.<br />
I changed the value &#8220;r-2&#8243; to &#8220;r&#8221;, then the ball size went up to 64 when it touch the screen and didn&#8217;t come back to 32.<br />
Please explain me.. the roll of constrain() in this example!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

