java.awt.geom.Area

  • Thread starter Richard A. DeVenezia
  • Start date
R

Richard A. DeVenezia

I am reflecting an area about an abitrary line defined by points (x1,y1) and
(x2,y2)

I have
double dy = (y2-y1);
double dx = (x2-x1);
double theta;
if dx != 0 {
theta = Math.atan (dy/dx);
} else {
theta = Math.pi/2;
}

AffineTransform t = new AffineTransform();

t.setToTranslation (-l.x1,-l.y1);
myArea.transform(t);
t.setToRotation (-theta);
myArea.transform(t);
t.setToScale (1,-1);
myArea.transform(t);
t.setToRotation (theta);
myArea.transform(t);
t.setToTranslation (l.x1,l.y1);
myArea.transform(t);

The above reflects myArea, but I am wondering why the following does _not_
reflect the area:

// does something, but it is certainly not a reflection through a line
t.translate(-l.x1,-l.y1);
t.rotate(-theta);
t.scale(1,-1);
t.rotate(theta);
t.translate(l.x1,l.y1);
myArea.transform(t);

I am wanting to call transform() as little as possible
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top