Results 1 to 10 of 10

Thread: Array of array of TPA's?

  1. #1
    Join Date
    Aug 2016
    Location
    Kentucky
    Posts
    254
    Mentioned
    3 Post(s)
    Quoted
    96 Post(s)

    Default Array of array of TPA's?

    So i have a script that takes a tpa, splits them up into groups using an ATPA. Now I need to take x groups and group them back into a separate TPA all together. How can this be done?

  2. #2
    Join Date
    Aug 2016
    Location
    Kentucky
    Posts
    254
    Mentioned
    3 Post(s)
    Quoted
    96 Post(s)

  3. #3
    Join Date
    Dec 2011
    Posts
    193
    Mentioned
    5 Post(s)
    Quoted
    51 Post(s)

    Default

    Look at CombineTPA and AppendTPA.

    Simba Code:
    var
      groupA, groupB, groupC, largeGroup: TPointArray;
      Groups: T2DPointArray;
      i: Integer;
    begin
      groupA := [Point(5,5),Point(6,6),Point(7,7)];
      groupB := [Point(9,9),Point(10,10),Point(11,11)];
      groupC := [Point(13,13),Point(14,14),Point(15,15)];

      Groups := [groupA, groupB, groupC];

      for i := 0 to High(Groups) do
       AppendTPA(largeGroup, Groups[i]);

      Writeln(largeGroup);
    end.

    OSRS Color Scripts: Borland_Salamanders | Borland_Iron_Ores
    Utilities & Snippets: [Color] OSBuddy Item Looting

  4. #4
    Join Date
    Aug 2016
    Location
    Kentucky
    Posts
    254
    Mentioned
    3 Post(s)
    Quoted
    96 Post(s)

    Default

    So say the three groups are on three different edges of the screen. Once you combine them, and then get the midpoint of the tpa, would it be in the middle of the three groups? That's the goal.

  5. #5
    Join Date
    Aug 2016
    Location
    Kentucky
    Posts
    254
    Mentioned
    3 Post(s)
    Quoted
    96 Post(s)

    Default

    Quote Originally Posted by Aspect View Post
    So say the three groups are on three different edges of the screen. Once you combine them, and then get the midpoint of the tpa, would it be in the middle of the three groups? That's the goal.
    I guess I could get the midpoint of each of thebthree groups then find a formula for finding the middle of a triangle.

  6. #6
    Join Date
    Dec 2010
    Posts
    483
    Mentioned
    30 Post(s)
    Quoted
    328 Post(s)

    Default

    Though I do not believe it is the answer to your question, what your title is describing is called a 3-dimensional array.

    A TPA is a TPointArray. Therefore, "Array of array of TPA's" can be represented as: TPoint[][][]

    This can be implemented like so:
    Simba Code:
    type TPointArray3D = array of array of TPointArray;

    Or skipping the TPA typdef entirely:
    Simba Code:
    type TPointArray3D = array of array of array of TPoint;

    And can be utilized like so:
    Simba Code:
    var
      theArray: TPointArray3D;

    theArray[firstColumn][secondColumn][thirdColumn] := Point(0, 0);

    An array stores a collection of values.
    A 2D array stores a collection of arrays.
    A 3D array stores a collection of 2D arrays.

    You choose which one to use depending on how many dimensions of data you need to represent, hence the name, dimensional arrays.

    Now did you mean something else? From your description it sounds more like you need a 2D array.

  7. #7
    Join Date
    Aug 2016
    Location
    Kentucky
    Posts
    254
    Mentioned
    3 Post(s)
    Quoted
    96 Post(s)

    Default

    Quote Originally Posted by the bank View Post
    Though I do not believe it is the answer to your question, what your title is describing is called a 3-dimensional array.

    A TPA is a TPointArray. Therefore, "Array of array of TPA's" can be represented as: TPoint[][][]

    This can be implemented like so:
    Simba Code:
    type TPointArray3D = array of array of TPointArray;

    Or skipping the TPA typdef entirely:
    Simba Code:
    type TPointArray3D = array of array of array of TPoint;

    And can be utilized like so:
    Simba Code:
    var
      theArray: TPointArray3D;

    theArray[firstColumn][secondColumn][thirdColumn] = Point(0, 0);

    An array stores a collection of values.
    A 2D array stores a collection of arrays.
    A 3D array stores a collection of 2D arrays.

    You choose which one to use depending on how many dimensions of data you need to represent, hence the name, dimensional arrays. Now did you mean something else?
    Think that's what I needed. Thank you.

  8. #8
    Join Date
    Dec 2010
    Posts
    483
    Mentioned
    30 Post(s)
    Quoted
    328 Post(s)

    Default

    Quote Originally Posted by Aspect View Post
    Think that's what I needed. Thank you.
    In that case, to add onto the last post;

    Adding a point to a TPointArray3D:
    Simba Code:
    theArray[firstColumn][secondColumn][thirdColumn] = Point(0, 0);

    Adding a TPA to a TPointArray3D:
    Simba Code:
    theArray[firstColumn][secondColumn] = theTPA;

    Adding an array of TPA (ATPA?) to a TPointArray3D:
    Simba Code:
    theArray[firstColumn] = theATPA;


    So to group 3 ATPA objects:
    Simba Code:
    var
      theArray: TPointArray3D;

    theArray[0] = atpa1;
    theArray[1] = atpa2;
    theArray[2] = atpa3;

  9. #9
    Join Date
    Dec 2011
    Posts
    193
    Mentioned
    5 Post(s)
    Quoted
    51 Post(s)

    Default

    Quote Originally Posted by Aspect View Post
    So say the three groups are on three different edges of the screen. Once you combine them, and then get the midpoint of the tpa, would it be in the middle of the three groups? That's the goal.
    Not with the two functions I know for getting the middle of a TPA.

    MiddleTPA produces an average point.
    Simba Code:
    Writeln(MiddleTPA([[100,100],[200,100],[150,200]]));
    From my understanding of your post, you'd want a point of 150,150 to be returned. But this function returns 150,133 because there are two y values with 100 and only one at 200.

    Using AeroLibs TPointArray.midPnt will produce even funkier results as the function finds the middle of the TPA using the function above, but then it'll return the closest actual point in the TPA to the middle point it got. In normal use this is often desirable to make sure you're clicking a point that was actually found and not some void area in between. For your uses though, not so useful.

    There's probably a function for finding the middle of a triangle in this way. If there isn't, luckily it's fairly easy.

    Edit: If 150,150 isn't what you'd want from the above then MiddleTPA, fed with a TPA of 3 points, which are the mid points of your 3 TPAs, will work fine.

    OSRS Color Scripts: Borland_Salamanders | Borland_Iron_Ores
    Utilities & Snippets: [Color] OSBuddy Item Looting

  10. #10
    Join Date
    Dec 2013
    Location
    Pitcairn Island
    Posts
    288
    Mentioned
    20 Post(s)
    Quoted
    166 Post(s)

    Default

    Quote Originally Posted by Aspect View Post
    So i have a script that takes a tpa, splits them up into groups using an ATPA. Now I need to take x groups and group them back into a separate TPA all together. How can this be done?
    Just filter the TPAs you don't want, and then MergeTPA(ATPA).

    I must admit though - it sounds like this problem can be tackled in a much easier way, what ever it is you are doing.

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
  •