SRL Archive - Mathematics

Hate doing Distance Formula? Use this!


Function

2010-01-24 19:34:04

Apparently there's already functions for all this stuff…

Method

2010-01-24 19:46:11

This looks more like the midpoint formula than the distance formula…

Function

2010-01-24 19:48:41

From: Method
This looks more like the midpoint formula than the distance formula…


Okay I'm going crazy I just made this function and its midpoint :duh: thats what I meant lol gah

Timer

2010-01-24 19:53:44

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

Function

2010-01-24 19:59:38

From: Timer
how does 0, 0 and 5, 5, result a mid point of (2, 2)?
:blink:


I have it using whole integers sorry

Timer

2010-01-24 20:10:03

haahhaha

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.

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

Function

2010-01-24 20:12:47

From: Timer
haahhaha

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.

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?

Mr. Doctor

2010-01-24 20:20:04

From: Function
Is extended an integer with decimal?


Bullseye.

Function

2010-01-24 20:21:12

From: Junkj
Bullseye.


Cool thanks. And sorry for being such a noob :/ new to this :D

lordsaturn

2010-01-24 20:31:39

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

Function

2010-01-24 20:35:07

From: lordsaturn
Distance:
Distance(x1, y1, x2, y2);
Midpoint:
MiddleTPA([Point(x1, y1), Point(x2, y2)]);


Good fight'd lol

Timer

2010-01-24 21:11:28

From: lordsaturn
Distance:
Distance(x1, y1, x2, y2);
Midpoint:
MiddleTPA([Point(x1, y1), Point(x2, y2)]);


never thought of using MiddleTPA for that.. I have before though. :p

Wanted

2010-01-24 23:26:37

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

Wizzup?

2010-01-25 04:45:56

From: Timer
haahhaha

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.

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.

Markus

2010-02-09 10:16:29

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.