Skip to main content
Solved

reflection of a polygon with respect to a segment


arthy
Contributor
Forum|alt.badge.img+8
  • Contributor

hello

How should I proceed to build the opposite (image) of a polygone (object) with respect to a line?

Best answer by arthy

Thanks @jdh, @gio, @pratsch

Based on your comments/answers, this is What I did to obtained an "approximate solution":

  • create a buffer around the line such that include the objects to be reflected
  • iteratively snip the line (using the iterative snipper) into short straight lines (By doing so, even a S-shape could be approximated to a series of straight lines) and the buffer will become a series of small rectangles.
  • determine the equation of the short straight lines
  • after computing the parameters of the affiner transformer for each short straight line, use the affine transformer to reflect the part of the object contained in that specific rectangle to its corresponding symmetric small rectangle

This is an illustration where the part of the feature contained in a specific small right rectangle was reflected in the corresponding small left rectangle.

View original
Did this help you find an answer to your question?

12 replies

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • May 16, 2019

I would use the Affiner transformer.

 

If I understand the math correctly the parameters should be

A: (1-m^2)/(1+m^2)

 

B: 2m/(1+m^2)

 

C: -2mb/(1+m^2)

 

D: 2m/(1+m^2)

 

E: (m^2-1)/(1+m^2)

 

F: 2b/(1+m^2)

for the line y = mx +b

If the line is the y-axis it simplifies to -1 0 0 0 1 0

 

If the line is the x-axis it simplies to 1 0 0 0 -1 0

 


arthy
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • May 16, 2019
jdh wrote:

I would use the Affiner transformer.

 

If I understand the math correctly the parameters should be

A: (1-m^2)/(1+m^2)

 

B: 2m/(1+m^2)

 

C: -2mb/(1+m^2)

 

D: 2m/(1+m^2)

 

E: (m^2-1)/(1+m^2)

 

F: 2b/(1+m^2)

for the line y = mx +b

If the line is the y-axis it simplifies to -1 0 0 0 1 0

 

If the line is the x-axis it simplies to 1 0 0 0 -1 0

 

Hello @jdh

It is a line from an FME perspective (i.e. with multiple vertices) not from a math perspective.

It wouldn't be possible to describve the line with an equation like y =mx +b


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • May 16, 2019
arthy wrote:

Hello @jdh

It is a line from an FME perspective (i.e. with multiple vertices) not from a math perspective.

It wouldn't be possible to describve the line with an equation like y =mx +b

If it's a straight line then you can calculate it easily enough by taking the coordinates of the starting vertex and ending vertex.

 

 

There's not enough caffeine in the world for me to figure out a reflection for a curve.

arthy
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • May 17, 2019
jdh wrote:

If it's a straight line then you can calculate it easily enough by taking the coordinates of the starting vertex and ending vertex.

 

 

There's not enough caffeine in the world for me to figure out a reflection for a curve.

@jdh unfortunately, it is not a straigth line.

@takashi Any ideas?


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • May 17, 2019
arthy wrote:

@jdh unfortunately, it is not a straigth line.

@takashi Any ideas?

Could you illustrate how the feature would reflect across a non-straight line? It would think it could cause significant distortion in the feature.

 

 

 

You would probably need to reflect each vertex independently and then rebuild your polygon.

 

It would be something like
  • find the closest point of the line to the vertex (Neighborfinder)
  • find the tangent of the line at that point (basically the segment, as long as the closest point is not a vertex)
  • reflect the vertex across the tangent (Affiner as above)
  • PointConnector to rebuild polygon.

pratsch
Forum|alt.badge.img
  • May 17, 2019
arthy wrote:

@jdh unfortunately, it is not a straigth line.

@takashi Any ideas?

I think you first have decide what simplification could be applied to the mirror lines and what is appropriate for the result you want. Do your lines have arcs? Can you use a chopper by 2 and then use a neighborfinder to reflect on the nearest segment? Or is a generalizer more appropriate? Does a single line function as a mirror for more than one polygon or is it one by one. Do they share a common value? No straight forward solution. It will get messy in some places I guess.


