}
public static List<LatLon> s_createSquareInViewport(WorldWindow wwd, Position position, Angle heading,
double sizeInMeters)
{
Globe globe = wwd.getModel().getGlobe();
Matrix transform = Matrix.IDENTITY;
transform = transform.multiply(globe.computeSurfaceOrientationAtPosition(position));
transform = transform.multiply(Matrix.fromRotationZ(heading.multiply(-1)));
double widthOver2 = sizeInMeters / 2.0;
double heightOver2 = sizeInMeters / 2.0;
Vec4[] points = new Vec4[]
{
new Vec4(-widthOver2, -heightOver2, 0.0).transformBy4(transform), // lower left
new Vec4(widthOver2, -heightOver2, 0.0).transformBy4(transform), // lower right
new Vec4(widthOver2, heightOver2, 0.0).transformBy4(transform), // upper right
new Vec4(-widthOver2, heightOver2, 0.0).transformBy4(transform) // upper left
};
LatLon[] locations = new LatLon[points.length];
for (int i = 0; i < locations.length; i++)
{
locations[i] = new LatLon(globe.computePositionFromPoint(points[i]));
}
return Arrays.asList(locations);
}