<?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/"
	>

<channel>
	<title>render fast &#187; Python</title>
	<atom:link href="http://renderfast.com/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://renderfast.com</link>
	<description>A blog about developing software by trial and error by Doug Letterman</description>
	<lastBuildDate>Mon, 24 Jan 2011 17:24:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Getting PyQt4 to work on Snow Leopard</title>
		<link>http://renderfast.com/2009/11/07/getting-pyqt4-to-work-on-snow-leopard/</link>
		<comments>http://renderfast.com/2009/11/07/getting-pyqt4-to-work-on-snow-leopard/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 23:45:20 +0000</pubDate>
		<dc:creator>Doug</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Qt]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[PyQt]]></category>

		<guid isPermaLink="false">http://renderfast.com/?p=160</guid>
		<description><![CDATA[I recently upgraded my Mac to OS 10.6 and I had to rebuild Qt and PyQt to get them working again. I installed Qt 4.5.3 from source and then installed sip 4.9.1 and PyQt4.6.1. Immediately it failed to work with the following error: >>> from PyQt4 import QtCore Traceback (most recent call last): File "", [...]]]></description>
			<content:encoded><![CDATA[<p>I recently upgraded my Mac to OS 10.6 and I had to rebuild Qt and PyQt to get them working again. I installed Qt 4.5.3 from source and then installed sip 4.9.1 and PyQt4.6.1. Immediately it failed to work with the following error:</p>
<pre>
>>> from PyQt4 import QtCore
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Python/2.6/site-packages/PyQt4/QtCore.so, 2): Symbol not found: _sipQtConnect
  Referenced from: /Library/Python/2.6/site-packages/PyQt4/QtCore.so
  Expected in: flat namespace
 in /Library/Python/2.6/site-packages/PyQt4/QtCore.so
</pre>
<p>Some quick searching led me to <a href="http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg18971.html">this post</a>, which implied that hacking PyQt&#8217;s configure.py file to force the architecture to be 64-bit would do the trick.<br />
So where it says:</p>
<pre class="brush: python;">
for a in sipcfg.arch.split():
    if a == 'i386':
        qmake_archs.append('x86_64')
    elif a == 'x86_64':
        qmake_archs.append('x86_64')
    elif a == 'ppc':
qmake_archs.append('ppc')
</pre>
<p>Replace <tt>qmake_archs.append('x86')</tt> with <tt>qmake_archs.append('x86_64')</tt>.<br />
Now PyQt works again.</p>
]]></content:encoded>
			<wfw:commentRss>http://renderfast.com/2009/11/07/getting-pyqt4-to-work-on-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>2D Transforms and QGraphicsScene</title>
		<link>http://renderfast.com/2008/08/18/xforms/</link>
		<comments>http://renderfast.com/2008/08/18/xforms/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 14:00:59 +0000</pubDate>
		<dc:creator>Doug</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Qt]]></category>
		<category><![CDATA[matrix]]></category>
		<category><![CDATA[PyQt]]></category>
		<category><![CDATA[QGraphicsScene]]></category>
		<category><![CDATA[transformation]]></category>
		<category><![CDATA[Xformer]]></category>

		<guid isPermaLink="false">http://renderfast.com/?p=18</guid>
		<description><![CDATA[QGraphicsScene and QGraphicsItems use the QTransform class to move, scale, shear, and rotate objects in the view. For the most part, this works great. Things get a little tricky when you want to keep track of an item&#8217;s rotation in terms of a simple angular value. QGraphicsItem doesn&#8217;t have a method to get the “rotation,” [...]]]></description>
			<content:encoded><![CDATA[<p>QGraphicsScene and QGraphicsItems use the QTransform class to move, scale, shear, and rotate objects in the view. For the most part, this works great. Things get a little tricky when you want to keep track of an item&#8217;s rotation in terms of a simple angular value. QGraphicsItem doesn&#8217;t have a method to get the “rotation,” and neither does QTransform. Instead we have to recover it from the transformation matrix.</p>
<p>The <a title="Trolltech - QTransform" href="http://doc.trolltech.com/4.3/qtransform.html#details">QTransform docs</a> tell us that a rotation is measured in the clockwise direction. Rotation by an angle ? is computed for a given point using the matrix:</p>
<p><img class="alignnone size-full wp-image-19" title="rotation_matrix" src="http://renderfast.com/wp-content/uploads/2008/07/rotation_matrix.png" alt="" width="215" height="44" /></p>
<p>How to recover the angular rotation from this matrix? One way is to apply the same matrix to a point at x=0, y=1 and use some simple trig to figure out the angle between its original and new positions.</p>
<p>Enter the excellent <a title="Wikipedia - Atan2" href="http://en.wikipedia.org/wiki/Atan2">atan2</a> function. Written in python, the math looks like this:</p>
<p><tt>rotation = 180./math.pi * math.atan2(-xform.m21(), xform.m11())</tt></p>
<p>Where <tt>xform</tt> is our QTransform object (the transformation matrix).</p>
<p><a rel="lightbox" href="http://renderfast.com/wp-content/uploads/2008/08/xformer_screenshot.png"><img class="alignleft size-medium wp-image-24" title="Xformer screenshot" src="http://renderfast.com/wp-content/uploads/2008/08/xformer_screenshot-300x223.png" alt="" width="300" height="223" /></a>I wrote a little program, “Xformer,” in PyQt that demonstrates the relationship between an object’s QTransform matrix and its corresponding transformation, rotation, scale, and shear values.</p>
<p><a href="http://renderfast.com/wp-content/uploads/2008/08/xformer.py.txt">Download Xformer</a> and try it out. It requires a working copy of PyQt4.</p>
]]></content:encoded>
			<wfw:commentRss>http://renderfast.com/2008/08/18/xforms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

