In order to calculate a new point from an origin, you will also need a distance from the origin to the point in question. Here I assumed that you have a distance value available.
An option would be to create a function calculating the target point from an origin and a vector:
function CalcPosFromAltAzDist(startPoint, vectorPointing) {
var ellipsoid = Cesium.Ellipsoid.WGS84;
var ENU = new Cesium.Matrix4();
Cesium.Transforms.eastNorthUpToFixedFrame(startPoint,ellipsoid,ENU);
var myX = vectorPointing.dist * Math.cos(vectorPointing.alt * Math.PI / 180) * Math.sin(vectorPointing.az * Math.PI / 180);
var myY = vectorPointing.dist * Math.cos(vectorPointing.alt * Math.PI / 180) * Math.cos(vectorPointing.az * Math.PI / 180);
var myZ = vectorPointing.dist * Math.sin(vectorPointing.alt * Math.PI / 180);
var offset = new Cesium.Cartesian3(myX,myY,myZ);
var finalPoint = Cesium.Matrix4.multiplyByPoint(ENU, offset, new Cesium.Cartesian3());
return finalPoint;
}
I used the method eastNorthUpToFixedFrame
to compute a transformation matrix from the local ENU frame at the origin, and used that along with the cartesian offset to compute the final point.
Then you can call that function when adding the points:
function addMultiplePoints() {
Sandcastle.declare(addMultiplePoints);
var origin = Cesium.Cartesian3.fromDegrees(290.6, -35.78);
viewer.entities.add({
position: origin,
point: {
color: Cesium.Color.RED,
pixelSize: 18,
},
label: {
text: "MLG",
font: "14px Helvetica",
pixelOffset: new Cesium.Cartesian2(0.0, 20),
},
description : "MLG"
});
var H2pointing = {"alt" : 30, "az" : 0, "dist" : 150};
viewer.entities.add({
position: new CalcPosFromAltAzDist(origin, H2pointing),
point: {
color: Cesium.Color.BLUE,
pixelSize: 18,
},
label: {
text: "Hayabusa2",
font: "14px Helvetica",
pixelOffset: new Cesium.Cartesian2(0.0, 20),
},
description : "Hayabusa2"
});
}