Rotating Arrays and other array operations

0 favourites
  • 5 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Hello!

    Is there some way to do array math operations like rotating, summing, subtract etc... ?

    I need to rotate an Array (yes, the values in the matrix) and sometimes sum this array in another array.

    Any info/tutorial on this?

    Thanks

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Rotation should be easy enough:

    Array2 set size to (Array.Height, Array.Width)

    For x=0 to Array.Width-1

    ...For y=0 to Array.Height-1 -> Array2 set at X:loopindex("y"), Y:loopindex("x"), value:Array1.At(loopindex("x"), loopindex("y"))

  • Rotation should be easy enough:

    Array2 set size to (Array.Height, Array.Width)

    For x=0 to Array.Width-1

    ...For y=0 to Array.Height-1 -> Array2 set at X:loopindex("y"), Y:loopindex("x"), value:Array1.At(loopindex("x"), loopindex("y"))

    Thanks!

    Can I use it to rotate clockwise or counter-clockwise? (I need to do both).

  • No... That's the same as "transpose" feature in Excel:

    https://chandoo.org/wp/2013/02/01/trans ... l-formula/

    For clockwise rotation try this:

    For x=0 to Array1.Width-1

    ...For y=0 to Array1.Height-1 -> Array2 set at

    ............X:loopindex("y")

    ............Y:((Array1.width-1)-loopindex("x")

    ............value:Array1.At(loopindex("x"), loopindex("y"))

    (This is just off the top of my head, not sure if it's correct)

  • No... That's the same as "transpose" feature in Excel:

    https://chandoo.org/wp/2013/02/01/trans ... l-formula/

    For clockwise rotation try this:

    For x=0 to Array1.Width-1

    ...For y=0 to Array1.Height-1 -> Array2 set at

    ............X:loopindex("y")

    ............Y:((Array1.width-1)-loopindex("x")

    ............value:Array1.At(loopindex("x"), loopindex("y"))

    (This is just off the top of my head, not sure if it's correct)

    Thank you! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" />

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)