Calculating the Midpoint of a Line Segment


The midpoint of a line segment is the point on the line segment that is equidistance from each end point. By using functions which we have already created we can easily calculate the midpoint of a line segment. The first step is to find the length of the line segment. This can be found be sending the end points into the Haversine formula. Our mid point is half this distance away from either of our end points. We then have to calculate the bearing from one end point to the other. Which every end point we choose as the origin of our bearing is the point we will pass into the function that calculates a coordinate based on a point of origin, a bearing and a distance.


To calculate the midpoint of a line segment we can use the Haversine function to find the distance between the end points. We can then calculate the bearing between the points. Once we have the distance to the midpoint and the bearing we can then calculate the midpoint coordinate. This function will take in two VELatLong objects and will return one VELatLong object.


function midpoint(latlong1, latlong2){    
 var arcLength = haversineDistance(latlong1,latlong2);    
 var brng = calculateBearing(latlong1,latlong2);
    return calculateCoord(latlong1, brng, arcLength/2);
Information on the haversineDistance method can be found here:!E7DBA9A4BFD458C5!317.entry

Information on the calculateBearing method can be found here:!E7DBA9A4BFD458C5!393.entry

Information on the calculateCoord method can be found here:!E7DBA9A4BFD458C5!400.entry


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s