I have WGS84 points
and I should convert to local coordinates (x, y, z)
and plot in ThreeJs. I referred the below article and created a converted (refer code below)
Article: Calculate distance, bearing and more between Latitude/Longitude points :
Code: WGS84 to Local Coordinate Converter
function convertPoint(gpsPoint: GpsPoint, originPoint: GpsPoint): LocalPoint {
// calculate distance between reference point and calibration Gps points
const distanceInMeters = HaversineDistance.calculate(originPoint, gpsPoint);
const bearingAngle = calculateBearing(originPoint, gpsPoint);
const distance = distanceInMeters;
const y = -(distance * Math.cos(bearingAngle));
const x = distance * Math.sin(bearingAngle);
const z = calculateZ(gpsPoint);
return { x: x, y: y, z: z };
}
The result is not coming as expected.
The WGS84 is coming near to strait line. Find the screenshot below
But the converted local coordinates are not not strait line. it get curved.
In the code, the converted values having a big different. both x and y.
Help me to figure out where it is going wrong.