<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Problems with rotating co-ordinates</title>
		<link>http://www.allegro.cc/forums/view/588740</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 26 Nov 2006 22:53:20 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi All,</p><p>I&#39;m trying to make a sprite rotate according to the mouse position, which I have working, however what I want to do is have a line drawn from a specific position to the mouse cursor.</p><p>For example my sprite is 32*32 and the point I want the line to start from is x=29,y=3.  The line draws fine if the mouse is directly to the right of the sprite, but once the rotation starts it doesn&#39;t line up properly.  Basically I want the start of the line to rotate with the sprite.</p><p>Any ideas on house this could work?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Moonsdescend)</author>
		<pubDate>Sun, 26 Nov 2006 05:06:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ll point you towards this wonderful document: <a href="http://pixwiki.bafsoft.com/mags/5/articles/circle/sincos.htm">http://pixwiki.bafsoft.com/mags/5/articles/circle/sincos.htm</a></p><p>More specifically, this code snippet:</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/line" target="_blank"><span class="a">line</span></a> <span class="k2">(</span><a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a>, <a href="http://www.allegro.cc/manual/fixtoi" target="_blank"><span class="a">fixtoi</span></a><span class="k2">(</span>x<span class="k2">)</span>, <a href="http://www.allegro.cc/manual/fixtoi" target="_blank"><span class="a">fixtoi</span></a><span class="k2">(</span>y<span class="k2">)</span>,
            <a href="http://www.allegro.cc/manual/fixtoi" target="_blank"><span class="a">fixtoi</span></a> <span class="k2">(</span>x <span class="k3">+</span> <span class="n">9</span> <span class="k3">*</span> fcos <span class="k2">(</span>angle<span class="k2">)</span><span class="k2">)</span>,
            <a href="http://www.allegro.cc/manual/fixtoi" target="_blank"><span class="a">fixtoi</span></a> <span class="k2">(</span>y <span class="k3">+</span> <span class="n">9</span> <span class="k3">*</span> fsin <span class="k2">(</span>angle<span class="k2">)</span><span class="k2">)</span>,
            <a href="http://www.allegro.cc/manual/makecol" target="_blank"><span class="a">makecol</span></a> <span class="k2">(</span><span class="n">255</span>, <span class="n">0</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

Where 9 is the length of the line. The rest is pretty self-explanatory. I hope this is what you wanted.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ngiacomelli)</author>
		<pubDate>Sun, 26 Nov 2006 06:58:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You probably need to rotate 29,3 by whatever the sprite is rotated by.</p><p>Taken from some google result...
</p><div class="source-code snippet"><div class="inner"><pre>newpoint.x<span class="k3">=</span> xold<span class="k3">*</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_113.html" target="_blank">cos</a><span class="k2">(</span>angle<span class="k2">)</span><span class="k3">-</span>yold<span class="k3">*</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_728.html" target="_blank">sin</a><span class="k2">(</span>angle<span class="k2">)</span><span class="k2">;</span>
newpoint.y<span class="k3">=</span> xold<span class="k3">*</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_728.html" target="_blank">sin</a><span class="k2">(</span>angle<span class="k2">)</span><span class="k3">+</span>yold<span class="k3">*</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_113.html" target="_blank">cos</a><span class="k2">(</span>angle<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

Angles in doubles (radians) (or fixed, if you want to use allegros functions. Don&#39;t use allegros functions btw =))
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jonatan Hedborg)</author>
		<pubDate>Sun, 26 Nov 2006 07:02:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
You probably need to rotate 29,3 by whatever the sprite is rotated by.
</p></div></div><p>
I think so.<br />What I think I need to do is rotate X+29 by angle and Y+3 by angle.  This area has never been my strong point <img src="http://www.allegro.cc/forums/smileys/cheesy.gif" alt=":D" /><br />So far I&#39;ve had no luck with the samples that have been posted.  They have caused some interesting effects which I might use later on though <img src="http://www.allegro.cc/forums/smileys/cheesy.gif" alt=":D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Moonsdescend)</author>
		<pubDate>Sun, 26 Nov 2006 07:31:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The code that i posted does just that. What effects are you having? If you are using fixed format angles (which are 0-255, while radians are 0-PI*2), that might be the reason.</p><p>Post the relevant code and we can look at it <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jonatan Hedborg)</author>
		<pubDate>Sun, 26 Nov 2006 22:53:20 +0000</pubDate>
	</item>
</rss>
