rectangles

Hello
I have 4 pairs of longitude & latitude

so is it possible to construct a rectangle?

I create cartesian and use Rectangle.fromCartographicArray, but I get minmal bounding rectangle for my image(

Thank is advance!

Kate

Kate,

fromCartographicArray should work. Are you using radians, not degrees? Do you have a code example?

Patrick

for example

ca[0] = Cartographic.fromDegrees(130.054128687,42.660675208,0);

ca[1] = Cartographic.fromDegrees(130.340099864,42.706203597, 0);

ca[2] = Cartographic.fromDegrees(130.287676997,42.88136488,0);

ca[3] = Cartographic.fromDegrees(130.000904512,42.835640026,0);

ca[4] = Cartographic.fromDegrees(130.054128687,42.660675208,0);

var extent = Rectangle.fromCartographicArray(ca);

rectangle.coordinates = new ConstantProperty(extent);

entity.position = new ConstantPositionProperty(Ellipsoid.WGS84.cartographicToCartesian(

Rectangle.center(extent, scratchCartesian), scratchCartographic));

on picture you can see, that I get bounding rectangle(

rectangle.coordinates build rectangle oriented to North? because I have rotated rectangle

4.jpg

so I try to use this formuls from http://stackoverflow.com/questions/1624574/calculate-lat-lng-of-corners-of-ground-overlay-from-kml-file

but I get wrong rotation value

SW: 60.400316388889;5.3194425
SE: 60.400824722222;5.3355405555556
NE: 60.406759444444;5.3347738888889
NW: 60.406251388889;5.3186730555556
$w=($nw_lng+$sw_lng)/2;
$e=($ne_lng+$se_lng)/2;
$n=($ne_lat+$nw_lat)/2;
$s=($se_lat+$sw_lat)/2;
$rot= rad2deg (atan ( ( $nw_lng - $sw_lng ) / ($sw_lat - $nw_lat ) / 2  ) );

The Rectangle in Cesium is always aligned to lines of latitude and longitude. Use a Polygon instead, like this Sandcastle example.

Patrick

Thank you, so much!