Is there a way to get the center position from between 2 points by using cartesian??

1. A concise explanation of the problem you’re experiencing.

for example, I’d like to get the center position from these 2 points below, into cartesian.

0: Cartesian3 {x: -3921995.456462748, y: 3367306.592566854, z: 3723758.4693907322}

1: Cartesian3 {x: -3922122.4638296547, y: 3367281.335349712, z: 3723648.2789329886}

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

I’ve made it like this below.

cartesian => latitude, longitude pair => calculate the center

initEntityBetweenPoint(pathWithLatLng,options,ClassName){
// should be like this
// pathWithLatLng = [139.3516098083, 35.9506299352, 139.3527392288, 35.9494031955];
let pairArray = this.combineLngLatTwoPair(pathWithLatLng);
var _this = this;
var entities = pairArray.map(function(pairObject) {
let centerPositionCarto = _this.getCenterPositionBetweenPoint(pairObject);
let position = _this.cesium.Cartesian3.fromRadians(
centerPositionCarto.longitude,
centerPositionCarto.latitude,
)
return new ClassName(_this.cesium,_this.viewer,position,options);
});
return (entities.length>0) ? entities : ;
}

combineLngLatTwoPair(path,isRounded=false) {

const pathToPair = path.reduce(function(result, value, index, array) {

if (index % 2 === 0) {

const pairedArray = array.slice(index, index + 4);

if(pairedArray.length == 4) {

result.push({

lng1:pairedArray[0],

lat1:pairedArray[1],

lng2:pairedArray[2],

lat2:pairedArray[3]

});

}

else if( isRounded && (index+2) == array.length){

result.push({

lng1:path[0],

lat1:path[1],

lng2:pairedArray[0],

lat2:pairedArray[1]

});

}

}

return result;

}, );

return pathToPair;

}

getCenterPositionBetweenPoint(pairObject) {
let startPoint, endPoint, geodesic, positionCarto;
startPoint = new this.cesium.Cartographic.fromDegrees(pairObject.lng1, pairObject.lat1);
endPoint = new this.cesium.Cartographic.fromDegrees(pairObject.lng2, pairObject.lat2);
geodesic = new this.cesium.EllipsoidGeodesic(startPoint, endPoint);
positionCarto = geodesic.interpolateUsingFraction(1/2);
return positionCarto;
}

``

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

to set some label on it between 2 points.

4. The Cesium version you’re using, your operating system and browser.

ver 1.59

Converting it to Cartographic and getting the center would be my suggestion as well. Does the code you posted here not produce the expected result?