On Jul 23, 2008, at 11:22 PM, Martin Desruisseaux wrote:
> Y.J.Chun a écrit :
>> I could not solve the below problem in the end. And creating
>> AffineTransform from MathTransform
>> is critical part in my program.
>
> I have not yet had a chance to inspect what is going on. But the
> behavior you are reporting suggests that the affine transform
> coefficients are copied in the wrong order by AffineTransform2D
> constructor. This is strange because I looked at the code 2 days ago
> and saw no obvious error (which is why I didn't replied - I had no
> clue was going on at that time).
>
> There is a choice. You can either:
>
> 1) Write a small test case reproducing the problem, so I can
> use it for debugging.
>
try
{
// create MathTransform...
Matrix matrix = new Matrix3(0.001, 0.1, 0.2, 1.0, 1.1,
1.2, 0, 0, 1);
LinearTransform mathTr =
ProjectiveTransform.create(matrix);
AffineTransform affineTr = new
AffineTransform2D(mathTr.getMatrix());
Point2D p = new Point2D.Double(1, 2);
GeneralDirectPosition dp = new GeneralDirectPosition(2);
dp.setLocation(affineTr.transform(p, null));
System.out.println("By AffineTransform: "+p+" ==> "+
dp);
dp.setLocation(p);
mathTr.transform(dp, dp);
System.out.println("By ProjectiveTransform: "+p+" ==>
"+ dp);
} catch (Exception e)
{
e.printStackTrace();
}
Check this code please. I do have no knowledge about affine transform
(duh...) unfortunately so
I dont know which is correct value (or even if i'm using it correct...:)
but the result of the two transform is different.
> or
>
> 2) Copies the affine transform coefficients yourself, using
> the following approach:
>
> Matrix m = ((LinearTransform) t).getMatrix();
> new AffineTransform(m.getElementAt(0,0), m.getElementAt(..etc..);
>
>
> But before to do that, have you tried to simply cast your t
> transform to AffineTransform? I believe it is already an instance of
> AffineTransform2D.
>
Oh right. I didn't check it before.
The problem is solved though my program still not working...:)
> Martin
I appreciate for your help.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users