All you need is x1,y1, and slope.
I made a form where all you have to do is fill in those 3 values, and press calculate!
Plus a little option to print the answer to the debug for you.
SCAR Code:
//Examples to do to prove
//(2,4) m= 6
//y - 4 = 6(x-2)
//y - 4 = 6x - 12
//y = 6x - 8 - Final answer
//(-3,-3) m = 3
//y + 3 = 3(x+3)
//y + 3 = 3x + 9
//y = 3x + 6 - Final answer
//(-4,2) m = -7
//y - 2 = -7(x + 4)
//y - 2 = -7x - 28
//y = -7x - 26 - Final answer
program pointslopezasz;
var
frmDesign : TForm;
Label1 : TLabel;
Label2 : TLabel;
Label3 : TLabel;
Label4 : TLabel;
Button1 : TButton;
Button2 : TButton;
x1 : TEdit;
y1 : TEdit;
slope : TEdit;
m,dist1,dist2,x1s,y1s : extended;
globalanswer : String;
procedure actualcalc(myslope,myx1,myy1: extended);
var
sign : string;
bools : boolean;
begin
if(x1s>0)then
else
begin
sign := '+';
end;
x1s := -x1s;
y1s := -y1s;
dist1 := m * x1s;
dist2 := dist1 - y1s;
if(dist2<0)then
sign := '';
globalanswer := ('Answer: Y='+floattostr(m)+'x'+sign+''+floattostr(dist2))
end;
procedure calc(sender: TObject);
begin
m := strtofloat(slope.text);
x1s := strtofloat(x1.text);
y1s := strtofloat(y1.text);
actualcalc(m,x1s,y1s);
Label1.Caption := globalanswer;
end;
procedure print(sender: TObject);
begin
writeln(Label1.Caption);
end;
procedure InitForm;
begin
frmDesign := CreateForm;
frmDesign.Left := 250;
frmDesign.Top := 114;
frmDesign.Width := 696;
frmDesign.Height := 480;
frmDesign.Caption := 'Zasz''s Amazing Point Slope Doer';
frmDesign.Color := clBtnFace;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := false;
frmDesign.PixelsPerInch := 96;
Label1 := TLabel.Create(frmDesign);
Label1.Parent := frmDesign;
Label1.Left := 144;
Label1.Top := 56;
Label1.Width := 134;
Label1.Height := 37;
Label1.Caption := 'Answer: ';
Label1.Font.Color := clWindowText;
Label1.Font.Height := -32;
Label1.Font.Name := 'MS Sans Serif';
Label1.Font.Style := [fsBold];
Label1.ParentFont := False;
Label2 := TLabel.Create(frmDesign);
Label2.Parent := frmDesign;
Label2.Left := 104;
Label2.Top := 136;
Label2.Width := 28;
Label2.Height := 20;
Label2.Caption := 'X1:';
Label2.Font.Color := clWindowText;
Label2.Font.Height := -16;
Label2.Font.Name := 'MS Sans Serif';
Label2.Font.Style := [fsBold];
Label2.ParentFont := False;
Label3 := TLabel.Create(frmDesign);
Label3.Parent := frmDesign;
Label3.Left := 104;
Label3.Top := 168;
Label3.Width := 28;
Label3.Height := 20;
Label3.Caption := 'Y1:';
Label3.Font.Color := clWindowText;
Label3.Font.Height := -16;
Label3.Font.Name := 'MS Sans Serif';
Label3.Font.Style := [fsBold];
Label3.ParentFont := False;
Label4 := TLabel.Create(frmDesign);
Label4.Parent := frmDesign;
Label4.Left := 88;
Label4.Top := 200;
Label4.Width := 59;
Label4.Height := 20;
Label4.Caption := 'SLOPE';
Label4.Font.Color := clWindowText;
Label4.Font.Height := -16;
Label4.Font.Name := 'MS Sans Serif';
Label4.Font.Style := [fsBold];
Label4.ParentFont := False;
Button1 := TButton.Create(frmDesign);
Button1.Parent := frmDesign;
Button1.Left := 240;
Button1.Top := 288;
Button1.Width := 169;
Button1.Height := 89;
Button1.Caption := 'Calculate';
Button1.TabOrder := 8;
Button1.Onclick := @calc;
Button2 := TButton.Create(frmDesign);
Button2.Parent := frmDesign;
Button2.Left := 440;
Button2.Top := 288;
Button2.Width := 185;
Button2.Height := 89;
Button2.Caption := 'Print Answer to Debug...';
Button2.Onclick := @print;
Button2.TabOrder := 12;
x1 := TEdit.Create(frmDesign);
x1.Parent := frmDesign;
x1.Left := 160;
x1.Top := 136;
x1.Width := 121;
x1.Height := 21;
x1.TabOrder := 9;
y1 := TEdit.Create(frmDesign);
y1.Parent := frmDesign;
y1.Left := 160;
y1.Top := 168;
y1.Width := 121;
y1.Height := 21;
y1.TabOrder := 10;
slope := TEdit.Create(frmDesign);
slope.Parent := frmDesign;
slope.Left := 160;
slope.Top := 200;
slope.Width := 121;
slope.Height := 21;
slope.TabOrder := 11;
end;
procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;
procedure ShowFormModal;
begin
frmDesign.ShowModal;
end;
procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;
begin
cleardebug;
SafeInitForm;
SafeShowFormModal;
end.
If you don't want the form, you need just
SCAR Code:
m,dist1,dist2,x1s,y1s : extended;
globalanswer : String;
in globals, and this procedure
SCAR Code:
procedure actualcalc(myslope,myx1,myy1: extended);
var
sign : string;
bools : boolean;
begin
if(x1s>0)then
else
begin
sign := '+';
end;
x1s := -x1s;
y1s := -y1s;
dist1 := m * x1s;
dist2 := dist1 - y1s;
if(dist2<0)then
sign := '';
globalanswer := ('Answer: Y='+floattostr(m)+'x'+sign+''+floattostr(dist2))
end;
Im in geometry, and im a freshman. And even though this is kinda review, we have to use it to find slopes of the perpendicular of parallel lines, (i think, I don't pay much attention lol)