<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>While transforming points using MatrixTransform2x3 we noticed
some strange rounding behavior:</p>
<blockquote>
<p><tt>"with plugin"</tt><tt><br>
</tt><tt>(MatrixTransform2x3 withOffset: 5 @ 10)
localPointToGlobal: 0@0. "5@10"</tt><tt><br>
</tt><tt>(MatrixTransform2x3 withOffset: -5 @ -10)
localPointToGlobal: 0@0. "-4@ -9"</tt><tt><br>
</tt><tt><br>
</tt><tt>"without plugin"</tt><tt><br>
</tt><tt>((MatrixTransform2x3 withOffset: 5 @ 10)
transformPoint: 0@0) rounded. "5@10"</tt><tt><br>
</tt><tt>((MatrixTransform2x3 withOffset: -5 @ -10)
transformPoint: 0@0) rounded. "-5@ -10"</tt></p>
</blockquote>
<p>It appears the code used to round in the plugin simply adds 0.5
and truncates the result, which does not work correctly for
negative numbers.<br>
This code can be found in <tt>Matrix2x3Plugin >>
#roundAndStoreResultPoint:</tt> and <tt>Matrix2x3Plugin
>> #roundAndStoreResultRect:x0:y0:x1:y1:</tt> .</p>
<p>----</p>
<p>On a kind of related note: Is there even a reason to round the
resulting floats?</p>
<p>While the class comment of MatrixTransform2x3 notes that this
behavior is intentional, glancing quickly over its uses we could
not find anything taking advantage or benefiting from it. It's
also not a limitation of the DisplayTransform interface, since
MorphicTransform does produce floating point values. Wouldn't it
be much more versatile and easier to leave rounding to users if
they actually need it?</p>
<p><br>
</p>
<p>Stephan<br>
</p>
</body>
</html>