Draw lines from center point

Hi Dear Community,

I am trying to draw lines from a center point. But things are getting weird.

I want to draw a line with 10 meter height. For example:

But lines’ heights are increasing:

Here’s my code:

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

var thetaMax = 360;

var dTheta = 90;

var R = 1500000; 

var centerLLH = Cesium.Cartographic.fromDegrees(40, 40 , 1000);

var centerXYZ = Cesium.Cartographic.toCartesian(centerLLH);



var enuTransform = Cesium.Transforms.eastNorthUpToFixedFrame(centerXYZ);



for (var theta = 0; theta < thetaMax; theta += dTheta) {
  var dX = R * Math.cos(Cesium.Math.toRadians(theta)) ; 

var dY = R * Math.sin(Cesium.Math.toRadians(theta)); 

var limitENU = new Cesium.Cartesian4(dX, dY, 0.0, 1.0);



var limitECF = new Cesium.Cartesian4();

limitECF = Cesium.Matrix4.multiplyByVector(enuTransform, limitENU, limitECF);
  

  var glowingLine = viewer.entities.add({

    name : 'Ray at ' + theta + ' degrees ENU',

    polyline : {

        positions : [
            centerXYZ,
            limitECF
        ],
        width : 5,
        material : Cesium.Color.DARKRED.withAlpha(1),        
    }
  });
  console.log([
            centerXYZ,
            limitECF 
        ]);
}


var centerEntity = viewer.entities.add({
name: 'Center',
position: new Cesium.ConstantPositionProperty(centerXYZ),
point: {
    size: 8
}
});

viewer.zoomTo(centerEntity);

Have any idea what is causing it?

Thank you!

Hi,

I could not find the origin of your problem but a quick work around would be to make sure that the height by converting to LLH again.

limitECF = Cesium.Matrix4.multiplyByVector(enuTransform, limitENU, limitECF);
var limitLLH = Cesium.Cartographic.fromCartesian(limitECF);
limitLLH.height = 10;
limitECF = Cesium.Cartographic.toCartesian(limitLLH);
1 Like

@Hazel-Leylak

Thank you for your detailed community forum post! Please move forward with @clementchdn’s suggestion - they bring up a great point. I suspect that additional information about how we handle mean sea level might give you more context here. Please checkout the following community forum post:

-Sam