Get center of two points?

Discussion in 'Plugin Development' started by Deleted user, May 22, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Deleted user

    How can I get the center Location between two Locations?

    [​IMG]
     
  2. Offline

    BajanAmerican

    Math:
    d = SQRT(x2 - x1) + (y2-y1)


    And then just find half of that segment and you should be good.
    Eballer48
     
  3. Offline

    caseif

    The equation should be:
    d = sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2)
    And that will only return the distance between the two points. You would need to find the distance on each axis individually, then take half of that and add it to the point with the smaller value on that axis (or subtract it from the larger one).
     
    TheGreenGamerHD likes this.
  4. Offline

    Technius

    Eballer48
    Code:
    //Untested
    Location p1; //Point 1
    Location p2; //Point 2
    Location result = p1.add(p1.subtract(p2).multiply(0.5));
    
    This roughly translates to
    Code:
    p1 + (p1 - p2)/2
    
     
Thread Status:
Not open for further replies.

Share This Page