# How to get the coordinates of vertex of a geometry after rotated?

I am trying to calculate the coordinates of each vertex of a polygon. I use Cesium.Transforms.headingPitchRollToFixedFrame() to make the transform matrix and Cesium.Matrix4.multiplyByPoint() to compute the new coordinates.

The following is my code:

var viewer = new Cesium.Viewer(‘cesiumContainer’);

var entities = viewer.entities;

var center = Cesium.Cartesian3.fromDegrees(10, 0);

polygon: {

hierarchy: new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArray([0, 0,

10, 0,

0, 10]))

}

});

var p1 = new Cesium.Cartesian3.fromDegrees(0, 0);

var result1 = Cesium.Matrix4.multiplyByPoint(transform, p1, new Cesium.Cartesian3());

var a1 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(result1);

var p2 = new Cesium.Cartesian3.fromDegrees(10,0);

var result2 = Cesium.Matrix4.multiplyByPoint(transform, p2, new Cesium.Cartesian3());

var a2 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(result2);

var p3 = new Cesium.Cartesian3.fromDegrees(0,10);

var result3 = Cesium.Matrix4.multiplyByPoint(transform, p3, new Cesium.Cartesian3());

var a3 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(result3);

polygon: {

hierarchy: new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArray([

Cesium.Math.toDegrees(a1.longitude), Cesium.Math.toDegrees(a1.latitude),

Cesium.Math.toDegrees(a2.longitude), Cesium.Math.toDegrees(a2.latitude),

Cesium.Math.toDegrees(a3.longitude), Cesium.Math.toDegrees(a3.latitude)]))

}

});

viewer.zoomTo(viewer.entities);

But the result shows that the two polygons have distance between and mirror each other even without any rotation…

Hello,

I’m not really sure what you are trying to accomplish. Can you please give a little more detail? Like why are you using a transform?

Best,

Hannah

Hi Hannah,