i have use only method to implement the reflection
it takes the points of a polygon put in a matrix then perform sme calculation
put the data of the"reflected points" in another array
then add it to the graph
The problem here is this: You say your "reflecting" code doesn't do what you want. But you only show us the code and don't tell us what it is supposed to do. Neither do you give us any examples.
And we don't even know what "reflecting" means to you. In geometry you can reflect with respect to any plane; you seem to have a special plane in mind.
So:
1. What does "reflect" mean?
2. Give us an example of some output which disagrees with your definition of "reflect" and tell us what you think the right output would be.
i have a graph panel where i can draw a polygon
i can translate the polygon
rotate the polygon by degree(input by user) at any point on the plane
and i must also implement the reflection of the polygon along a line
the problem is that the way i have implemented the class reflectPolygon is not working
it is drawing the polygon on the polygon itself
i have use matrix@D to implement the matrices to get the points of polygon
A standard and simple way is: rotate your reflection axis so that it coincides with either the x- or the y-axis.
Do the reflection (chance the sign of either the x- or the y-coordinate), and rotate back.
That is a multiplication of three simple matrices.
If your reflection axis does not pass through the origin, you also need a translation. In that case, it is handy
to look at the way the 'AffineTransform' class works.
If this isn't an assignment, I would suggest using a Shape for your Polygon (Path2D). That would greatly
simplify your methods.
Post by:autobot
I do some of my very best work in water. Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking