Results 1 to 7 of 7

Thread: Distance Finder

  1. #1
    Join Date
    Apr 2007
    Posts
    2,593
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Distance Finder

    I need a script that finds distance from two points on a coordinate plane.

  2. #2
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    SCAR Code:
    program New;
    const
      Ax = 0; Ay = 0;
      Bx = 3; By = 4;
    begin
      WriteLn('Distance between the points is ' + IntToStr(Distance(Ax, Ay, Bx, By)));
    end.


  3. #3
    Join Date
    Oct 2006
    Location
    finland, helsinki
    Posts
    2,501
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Simple:

    Distance(x1, y1, x2, y2);

    Returns a INTEGER (number)

    Code:
    • Narcle: I recall Jukka releasing a bunch of scripts like this before... Its how he rolls I think. rofl
    • Solarwind: Dude, you are like... t3h s3x.
    • Hy71194: JuKKa you're a machine! You released 3 scripts in 10 minutes! :O
    • benjaa: woah.... Jukka is the man Guildminer pwns all
    • NaumanAkhlaQ: And JuKKa Is my Her0!

  4. #4
    Join Date
    Apr 2007
    Posts
    2,593
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Oh, thanks....Didn't know that existed...

    EDIT: Now how to find slope plox.

  5. #5
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Elkins121 View Post
    Oh, thanks....Didn't know that existed...

    EDIT: Now how to find slope plox.
    SCAR Code:
    program New;

    const
      ax = 0; ay = 0;
      bx = 4; by = 4;
     
    var
      Slope: Extended;

    begin
      Slope := (ay - by)/(ax - bx);
      Writeln('The gradient of the line connecting the two points is: ' + FloatToStr(Slope));
    end.

    The gradient of the line between two points is equal to the difference of the two y's divided by the difference of the two x's.

    Hmm... it automatically rounds the decimal for some reason...

  6. #6
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by ZephyrsFury View Post
    SCAR Code:
    program New;

    const
      ax = 0; ay = 0;
      bx = 4; by = 4;
     
    var
      Slope: Extended;

    begin
      Slope := (ay - by)/(ax - bx);
      Writeln('The gradient of the line connecting the two points is: ' + FloatToStr(Slope));
    end.

    The gradient of the line between two points is equal to the difference of the two y's divided by the difference of the two x's.

    Hmm... it automatically rounds the decimal for some reason...
    This works:

    SCAR Code:
    program New;

    const
      ax = 0; ay = 0;
      bx = 4; by = 5;

    var
      Slope: Extended;
      z, r : Extended;
    begin
      z := ay - by;
      r := ax - bx;
      Slope := z/r;
      Writeln('The gradient of the line connecting the two points is: ' + FloatToStr(Slope));
    end.
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  7. #7
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    If you try to divide integers, the answer will be floored (or ceiled? Floored I think). So just simply change
    Slope := (ay - by)/(ax - bx);
    to
    Slope := (ay * 1.0 - by)/(ax - bx);
    And it should work.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Creating a pick head finder, and gas finder
    By Tom_Gower in forum OSR Help
    Replies: 7
    Last Post: 11-07-2008, 07:06 AM

Posting Permissions

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