I've got a set of Java2D calls that draw vectors on a graphics context. I'd like for the image to be doubled in size and then rotated 90 degrees.
I'm using the following code to do this:
Graphics2D g2 = // ... get graphics 2d somehow ...
AffineTransform oldTransform = g2.getTransform();
AffineTransform newTransform = (AffineTransform)...
Hi all,
I'm trying to scale a rectangle from its center using AffineTransform. I'm sure the solution is obvious but I cannot make it work ! Here is what I've tested so far...
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.geom.AffineTrans...
Hi i am trying to create the affine transform that will allow me to transform a triangle into another one. What i have are the coordinates for the 2 triangles. Can you help me?
Following the answer by Adam Rosenfield i came up with this code in case anyone is bored to solve the equation himself :
public static AffineTransform createTra...
I would like to move the origin from top left to bottom middle of the component?
I have been playing with AffineTransform class could not get it to work?
...
I mean, if I have an object and I apply 3 transforms to it, for example, suppose I don't know what each transform is doing, but I have the matrices.
So, I have
Object X > transform1 > transform2 > transform3 > final result
is there a way to obtain an Affine Transform that can represent the 3 transforms, so I can obtain the same resul...
I have an MKMapView that I am considering rotating in order to more conveniently display a series of Annotations to my users.
As of now I am planning on simply rotating the entire view with a CGAffineTransform, but I wanted to know if anyone had any experience with MKMapView rotation.
Are there any pitfalls or "gotchas" that you came...
I am trying to solve the below problem. I don't have much knowledge in Affine transformations. Could someone help me answer this question:
Find a 3x3 matrix representing a 2D affine transformation of homogeneous coordinates (i.e. every point [x,y] is represented as a column vector [x, y, 1]), which transforms a square [0,0],[1,0],[1,1],...
I have asked this question before, but I wanted to rephrase/clarify some points and expand upon it. I have a piece of code which transforms a BufferedImage using an AffineTransform.
op = new AffineTransformOp(atx, interactive ? interpolationInteractive : interpolationNormal);
displayImage = op.filter(displayImage, null);
This code wo...
I'm working on an iPhone app with some simple animation.
I have a view I want to translate, but not along a line. I want to translate it parabolically. Imagine that I am animating a car moving along a curved road.
I know I can set the transform properly to an instance of CGAffineTransform
Problem is, I have no idea how to create the ...
What is affine invariant? Please explain affine invariant intuitively.
...
I have some problems with rotating images in Java using the AffineTransform class.
I have the following method for creating a rotated (90 degrees) copy of an image:
private BufferedImage createRotatedCopy(BufferedImage img, Rotation rotation) {
int w = img.getWidth();
int h = img.getHeight();
BufferedImage rot = new Buffer...
I'm having an issue using bilinear interpolation for 16 bit data. I have two images, origImage and displayImage. I want to use AffineTransformOp to filter origImage through an AffineTransform into displayImage which is the size of the display area. origImage is of type BufferedImage.TYPE_USHORT_GRAY and has a raster of type sun.awt.im...
Hi,
I'm having a problem with image scaling. When I use the following code to scale an image it ends up with a line either at the bottom or on the right side of the image.
double scale = 1;
if (scaleHeight >= scaleWidth) {
scale = scaleWidth;
} else {
scale = scaleHeight;
}
AffineTransform af = new AffineTransform();
af.scale(s...
I would like to draw some shapes on a JPanel by overriding paintComponent. I would like to be able to pan and zoom. Panning and zooming is easy to do with AffineTransform and the setTransform method on the Graphics2D object. After doing that I can easyli draw the shapes with g2.draw(myShape) The shapes are defined with the "world coordin...
This should be an easy one -- when I use a CGAffineTransformMakeScale on a UIView with width and height = 0.5, it shrinks to the upper left. I need it to shrink around its center. What do I need to do? Thanks!
...
I use the AffineTransform when drawing with Graphics2D. I use it to transform a Shape before drawing it. rx and ry are supposed to be rotation but when drawing the shapes are sheared not rotated. How can I enforce rotation? I tried using the default constructor then calling the rotate, scale and translate but the shapes looked nothing li...
Hi all,
So I have a 3D image that's getting transformed into a space via an affine transform. That transform is composed of the traditional 4x4 matrix plus a center coordinate about which the transform is performed. How can I invert that center point in order to go back into the original space? I have the coordinate, but its a 1x3 ve...
I have some Swing controls in a JPanel. I want this panel to appear on the screen transformed by some arbitrary affine transformation, and for all the controls to remain interactive. Lets assume a rotation by 20 degrees and a scale down to 75% normal size for example.
The closest I have seen for how to do this is here:
http://www.code...
Hi,
I have two squares, S1 = (x1,y1,x2,y2) and S2 = (a1,b1,a2,b2)
I'm looking for the A transformation matrix with which
A * S1 = S2
As far as I see, A is an affine 3x3 matrix, so I have 9 unknown values.
How can I calculate these values?
thanks and best,
Viktor
...
Hi,
I'm trying to make an interactive GUI but I need to move a certain object whenever that rectangle is clicked + dragged. Basically I wanna know whether a rectangle, that has been affine transformed, contains a specific point (x, y). Is there a way to do this? I have tried using contains() method but it doesn't work for a rectangle th...