takashi
Influencer
  • May 19, 2019
arthy wrote:

@jdh unfortunately, it is not a straigth line.

@takashi Any ideas?

I cannot imagine how a shape should be transformed if the line isn't straight. Could you please illustrate specifically how a triangle should be transformed if the line is S-shape, for example?


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • May 21, 2019

@takashi

It is possible to do that, though the calculation is much more difficult (often very much so ).

Also it would be a stretch to call the result a "reflection". It would be more like a laughing mirror reflection.

You end up with distortions up to extremes.

Depending on the curve and weather it can be described as a single function.

 

I don't see any apparent use for such in Geography.

 

I'm wondering if @arthy is talking polylines. Which are still lines.

Reflecting in segments of polylines raises the question as what you consider a reflection even.

AS you can reflect anything in any line.

So reflecting in a polyline might also be considered as reflecting in any line segment of the polyline.

So where do you set your bounds?

 


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • May 21, 2019

@takashi

@arthy

Of course a question been posed many a time and solutions abound.

https://www.reddit.com/r/math/comments/4xrpjk/how_to_define_a_nonlinear_reflection_in_2d/

Check the links, you'll love it. The Imgur gifts.


arthy
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • Best Answer
  • May 22, 2019

Thanks @jdh, @gio, @pratsch

Based on your comments/answers, this is What I did to obtained an "approximate solution":

  • create a buffer around the line such that include the objects to be reflected
  • iteratively snip the line (using the iterative snipper) into short straight lines (By doing so, even a S-shape could be approximated to a series of straight lines) and the buffer will become a series of small rectangles.
  • determine the equation of the short straight lines
  • after computing the parameters of the affiner transformer for each short straight line, use the affine transformer to reflect the part of the object contained in that specific rectangle to its corresponding symmetric small rectangle

This is an illustration where the part of the feature contained in a specific small right rectangle was reflected in the corresponding small left rectangle.


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • May 22, 2019
arthy wrote:

Thanks @jdh, @gio, @pratsch

Based on your comments/answers, this is What I did to obtained an "approximate solution":

  • create a buffer around the line such that include the objects to be reflected
  • iteratively snip the line (using the iterative snipper) into short straight lines (By doing so, even a S-shape could be approximated to a series of straight lines) and the buffer will become a series of small rectangles.
  • determine the equation of the short straight lines
  • after computing the parameters of the affiner transformer for each short straight line, use the affine transformer to reflect the part of the object contained in that specific rectangle to its corresponding symmetric small rectangle

This is an illustration where the part of the feature contained in a specific small right rectangle was reflected in the corresponding small left rectangle.

Looks like reflection in a line. If the line is not "straight" it looks like a polyline.

I see no curves, arcs etc. (also you can always stroke a non line)

If all or some of the lines of the polyline have different angles, then you are warping your object. Or in your example, as they are point objects, displacing geographic features. (lidar samples or something)

And you seem to reflect in the line(segment) closest to the objects.

Looks visibly warped.

 

Why would you want to do that to geo features?

 

The reflection question has been posted on this forum before by the way.

 

 

 

 


arthy
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • May 22, 2019
gio wrote:

Looks like reflection in a line. If the line is not "straight" it looks like a polyline.

I see no curves, arcs etc. (also you can always stroke a non line)

If all or some of the lines of the polyline have different angles, then you are warping your object. Or in your example, as they are point objects, displacing geographic features. (lidar samples or something)

And you seem to reflect in the line(segment) closest to the objects.

Looks visibly warped.

 

Why would you want to do that to geo features?

 

The reflection question has been posted on this forum before by the way.

 

 

 

 

@gio,

On the screen shot, I zoommed in a lot just to illustrate the methodology. There are some cases where the reflection has to be done on a line having an arc shape or an S-shape.

I'm not reflecting to the closest object. I used the small rectangles to split the object and it is only the part included in that small rectangle that will be reflected. In the previous image, I only show the part of the object that was included in one of those small rectangles.

I'm going to use the reflected objects in combination with the original objects to create a worst case scenario of possible obstruction of any structure over or beside a railway track.

 

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings