Author Topic: [83+ BASIC] Rotating matix data...  (Read 5890 times)

0 Members and 2 Guests are viewing this topic.

Demon

  • Guest
[83+ BASIC] Rotating matix data...
« on: July 15, 2006, 01:02:00 pm »
What would be a quick way to rotate a Matrix 90 degrees in either direction?  And if you ran the same code again it would keep rotating it in a circle?

Second question:  how would you make something move radially around a point (IE, the center of the screen) on the homescreen (not the graphscreen), so say in a "defend-the-castle" style game where you could have to shoot all the enemies coming your way, how would you rotate a character around whatever's in the center of the screen?

Offline kalan_vod

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2715
  • Rating: +10/-0
    • View Profile
    • kalanrock.us
[83+ BASIC] Rotating matix data...
« Reply #1 on: July 15, 2006, 06:11:00 pm »
I think it would only work effeciently by going through the entire matix and rotating it. It wouldn't be too hard to make a rotating point, if you would like I could show some code for one.

Demon

  • Guest
[83+ BASIC] Rotating matix data...
« Reply #2 on: July 15, 2006, 06:20:00 pm »
QuoteBegin-kalan_vod+Jul 16 2006, 12:11 AM-->
QUOTE (kalan_vod @ Jul 16 2006, 12:11 AM)
...if you would like I could show some code for one.  

 Sure.

Liazon

  • Guest
[83+ BASIC] Rotating matix data...
« Reply #3 on: July 16, 2006, 03:06:00 am »
man, I wish I remembered this from math class.  To rotate a matrix, you need to multiply it by the right kind of matrix of the same size.  This probably only works for square matrices though.

I think there's a formula for determining what to do.  I'll get back to you on that, but first, are the matrices square?

edit: oops, I was confusing this with 3D math.  Never mind.

Offline Speler

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 857
  • Rating: +6/-2
    • View Profile
[83+ BASIC] Rotating matix data...
« Reply #4 on: July 16, 2006, 04:00:00 pm »
QUOTE
Second question: how would you make something move radially around a point (IE, the center of the screen) on the homescreen (not the graphscreen), so say in a "defend-the-castle" style game where you could have to shoot all the enemies coming your way, how would you rotate a character around whatever's in the center of the screen?

You would use sin( and cos( functions to do this inside something similar to a for( loop with the radius of the circle outside the two trig functions.

For example:

While 1
for(A,1,360
pt-On(10sin(A),10cos(A
pt-Off(10sin(A-1),10cos(A-1
End
End

Don't have enough experiance with matrices to answer the first question though sorry.

Offline kalan_vod

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2715
  • Rating: +10/-0
    • View Profile
    • kalanrock.us
[83+ BASIC] Rotating matix data...
« Reply #5 on: July 17, 2006, 04:37:00 pm »
Well, what super speler said is true and it works fine (but he wanted to use it on the home screen). If you wanted to use this on the graph screen I could make something better than what I am about to post...Well I made two versions of this, and the one I posted is using a list >.>, the other was slower and bloated...but didnt use lists :Ptongue.gif.

QUOTE
:ClrHome
:"OO
:Output(4,8,Ans
:Output(5,8,Ans
:10
:3,9,3,Ans,4,Ans,5,Ans,6,Ans,6,9,6,8,6,7,5,7,4,7,3,7,3,8→L1:3→A:Ans→C:9→B:Ans→D:1→E
:Repeat θ=45
:Output(C,D,"
:L1(2E-1→A:L1(2E→B
:Output(A,Ans,".
:Ans→D:A→C
:Repeat Ans
:getKey→θ
:End
:E+(Ans=26)-(Ans=24
:Ans+12(‾(Ans=13)+not(Ans→E
:End

Demon

  • Guest
[83+ BASIC] Rotating matix data...
« Reply #6 on: July 17, 2006, 05:04:00 pm »
That one works pretty good.  But I think I like the one that uses the sin and cos functions better because it would be easier to tell if you're making a turn and collide with something without having to use matrices.

Offline kalan_vod

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2715
  • Rating: +10/-0
    • View Profile
    • kalanrock.us
[83+ BASIC] Rotating matix data...
« Reply #7 on: July 17, 2006, 05:41:00 pm »
Yes, but you asked for something using the homescreen. If you could incorparate those functions into using the homescree, if would work best.

Demon

  • Guest
[83+ BASIC] Rotating matix data...
« Reply #8 on: July 18, 2006, 06:04:00 am »
Hmm...  I suddenly got an idea and now I like yours better...
Besides, I need to an ASCII game.  Every since I learned the wonders of xLIB, I haven't done anything in pure ASCII since...  time to revisit...

Offline kalan_vod

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2715
  • Rating: +10/-0
    • View Profile
    • kalanrock.us
[83+ BASIC] Rotating matix data...
« Reply #9 on: July 19, 2006, 11:35:00 am »
So, the flipping sprite routine you added in your sprite program is going through the matrix?

Demon

  • Guest
[83+ BASIC] Rotating matix data...
« Reply #10 on: July 20, 2006, 04:33:00 pm »
Yeah, in the pixel editor, it does rowSwap to flip vertically, so that's no prob, but there's no colSwap command, so I had to make it go through half the matrix to flip horizontal.

Offline dinhotheone

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 410
  • Rating: +2/-1
    • View Profile
[83+ BASIC] Rotating matix data...
« Reply #11 on: December 09, 2006, 11:36:00 am »
i'm not sure if you still care after these 4 months but i recently wrote a sprite rotator for a sprite editor pakage (basic) i was making. it flipps the sprite 90 degrees. but i think it would work for you. the main thing is that you take the matrix and decalre another matrix with flipped dimension so 3x2 is 2x3 then you do a nested for loop to hit all the originol dimesions and in the for loop you do
[matrix1](a,c)->[flippeddimensionmatrix]((original left,right dimension) + 1 - c,a))

in actuality the code i had was:

dim([A] -> LSize
{LSize(2),Lsize(1)} -> dim ([J]
for a, 1, Lsize(1)
for c, 1, Lsize(2)
[A](a,c) -> [J]((Lsize(2) + 1 - c), A)
end
end
[J] -> [A]
delvar [J]

Offline Halifax

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1334
  • Rating: +2/-1
    • View Profile
    • TI-Freakware
[83+ BASIC] Rotating matix data...
« Reply #12 on: December 09, 2006, 11:47:00 am »
dinhotheone your a little wealth of knowledge aren't you :)smile.gif lol sweet routine
There are 10 types of people in this world-- those that can read binary, and those that can't.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
[83+ BASIC] Rotating matix data...
« Reply #13 on: December 09, 2006, 11:59:00 am »
that sound nice, that can be cool in addition to xLIB flip sprite routine, which flip sprite horizontally only though

Demon

  • Guest
[83+ BASIC] Rotating matix data...
« Reply #14 on: December 09, 2006, 06:37:00 pm »
Wow.  And it's such a simple routine, too...
I'll try that, but instead of using a matrix, I'll make it use a Finance var so you can rotate really big selections without worrying about memory...