• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

172
Vistas
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 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You have to calculate rotated positions using Matrix operations.

Here's Sandcastle link enter image description here

about 3 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda