Reflection in Y axis - Affine transofrmations?
Hi,
I would like to rotate a bezier curve drawn using the cubicCurve method in the y axis to save having to draw another, this is what I have currently in my graphics method: (I have an assignment to draw a face with horns using bezier curves)
publicvoid paint(Graphics g){
Graphics2D g2 = (Graphics2D)g;
// Antialiasing looks much nicer
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
// Transformations for all
AffineTransform R1 = AffineTransform.getRotateInstance(Math.PI);// Rotate so that it isnt upside down
AffineTransform T1 = AffineTransform.getTranslateInstance(300.0,300.0);// Translate the origin to middle of screen
T1.concatenate(R1);// Rotate, then translate
g2.setTransform(T1);
c1.paint(g);// Bottom of face
c2.paint(g);// Left eye
c3.paint(g);// Left bottom bit of horn
c4.paint(g);// Left top bit of horn
c5.paint(g);// Left top of face
// Reflect around the x axis.
// FOUND ON GOOGLE AS Y AXIS REFLECTION BUT CAUSES AN ERROR
//AffineTransform R2 = AffineTransform.setElements(1, 0, 0, -1, 0, 0);
//g2.setTransform(R2);
// What I have: Just rotates atm
AffineTransform R2 = AffineTransform.getRotateInstance(Math.PI, 0, 65);// Transformation to draw right side of the face using left curves
g2.transform(R2);
c2.paint(g);// Right eye
c3.paint(g);// Right bottom bit of horn
c4.paint(g);// Right top bit of horn
c5.paint(g);// Right top of face
}// End of paint method
Many thanks in advance,
Ed

