wood burning stoves*
The moose likes Java in General and the fly likes AffineTransform Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "AffineTransform" Watch "AffineTransform" New topic
Author

AffineTransform

colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
I'm using an AffineTransform for some 3D stuff, but this line throws an exception:



I can't see why, I thought I could use any floats as parameters?
Any ideas?
Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Does it throw any particular exception? It would be helpful for us to know.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Note that those constants have far more precision in them than a float can represent. You only get about 7 decimal digits in a float.

If you really need all that precision (unlikely?), then use double.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
Here is an output of the exception.
That is when I used this line...
return new AffineTransform(0.0f,-0.02999f,0.0f,0.99955f,130.0f,288.78218f);
I could obviously catch it, but thats like sweeping up rubbish under the carpet, and pretending its not there, I would rather know why I get an exception.
Any help is much appreciated. Thanks


java.awt.image.ImagingOpException: Unable to invert transform AffineTransform[[0.0, 0.0, 130.0], [-0.029990000650287, 0.999549984931946, 288.78216552734375]]
at java.awt.image.AffineTransformOp.validateTransform(Unknown Source)
at java.awt.image.AffineTransformOp.<init>(Unknown Source)
at sun.java2d.pipe.DrawImage.transformImage(Unknown Source)
at sun.java2d.pipe.DrawImage.copyImage(Unknown Source)
at sun.java2d.pipe.DrawImage.copyImage(Unknown Source)
at sun.java2d.SunGraphics2D.drawImage(Unknown Source)
at sun.awt.image.ImageRepresentation.drawToBufImage(Unknown Source)
at sun.java2d.pipe.DrawImage.copyImage(Unknown Source)
at sun.java2d.pipe.ValidatePipe.copyImage(Unknown Source)
at sun.java2d.SunGraphics2D.drawImage(Unknown Source)
at sun.java2d.SunGraphics2D.drawImage(Unknown Source)
at rubik.Drawer.drawImage(Drawer.java:275)
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Well, the numbers you put into your AffineTransform result in a transformation that maps the entire plane into a single line. You can see this because its determinant is zero. This can't be inverted as it isn't a one-to-one mapping. Evidently whatever you were trying to do has a problem with degenerate transformations.

Read the documentation for AffineTransform, especially the getDeterminant() method, for more information.
colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
Excellent, I was thinking it was something like that.
Didn't really consider the determinant, but that explains why it says
"Unable to invert transform..."
Because you can't invert a matrix that has a zero determinant.

I'm basically building a rubiks cube, and it when it loads up,
it shows the cube from the front, but also tries to draw 2 of the side
faces, which are really just lines, hence the zero determinant,

I think I can fix it now, thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: AffineTransform
 
Similar Threads
Help!!! Image print problem
Invoking equals method on float object
incompatible types: found double required float error;
How to draw a circle using 2d arrays
Difficulty rendering an octahedron (2 pyramids attached at the bottom to each other)