No announcement yet.

Dragging Polygons Back to Original Position Leaves them Distorted

  • Filter
  • Time
  • Show
Clear All
new posts

  • Dragging Polygons Back to Original Position Leaves them Distorted

    I'm running into a Worldwind issue where dragging a SurfacePolygon around the globe and then moving it back to its original position causes it to be distorted from how it originally was at that position. My understanding is that when the polygon is moved back to its original position, it should look the same. I found a similar post about this that mentioned a small calculation error could be compounding over the course of the drag causing the distortion. You can best see this problem by dragging polygons in a circular clockwise motion which will shrink the polygon. This is easily testable using the DraggableShapes example. So far I've only seen this issue with Polygons and Boxes. Circles appear to work as intended.

    Some areas of note that I've looked at are:
    1) -> getReferencePosition() - this returns the first point in the outer boundary (I feel like this should instead return the calculated center point of the polygon?)
    2) -> doMoveTo(Globe globe, Position oldReferencePosition, Position newReferencePosition) - this method is what is called as the shape is dragged.
    3) -> computeShiftedLocations(Globe globe, LatLon oldLocation, LatLon newLocation, Iterable<? extends LatLon> locations) - this method computes the transformation of the boundary points.

    I'm running off a slightly older version of the Worldwind code but when I looked at the latest code I didn't see any relevant changes that would fix this problem. I need these transformations to work for both the Globe & FlatEarth. Any assistance on the following would be very helpful:
    1) Has this bug been encountered/reproduced/fixed?
    2) Math resources on Transforming Polygons on a Globe.
    3) Any other code areas of interest.

    Thanks in advance!

  • #2
    1. I'm familiar with the effect you described. I believe you are right on track with the LatLon.computeShiftedLocations function. It was designed to maintain the orientation of a shape as it was dragged, but I agree, it suffers from distortion after significant dragging.

    2. I have a fork branch that had an attempted work around of the issue. It doesn't have a great deal of testing and the orientation changes differently than current methodology, but I do believe it does a better job of maintaining the overall shape. You're welcome to try it out, I make no guarantees, but maybe it'll get you thinking in a new direction. Instead of the cartesian point addition it uses a quaternion rotation.

    Let me know if that helps. If it really is a major issue and you can't find resolution here, please open an issue on our GitHub site.



    World Wind Team


    • #3
      Thanks Zach! I'll play around with it and let you know if I can get it working reliably.


      • #4
        glueck , Adding your fix is now preventing the polygon from shrinking now but I'm still getting some strange rotation behavior. It seems that dragging the polygon above/below the equator inverts the rotation.
        1) Drag the polygon to the right (above the equator) and it rotates clockwise.
        2) Drag the polygon to the right (below the equator) and it rotates counter-clockwise.
        3) Drag right (above the equator), then drag down (below the equator), then drag left (below the equator), then drag up (above the equator). The polygon should be in its original position but its rotation is not the same.


        • #5
          Well, we like to keep you guessing

          Ok, so how would you like the shape to stay oriented during dragging? Like I mentioned previously, the idea was to keep the shape in the same orientation on the screen. Is that the desired behavior? Or would a shape oriented to a pole or other point be a better target?
          World Wind Team


          • #6
            Hmm. I think what I'm looking for is orientation to the north pole. I'm fairly new at this so I might be mixing things up but essentially when my map is in FlatEarth mode, I would like the North/South orientation to not change. For instance, if I have a surface polygon shaped like an arrow pointing 'up', dragging it in FlatEarth mode will keep the arrow pointing up. dragging it on the Globe will keep the arrow pointing at the north pole.


            • #7
              In that case, instead of the axis of rotation being defined as the axis derived by the cross product of the two ellipsoidal positions, you'll want to explicitly define the axis (or more likely axes) to enforce the orientation.

              This is something I have thought about in the past. I don't have the time at the moment to pursue, but if I do find some time, I'll update the branch. Perhaps you can try experimenting with defining the axis of rotation in a way which maintains northward orientation.
              World Wind Team