Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

240
Views
How to get rotated rectangle’s corner coordinates?

I am trying to get a corner coordinates of rotated rectangle. Then, create a polygon with these coordinates.

So far, I tried to use Rectangle.nortwest, southeast etc. functions but it gives me coordinates before rotation.

Rotated rectangle and created polygon picture

Here’s my code: Cesium Sandcastle

var viewer = new Cesium.Viewer("cesiumContainer");

var tl = Cesium.Cartographic.fromDegrees(43.92666513491127,37.413199590790164,0);
var tr = Cesium.Cartographic.fromDegrees(44.142734829047264,37.413199590790164,0);
var bl = Cesium.Cartographic.fromDegrees(43.92666513491127,37.29166038783867,0);
var br = Cesium.Cartographic.fromDegrees(44.142734829047264,37.29166038783867,0);

tl = Cesium.Cartographic.toCartesian(tl);
tr = Cesium.Cartographic.toCartesian(tr);
bl = Cesium.Cartographic.toCartesian(bl);
br = Cesium.Cartographic.toCartesian(br);

var cartoArr = [bl, br, tr, tl];

var convRect = viewer.entities.add({
  rectangle : {
    coordinates: Cesium.Rectangle.fromCartesianArray(cartoArr),
    material: Cesium.Color.PURPLE.withAlpha(0.7),
    rotation: -46.22552065940672
  }
});


var rect = convRect.rectangle.coordinates._value;

var northeast = Cesium.Cartographic.toCartesian(Cesium.Rectangle.northeast(rect));
var northwest = Cesium.Cartographic.toCartesian(Cesium.Rectangle.northwest(rect));
var southwest = Cesium.Cartographic.toCartesian(Cesium.Rectangle.southwest(rect));
var southeast = Cesium.Cartographic.toCartesian(Cesium.Rectangle.southeast(rect));

var cartes = [northwest, southwest, southeast, northeast];

var polygonFirst = viewer.entities.add({
    polygon : {
      hierarchy : cartes,
      material: Cesium.Color.GREEN.withAlpha(0.8),
    }
});

polygonFirst.polygon.stRotation = -46.22552065940672;

viewer.zoomTo(convRect);

Any idea about converting rectangle to polygon?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You have to calculate rotated positions using Matrix operations.

Here's Sandcastle link enter image description here

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!