# Midpoint in line

**URL:** <https://community.cesium.com/t/midpoint-in-line/5578>\
**Category:** CesiumJS\
**Created:** [May 31, 2017, 2:24pm UTC](https://community.cesium.com/t/midpoint-in-line/5578 "2017-05-31T14:24:56Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Rachel\_Hwang](https://avatars.discourse-cdn.com/v4/letter/r/d78d45/32.png) [@Rachel\_Hwang](https://community.cesium.com/u/Rachel_Hwang)\
**Post date:** [May 31, 2017, 7:27pm UTC](https://community.cesium.com/t/midpoint-in-line/5578/2 "2017-05-31T19:27:21Z")

</div>

Hi Fidel,

This is a classic graphics math problem. To compute the midpoint between two points A and B, we an compute the vector between them by taking (B - A), normalizing to get the direction vector. Then multiplying this direction vector by magnitude of (B-A) multiplied by the fraction of the way we want to travel between them. Then you can just convert to Cartographic. Here’s the code for this: [http://cesiumjs.org/Cesium/Apps/Sandcastle/?src=Hello%20World.html&label=Showcases&gist=d290d6e52cdeec93ac14c8a0aef1a8b6](http://cesiumjs.org/Cesium/Apps/Sandcastle/?src=Hello%20World.html&label=Showcases&gist=d290d6e52cdeec93ac14c8a0aef1a8b6)

You can also use linear interpolation to get an intermediate point. Let me know if you want to discuss that method also.

Hope that helps!

- Rachel

---

_[View the full topic](https://community.cesium.com/t/midpoint-in-line/5578)._
