Results 1 to 15 of 15

Thread: Hate doing Distance Formula? Use this!

  1. #1
    Join Date
    Jan 2010
    Posts
    90
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Hate doing Distance Formula? Use this!

    Apparently there's already functions for all this stuff...
    Last edited by Function; 01-25-2010 at 01:35 AM.

  2. #2
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    This looks more like the midpoint formula than the distance formula...
    :-)

  3. #3
    Join Date
    Jan 2010
    Posts
    90
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Method View Post
    This looks more like the midpoint formula than the distance formula...
    Okay I'm going crazy I just made this function and its midpoint thats what I meant lol gah

  4. #4
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    how does 0, 0 and 5, 5, result a mid point of (2, 2)?

  5. #5
    Join Date
    Jan 2010
    Posts
    90
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Timer View Post
    how does 0, 0 and 5, 5, result a mid point of (2, 2)?
    I have it using whole integers sorry

  6. #6
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    haahhaha

    SCAR Code:
    program Midpoint;

    var
      x1, y1, x2, y2: Extended;

    procedure Points;
    begin
      x1 := 0;
      y1 := 0;
      x2 := 5;
      y2 := 5;
    end;

    procedure MidPoint;
    var
      x, y: Extended;
    begin
      x := (x2 + x1) div 2;
      y := (y2 + y1) div 2;
      WriteLn('The Midpoint between (' + FloatToStr(x1) + ', ' + FloatToStr(y1) + ') and (' +
      FloatToStr(x2) + ', ' + FloatToStr(y2) + ') is (' +
      FloatToStr(x) + ', ' + FloatToStr(y) + ')!');
    end;

    begin
      Points;
      MidPoint;
    end.

    Code:
    Successfully compiled (7 ms)
    The Midpoint between (0, 0) and (5, 5) is (2.5, 2.5)!
    Successfully executed

  7. #7
    Join Date
    Jan 2010
    Posts
    90
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Timer View Post
    haahhaha

    SCAR Code:
    program Midpoint;

    var
      x1, y1, x2, y2: Extended;

    procedure Points;
    begin
      x1 := 0;
      y1 := 0;
      x2 := 5;
      y2 := 5;
    end;

    procedure MidPoint;
    var
      x, y: Extended;
    begin
      x := (x2 + x1) div 2;
      y := (y2 + y1) div 2;
      WriteLn('The Midpoint between (' + FloatToStr(x1) + ', ' + FloatToStr(y1) + ') and (' +
      FloatToStr(x2) + ', ' + FloatToStr(y2) + ') is (' +
      FloatToStr(x) + ', ' + FloatToStr(y) + ')!');
    end;

    begin
      Points;
      MidPoint;
    end.

    Code:
    Successfully compiled (7 ms)
    The Midpoint between (0, 0) and (5, 5) is (2.5, 2.5)!
    Successfully executed
    Is extended an integer with decimal?

  8. #8
    Join Date
    Jan 2007
    Posts
    834
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Function View Post
    Is extended an integer with decimal?
    Bullseye.

  9. #9
    Join Date
    Jan 2010
    Posts
    90
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Junkj View Post
    Bullseye.
    Cool thanks. And sorry for being such a noob :/ new to this

  10. #10
    Join Date
    Mar 2007
    Posts
    1,700
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Distance:
    SCAR Code:
    Distance(x1, y1, x2, y2);
    Midpoint:
    SCAR Code:
    MiddleTPA([Point(x1, y1), Point(x2, y2)]);

  11. #11
    Join Date
    Jan 2010
    Posts
    90
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by lordsaturn View Post
    Distance:
    SCAR Code:
    Distance(x1, y1, x2, y2);
    Midpoint:
    SCAR Code:
    MiddleTPA([Point(x1, y1), Point(x2, y2)]);
    Good fight'd lol

  12. #12
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by lordsaturn View Post
    Distance:
    SCAR Code:
    Distance(x1, y1, x2, y2);
    Midpoint:
    SCAR Code:
    MiddleTPA([Point(x1, y1), Point(x2, y2)]);
    never thought of using MiddleTPA for that.. I have before though.

  13. #13
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Isn't MiddleTPA abstract though? It's customized to find the center of a blob or something?

  14. #14
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by Timer View Post
    haahhaha

    SCAR Code:
    program Midpoint;

    var
      x1, y1, x2, y2: Extended;

    procedure Points;
    begin
      x1 := 0;
      y1 := 0;
      x2 := 5;
      y2 := 5;
    end;

    procedure MidPoint;
    var
      x, y: Extended;
    begin
      x := (x2 + x1) div 2;
      y := (y2 + y1) div 2;
      WriteLn('The Midpoint between (' + FloatToStr(x1) + ', ' + FloatToStr(y1) + ') and (' +
      FloatToStr(x2) + ', ' + FloatToStr(y2) + ') is (' +
      FloatToStr(x) + ', ' + FloatToStr(y) + ')!');
    end;

    begin
      Points;
      MidPoint;
    end.

    Code:
    Successfully compiled (7 ms)
    The Midpoint between (0, 0) and (5, 5) is (2.5, 2.5)!
    Successfully executed
    What's so funny? This is expected behaviour. If he chose to use integers, then it will be rounded down.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  15. #15
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    Well in this case it's clearly wrongly defined behaviour though, thus you can see it in a funny way.
    Oh well, trial 'n error is your best teacher.
    I made a new script, check it out!.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •