Results 1 to 6 of 6

Thread: Point Slope Equation solver - Zasz.

  1. #1
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default Point Slope Equation solver - Zasz.

    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)
    Last edited by Sir R. M8gic1an; 11-14-2009 at 03:27 PM.
    I do visit every 2-6 months

  2. #2
    Join Date
    Nov 2006
    Location
    Wisconsin
    Posts
    1,629
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Hmm so it's finding the equations of lines right? My math is a little fuzzy....

    If I remember right:

    Y=mX+b

    Say you have (1,1) and (2,3)
    m(slope)= 2 (3-1 over 2-1) (slashes don't work nicely in my eyes)
    Then you have to find b so substitute
    1=2(1)=b
    b=-1

    Then you substitute whatever m and b are.... Y=2x+-1 and standard form is Ax+By=C so 2x-y=1

    Something like that....

    Hope I am right?


    Quote Originally Posted by Rubix View Post
    Quote Originally Posted by Dan Cardin View Post
    you ought to listen to Mr. Klean...he's magical!
    this.

  3. #3
    Join Date
    Feb 2007
    Location
    South East England
    Posts
    2,906
    Mentioned
    2 Post(s)
    Quoted
    8 Post(s)

    Default

    y = mx + c, Mr Klean.
    Jus' Lurkin'

  4. #4
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Mr.Klean View Post
    Hmm so it's finding the equations of lines right? My math is a little fuzzy....

    If I remember right:

    Y=mX+b

    Say you have (1,1) and (2,3)
    m(slope)= 2 (3-1 over 2-1) (slashes don't work nicely in my eyes)
    Then you have to find b so substitute
    1=2(1)=b
    b=-1

    Then you substitute whatever m and b are.... Y=2x+-1 and standard form is Ax+By=C so 2x-y=1

    Something like that....

    Hope I am right?
    But the beauty of it is all you need is 1 point and the slope...

    What you described is slope-intercept form. This is point-Slope form.

    The same thing could be done with point slope with one of those points.

    y -1 = 2(x-1)
    y -1 = 2x - 2
    y = 2x - 1 (Same answer...)
    I do visit every 2-6 months

  5. #5
    Join Date
    Mar 2009
    Location
    Illinois
    Posts
    292
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Where was this for alegbra 1 -_- lol nice

  6. #6
    Join Date
    Nov 2006
    Location
    Wisconsin
    Posts
    1,629
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Ah ok. Now all I need is a really nice solver for my physics II class


    Quote Originally Posted by Rubix View Post
    Quote Originally Posted by Dan Cardin View Post
    you ought to listen to Mr. Klean...he's magical!
    this.

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
  •