Forums Register Login

Polygon Reflection

+Pie Number of slices to send: Send
hello
i have been trying to implement a reflection in java using matrices
Here is my matrix


and here is the class:
+Pie Number of slices to send: Send
… and what happens? Please write down what the algorithm you are using is. Then one can see whether you are reflecting the points correctly.
+Pie Number of slices to send: Send
this is my class matrix:


Here is where i perform the transformation:


and here is in my main where i call the function:



it is not working
mayB the matrix or the functionis not well implemented
how can i implement reflection using matrix
+Pie Number of slices to send: Send
Don't show us any code at this stage; show us the algorithm.
+Pie Number of slices to send: Send
 

Vani Sweety wrote:


 
+Pie Number of slices to send: Send
That does not help.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
And what is the formula for reflection along a line? You need to work out the formula before you try writing any code.
+Pie Number of slices to send: Send
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.
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
https://gardener-gift.com


reply
reply
This thread has been viewed 560 times.
Similar Threads
Trying to make a shape.
how to rotate my arrow?
How do read a double datatype 2D array into your applet code from a text file
AffineTransform "transform" method
Shape Hierarchy
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 02:22:50.