Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

AffineTransform

 
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 26283
80
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does it throw any particular exception? It would be helpful for us to know.
 
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 26283
80
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Well THAT's new! Comfort me, reliable tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic