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






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.
![]()
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!
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...
[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]



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.
There are currently 1 users browsing this thread. (0 members and 1 guests)