How to get positions of points at regular intervals at a particular direction?

I have demonstrated the issue in image below:

There are two known positions ‘A’ and ‘B’ and I would like to have the positions of all the points at regular intervals between them. How to do this in Cesium.

I know of one idea… I can find line equation between the two points and then by taking point A as origin taking 10m as radius, find intersection point between line and circle to get the point 10m away in desired direction from point A.

But that is a very inefficient way. I would like to know if there is any simpler and efficient way?

Thanks and Regards,

Parthesh.

It’s not a Cesium question, just a general geo calculation question. Basically, you need to determine the bearing from point A to point B, calculate the first intermediate position starting at A going at that bearing and your desired step distance, then repeat. There’s a great resource of geographic algorithms at http://www.movable-type.co.uk/scripts/latlong.html , including Javascript sample code. You’d be interested in the “bearingTo” and “destinationPoint” functions.

Parthesh,

Take a look at EllipsoidGeodesic:

https://cesiumjs.org/Cesium/Build/Documentation/EllipsoidGeodesic.html

Kevin

Thanks Mark, the source is greatly helpful. But in this case I would prefer Kevin’s approach since Cesium itself is having a way to interpolate the points between the two given points. Although for general purposes(non-Cesium), the source is the best !

Thanks again,

Parthesh.

Thanks a lot Kevin, the method “interpolateUsingSurfaceDistance()” did the trick. I just have to pass the sampling distance as argument and put it in a for loop. Simple and efficient.

Thanks again,

Parthesh.

Can you share sample code

Hi there,

Here’s a simple code example: http://cesiumjs.org/Cesium/Apps/Sandcastle/?src=Hello%20World.html&label=Showcases&gist=5b8a00c55318737f13951039166cf588

Hope that helps!

  • Rachel