Results 1 to 21 of 21

Thread: Symbol.scar IsPointInTPA();

  1. #1
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default Symbol.scar IsPointInTPA();

    Just a bunch of unnecessary stuff..

    Current one:
    SCAR Code:
    {*******************************************************************************
    Function IsPointInTPA(Point:TPoint; TPA:TPointArray):Boolean;
    By: Bad Boy JH
    Description:
    *******************************************************************************}

    Function IsPointInTPA(Point:TPoint; TPA:TPointArray):Boolean;
    var I:integer;
    begin
      for i := 0 to high(TPA)-1 do
      begin
        if (TPA[i].x = Point.x) and (TPA[i].y = Point.y) then
        begin
          Result:= True
          Exit;
        end;
      end;
      Result := False
    end;

    New one
    SCAR Code:
    {*******************************************************************************
    Function IsPointInTPA(Point:TPoint; TPA:TPointArray):Boolean;
    By: Bad Boy JH
    Description:
    *******************************************************************************}

    Function IsPointInTPA(Point:TPoint; TPA:TPointArray):Boolean;
    var I:integer;
    begin
      for i := 0 to high(TPA) - 1 do
        Result := (TPA[i].x = Point.x) and (TPA[i].y = Point.y);
    end;
    Last edited by Wanted; 02-18-2010 at 02:04 AM.

  2. #2
    Join Date
    Sep 2009
    Posts
    580
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    That would slow it down a little.
    I don't check this place often, sorry.

    Currently working on - Software Engineering degree. Thank you SRL for showing me the one true path

  3. #3
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Sorry, but this won't work. It needs to break out of the loop otherwise the last points in the TPA corresponding will determine whether the argument is true or not.

  4. #4
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by IceFire908 View Post
    Sorry, but this won't work. It needs to break out of the loop otherwise the last points in the TPA corresponding will determine whether the argument is true or not.
    Ah >.< I see what you mean. Never mind then

  5. #5
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    erm, it seems that it should be looping up to high, not high -1? At the moment it looks like it will return false if the matching TPoint was the last one in the loop... If you did want to speed it up though, I think I suggested in his original thread somewhere that you can sort the TPA based on the TPoint then just compare the first point.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  6. #6
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    {*******************************************************************************
    function IsPointInTPA(Point:TPoint; TPA:TPointArray): Boolean;
    By: IceFire908
    *******************************************************************************}


    function IsPointInTPA(Point: TPoint; TPA: TPointArray): Boolean;
    var
      I: LongInt;
    begin
      for I := High(TPA) downto 0 do
        if ((TPA[I].X = Point.X) and (TPA[I].Y = Point.Y)) then
        begin
          Result:= True
          Exit;
        end;
    end;

    That's as fast as it will go SCAR side... I'll commit later when something else needs to be done.
    Last edited by Wanted; 02-13-2010 at 12:03 AM.

  7. #7
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    Isn't it faster to split the comparison?

    SCAR Code:
    function IsPointInTPA2(Point: TPoint; TPA: TPointArray): Boolean;
    var
      I: LongInt;
    begin
      for I := High(TPA) downto 0 do
        if (TPA[I].X = Point.X) then if (TPA[I].Y = Point.Y) then
        begin
          Result:= True
          Exit;
        end;
      Result := False;
    end;

  8. #8
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by nielsie95 View Post
    Isn't it faster to split the comparison?

    SCAR Code:
    function IsPointInTPA2(Point: TPoint; TPA: TPointArray): Boolean;
    var
      I: LongInt;
    begin
      for I := High(TPA) downto 0 do
        if (TPA[I].X = Point.X) then if (TPA[I].Y = Point.Y) then
        begin
          Result:= True
          Exit;
        end;
      Result := False;
    end;
    Yea I'll do that.

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

    Default

    Use WizzyPlugin's PointInTPA - same purpose, same params.

  10. #10
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    The problem of rewriting in Scar originates in that the WizzyPlugin one suddenly started crashing Scar or something or other. Unless you mean just steal the code.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

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

    Default

    Quote Originally Posted by mixster View Post
    The problem of rewriting in Scar originates in that the WizzyPlugin one suddenly started crashing Scar or something or other. Unless you mean just steal the code.
    Oh sorry, wasn't aware of that. Ignore my post then.

  12. #12
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Use nielsie's as scar doesn't have short circuit evalution. If you don't know what it is, wikipedia.


    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  13. #13
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Committed.

    Quote Originally Posted by Rasta Magician View Post
    Use nielsie's as scar doesn't have short circuit evalution. If you don't know what it is, wikipedia.


    ~RM
    I'm pretty sure I know what you mean by that.

    I hope what you meant was this:

    SRL Rev 388+
    SCAR Code:
    {*******************************************************************************
    function IsPointInTPA(Point:TPoint; TPA:TPointArray): Boolean;
    By: IceFire908
    *******************************************************************************}


    function IsPointInTPA(Point: TPoint; TPA: TPointArray): Boolean;
    var
      I: LongInt;
    begin
      for I := High(TPA) downto 0 do
        if (TPA[I].X = Point.X) then
          if (TPA[I].Y = Point.Y) then
          begin
            Result:= True
            Exit;
          end;
    end;

  14. #14
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Quote Originally Posted by Rasta Magician View Post
    Use nielsie's as scar doesn't have short circuit evalution. If you don't know what it is, wikipedia.


    ~RM
    wtf.
    Any good interpreter/language uses short circuit evaluation
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  15. #15
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Quote Originally Posted by noidea View Post
    wtf.
    Any good interpreter/language uses short circuit evaluation
    Not scar tho.

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  16. #16
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by Rasta Magician View Post
    Not scar tho.

    ~RM
    I think I can vaguely remember Wizzup? saying that SCAR had short circuit evaluation..?

  17. #17
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    It doesn't. You can easily test it and see.

    SCAR Code:
    function meow: Boolean;
    begin
      Writeln('Meow!');
      Result := True;
    end;

    begin
      Writeln('Begin');
     
      if (False) and (meow) then
        Writeln('Defying the laws of Booleans!');

      if (True) or (meow) then
        Writeln('Following the laws of Booleans!');

      Writeln('End');
    end.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  18. #18
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Quote Originally Posted by Zyt3x View Post
    I think I can vaguely remember Wizzup? saying that SCAR had short circuit evaluation..?
    SCAR Code:
    program New;

    var
      time, i: integer;
      boolF, boolT: boolean;

    begin
      boolF := False;
      boolT := True;
     
      Time := GetSystemTime;
      for i := 0 to 99999 do
        if (boolF)and(boolT) then
          wait(1);
      writeln(GetSystemTime - Time);
     
      Time := GetSystemTime;
      for i := 0 to 99999 do
        if (boolF) then
          if (boolT) then
          wait(1);
      writeln(GetSystemTime - Time);
         

    end.

    Quote Originally Posted by scar
    546
    312
    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  19. #19
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    [SPAM]
    Code:
    Successfully compiled (21 ms)
    124
    75
    Successfully executed
    Funny. [/SPAM]

  20. #20
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Timer View Post
    [SPAM]
    Code:
    Successfully compiled (21 ms)
    124
    75
    Successfully executed
    Funny. [/SPAM]
    Oh you have a faster computer what a cool kid...

  21. #21
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    /facepalm
    Stop caring about speed within the interpreter!



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

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
  •