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
(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