Slide a rectangle along a sphere

I'm using NASA WorldWind to place a rectangle on the Earth ('sphere'). When I drag the rectangle on the sphere, the rectangle changes shape and size but the dimensions should be preserved.

What is needed to preserve the rectangle's original dimensions when it is dragged along the Earth/sphere?

EDIT

It looks like most of the code in use was copied from this example: http://worldwind31.arc.nasa.gov/svn/trunk/WorldWind/src/gov/nasa/worldwind/util/BasicDragger.java

The line of code in the example that confuses me the most is

double y = event.getMouseEvent().getComponent().getSize().height -
this.dragRefObjectPoint.y + dy - 1;


The resulting behavior is the 'rectangle' that is mapped to the globe changes shape and size.

I also want to point out my experience with computer graphics and NASA worldwind are limited. I'm especially rusty on linear algebra and very weak with geomtery. I'd appreciate suggestions on resources (outside of the obvious NASA WorldWind reference).

• How are you representing the rectangle, and how are you moving it? Can you share the relevant sections of your code? Jan 20, 2016 at 18:53
• We will need more detail on what you are trying to achieve, and what you have tried so far so we don't duplicate effort. Jan 20, 2016 at 20:20
• I'm new to this code base so I'm still figuring things out. I'll update the question with some more information when I get time.
– Erik
Jan 20, 2016 at 22:27
• There is no such thing as a straight line on a sphere. Thus no rectangle. But most likely also your coordinate system is cylindrical causing the cordinates not to be uniform. Jan 21, 2016 at 5:25
• @joojaa: A rectangle is mapped on to a sphere. The coordinates on the globe are LatLon but from what I can tell, the X and Y used aren't related.
– Erik
Jan 21, 2016 at 15:26

//note: from http://iquilezles.org/www/articles/distfunctions/distfunctions.htm