java.awt.geom.Area

Discussion in 'Java' started by Richard A. DeVenezia, Jan 12, 2004.

  1. 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

    --
    Richard A. DeVenezia
     
    Richard A. DeVenezia, Jan 12, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Mark Bram
    Replies:
    2
    Views:
    5,968
    Robert Mark Bram
    Dec 11, 2003
  2. Mark
    Replies:
    1
    Views:
    611
    Larry Barowski
    Jun 27, 2005
  3. Chantal

    java.awt.geom.Area questions

    Chantal, Jan 26, 2006, in forum: Java
    Replies:
    1
    Views:
    487
    Chantal
    Jan 26, 2006
  4. hotadvice
    Replies:
    14
    Views:
    709
    hotadvice
    Oct 2, 2007
  5. Andy B.
    Replies:
    0
    Views:
    813
    Andy B.
    Apr 30, 2010
Loading...

Share This Page