Distance between 2 Points

Discussion in 'Plugin Development' started by Mr. X, Sep 18, 2012.

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

    Mr. X

    Hi
    I have a maths problem, i have to points or coords:
    p1: 4,5
    p2: 6,3
    now i want to get the distance between the both points but, the dircet way.
    Did anyone now a simple formula?
     
  2. Offline

    Lolmewn

    Please, normal English or I won't even try to understand what you're trying to say.
     
  3. Offline

    gregthegeek

    double x = 6 - 4;
    double y = 3 - 5;
    double dist = Math.sqrt((x * x) + (y * y));
     
    Mr. X likes this.
  4. Offline

    Mr. X

    thanks
     
  5. Offline

    JazzaG

    You can use the Cartesian plane distance formula.

    distance = sqrt((x2 - x1)^2 + (y2-y1)^2)

    In your case, distance can be found by...

    distance = sqrt((4-6)^2 + (5-3)^2)
    distance = 2.83

    Hope this helped!

    More information: http://www.icoachmath.com/math_dictionary/Distance_Formula.html

    EDIT: I see I was beaten...never mind :S
     
Thread Status:
Not open for further replies.

Share This Page