Qbasicnews.com
October 01, 2020, 09:16:28 AM
 Pages: [1] 2
 Author Topic: Rotating a squared matrix  (Read 19174 times)
Clay Dragon
Member

Posts: 38

 « on: January 11, 2008, 10:21:48 PM »

Hi, I'm working on a image (Tile) editor in Qbasic and my Rotate 90 degrees function doesn't work for smaller selections within a bigger image.

So, to solve my problem I need to know how I can achieve this in QBasic:

We have this matrix and the selection I made and I wish to rotate it 90 degrees clockwise:

Before the rotation:

After the rotation:

Regards,
Clay Dragon
 Logged
Mac
Senior Member

Posts: 243

 « Reply #1 on: January 23, 2008, 03:26:57 AM »

We have this matrix and the selection I made and I wish to rotate it 90 degrees clockwise

You have A(5,5) with content such as

abcde
fghij
klmno
pqrst
uvwxy

Given you select one of the 9 interior cells
ghi
lmn
qrs

You want to rotate the adjacent cells two position clockwise. For example, if the cell chosen is r then you want the result

abcde
fghij
kvqlo
pwrmt
uxsny

Does that restate your problem correctly?

Mac
 « Last Edit: January 23, 2008, 03:32:54 AM by Mac » Logged
Mac
Senior Member

Posts: 243

 « Reply #2 on: January 23, 2008, 01:23:53 PM »

Does that restate your problem correctly?

Assuming "yes", this will do it
Code:
' Populate demo array
DIM a(5, 5) AS STRING * 1
FOR i = 1 TO 5: FOR j = 1 TO 5
k = k + 1
a(i, j) = MID\$("abcdefghijklmnopqrstuvwxy", k, 1)
NEXT j: NEXT i
' Show Rotations
DO: GOSUB Demo: LOOP WHILE R > 0
CLS
SYSTEM

Demo:
R = 0: C = 0
CLS : PRINT "Array Before"
GOSUB DumpA
PRINT "Enter coordinates of pivot point"
DO
INPUT "Enter 2, 3, or 4. Row"; R
IF R = 0 THEN RETURN
LOOP WHILE NOT ((R = 2) OR (R = 3) OR (R = 4))
DO
INPUT "Enter 2, 3, or 4. Column"; C
IF C = 0 THEN R = 0: RETURN
LOOP WHILE NOT ((C = 2) OR (C = 3) OR (C = 4))
GOSUB Rotate
PRINT "Array After"
GOSUB DumpA
LINE INPUT "Press Enter"; e\$
RETURN

Rotate:
c1\$ = a(R - 1, C - 1)
c2\$ = a(R, C - 1)
a(R - 1, C - 1) = a(R + 1, C - 1)
a(R, C - 1) = a(R + 1, C)
a(R + 1, C - 1) = a(R + 1, C + 1)
a(R + 1, C) = a(R, C + 1)
a(R + 1, C + 1) = a(R - 1, C + 1)
a(R, C + 1) = a(R - 1, C)
a(R - 1, C + 1) = c1\$
a(R - 1, C) = c2\$
RETURN

DumpA:
FOR i = 1 TO 5
LOCATE , 30
FOR j = 1 TO 5
IF i = R AND j = C THEN COLOR 13, 0 ELSE COLOR 7, 0
PRINT a(i, j);
NEXT j
PRINT
NEXT i
PRINT : PRINT
RETURN
 Logged
Clay Dragon
Member

Posts: 38

 « Reply #3 on: January 23, 2008, 09:31:20 PM »

Sorry for coming in so late, mac, but I do appreciate your help very much! However my problem is not simple as that! My first post is describing only a simple example of what I want to achieve! I want to be able to rotate any selection of 2x2, 3x3, 4x4... up to the max of the main matrix ranging from 2x2 up to 56x56.

But I got to admit it is a good start and once again I want to thank you very much for your help, mac! Sadly, I must say I wasn't expecting that such a big code snipet would be necessary to realize my first wish:

Code:
Rotate:
c1\$ = a(R - 1, C - 1)
c2\$ = a(R, C - 1)
a(R - 1, C - 1) = a(R + 1, C - 1)
a(R, C - 1) = a(R + 1, C)
a(R + 1, C - 1) = a(R + 1, C + 1)
a(R + 1, C) = a(R, C + 1)
a(R + 1, C + 1) = a(R - 1, C + 1)
a(R, C + 1) = a(R - 1, C)
a(R - 1, C + 1) = c1\$
a(R - 1, C) = c2\$
RETURN

So I guess I have to forget that idea it is to much complicated for me unless, of course, you really want to sort my problem out...

Clay Dragon

P.S. I apologize for my bad english...
 Logged
Tia
Member

Posts: 37

 « Reply #4 on: January 24, 2008, 12:53:33 AM »

usually when you need monstrous amounts of code for certain tasks you may want to separate each task into its own section.  I would start off especially if you want to do this create a menu for each rotation so that a user can select which type of rotation he/she wants to do.  Personally I am not so great at coding but one thing I do know are standards and that was beaten to hell into my brain
 Logged
Clay Dragon
Member

Posts: 38

 « Reply #5 on: January 24, 2008, 01:06:20 AM »

Thank you for your input Tia!
 Logged
Mac
Senior Member

Posts: 243

 « Reply #6 on: January 24, 2008, 10:20:08 AM »

Sorry for coming in so late
Jan 24 - "Sorry for coming in so late"

That's funny. You waited for 13 days for a reply and responded within a day. Very nice person.

Anyway, yep, it is hard. I give up. Good luck.

Mac
 Logged
Clay Dragon
Member

Posts: 38

 « Reply #7 on: January 24, 2008, 09:36:30 PM »

Sorry for coming in so late
Jan 24 - "Sorry for coming in so late"

That's funny. You waited for 13 days for a reply and responded within a day. Very nice person.

Anyway, yep, it is hard. I give up. Good luck.

Mac

I said that because you replied twice to my question in the same day! I thought I wasn't fast enough for you! That's all...

Anyway, I want to thank you again for your help!

Regards,

Clay Dragon
 « Last Edit: January 24, 2008, 09:41:43 PM by Clay Dragon » Logged
Ralph
Ancient Guru

Posts: 544

 « Reply #8 on: January 25, 2008, 01:40:58 AM »

Just as a challenge, I dug in, trying to come up with a solution for your 5x5 matrix.  I managed to write the code to do the trick for any selection of 2x2, 3x3, 4x4 and the 5x5.  I can rotate the outermost sqare 90 degrees in a clockwise or a counterclockwise direction, as many times as wanted, one by one.

As can be seen, the code is quite repetitive, in part, and is susceptible, with a little more work, of being greatly reduced by using more FOR/NEXT, or SELECT CASE/END SELECT, or DO/LOOP.  In that manner, it could easily handle any size of square, up to the limit that I get, 127x127.  Obviously, this would meet the OP's requirement of a 56x56 square.

Here's my code:

Code:
'ArrayRot, by Ralph A. Esquivel, 24 Jan 2008, creates a 5x5 array, then
'allows selecting any 2x2, 3x3 or 4x4 submatrix, or the 5x5 matrix, then
'rotate it +/-90ø (clock- or counterclock-wise), repeatedly

OPTION BASE 1 'I like to use arrays whose first element is 1.
SCREEN 12

CLS
'size of array will be S,S
SS = 5
DIM array0(SS, SS) AS STRING * 1 'initial array
DIM array1(SS, SS) AS STRING * 1 'final array

'create array0 and array1
FOR y = 1 TO SS
FOR x = 1 TO SS
array0(x, y) = m\$
array1(x, y) = m\$
NEXT x
NEXT y

GOSUB printArray0
firstLine = y * vv 'first line of text

'draw grid
GOSUB drawGrid

'PART THAT REPEATS STARTS HERE
DO
DO
'clear all text below grid
LOCATE firstLine + 1, 1
FOR i = 1 TO 12
PRINT STRING\$(78, " ")
NEXT i

'enter size of block to rotate
LOCATE firstLine + 1, 4
PRINT "Enter horizontal dimension of block to rotate 90ø (+/-2 to +/-5): ";
LINE INPUT k\$
d\$ = k\$
d = VAL(d\$)
PRINT d
LOOP WHILE d = 0 OR ABS(d) > 5

DO
DO
'clear old text
cellChosen\$ = ""
LOCATE firstLine + 2, 4
FOR i = 1 TO 11
PRINT STRING\$(78, " ")
NEXT i

'find right-bottom-most letter allowed for top of block w/ dimension chosen
rbmL\$ = array1(SS + 1 - ABS(d), SS + 1 - ABS(d))

'enter letter for left-top letter of block to rotate
a\$ = "Enter top-left cell of block (A TO " + rbmL\$ + "): "
LOCATE firstLine + 2, 4
PRINT a\$;
GOSUB inkey
L\$ = UCASE\$(k\$)
PRINT L\$
LOOP WHILE L\$ = 0 OR L\$ < "A" OR L\$ > "Z"

'find x and y values for L\$ in array1
FOR y = 1 TO SS
FOR x = 1 TO SS
'''PRINT x; y,
IF array1(x, y) = L\$ THEN
ex\$ = "Yes"
EXIT FOR
END IF
NEXT x
IF ex\$ = "Yes" THEN EXIT FOR
PRINT
NEXT y
'reset ex\$
ex\$ = ""

'evaluate if cell chosen is appropriate for block chosen
maxvalue = SS + 1 - ABS(d)
IF x > maxvalue THEN
PRINT " x ="; x; "is too large.  Choose an appopriate cell"
GOSUB pause
END IF

IF y > maxvalue THEN
PRINT " y ="; y; "is too large.  Choose an appopriate cell"
GOSUB pause
END IF

'create a temporary array for the block to be rotated
REDIM temp(x TO x + ABS(d) - 1, y TO y + ABS(d) - 1) AS STRING * 1

'rotate block chosen +/-90ø

IF d = 2 THEN
temp(x + 0, y + 0) = array1(x + 0, y + 1)
temp(x + 0, y + 1) = array1(x + 1, y + 1)

temp(x + 1, y + 0) = array1(x + 0, y + 0)
temp(x + 1, y + 1) = array1(x + 1, y + 0)

ELSEIF d = -2 THEN
temp(x + 0, y + 0) = array1(x + 1, y + 0)
temp(x + 0, y + 1) = array1(x + 0, y + 0)

temp(x + 1, y + 0) = array1(x + 1, y + 1)
temp(x + 1, y + 1) = array1(x + 0, y + 1)
END IF

IF d = 3 THEN
temp(x + 0, y + 0) = array1(x + 0, y + 2)
temp(x + 0, y + 1) = array1(x + 1, y + 2)
temp(x + 0, y + 2) = array1(x + 2, y + 2)

temp(x + 1, y + 0) = array1(x + 0, y + 1)
temp(x + 1, y + 1) = array1(x + 1, y + 1)
temp(x + 1, y + 2) = array1(x + 2, y + 1)

temp(x + 2, y + 0) = array1(x + 0, y + 0)
temp(x + 2, y + 1) = array1(x + 1, y + 0)
temp(x + 2, y + 2) = array1(x + 2, y + 0)

ELSEIF d = -3 THEN
temp(x + 0, y + 0) = array1(x + 2, y + 0)
temp(x + 0, y + 1) = array1(x + 1, y + 0)
temp(x + 0, y + 2) = array1(x + 0, y + 0)

temp(x + 1, y + 0) = array1(x + 2, y + 1)
temp(x + 1, y + 1) = array1(x + 1, y + 1)
temp(x + 1, y + 2) = array1(x + 0, y + 1)

temp(x + 2, y + 0) = array1(x + 2, y + 2)
temp(x + 2, y + 1) = array1(x + 1, y + 2)
temp(x + 2, y + 2) = array1(x + 0, y + 2)
END IF

IF d = 4 THEN
temp(x + 0, y + 0) = array1(x + 0, y + 3)
temp(x + 0, y + 1) = array1(x + 1, y + 3)
temp(x + 0, y + 2) = array1(x + 2, y + 3)
temp(x + 0, y + 3) = array1(x + 3, y + 3)

temp(x + 1, y + 0) = array1(x + 0, y + 2)
temp(x + 1, y + 1) = array1(x + 1, y + 2)
temp(x + 1, y + 2) = array1(x + 2, y + 2)
temp(x + 1, y + 3) = array1(x + 3, y + 2)

temp(x + 2, y + 0) = array1(x + 0, y + 1)
temp(x + 2, y + 1) = array1(x + 1, y + 1)
temp(x + 2, y + 2) = array1(x + 2, y + 1)
temp(x + 2, y + 3) = array1(x + 3, y + 1)

temp(x + 3, y + 0) = array1(x + 0, y + 0)
temp(x + 3, y + 1) = array1(x + 1, y + 0)
temp(x + 3, y + 2) = array1(x + 2, y + 0)
temp(x + 3, y + 3) = array1(x + 3, y + 0)

ELSEIF d = -4 THEN
temp(x + 0, y + 0) = array1(x + 3, y + 0)
temp(x + 0, y + 1) = array1(x + 2, y + 0)
temp(x + 0, y + 2) = array1(x + 1, y + 0)
temp(x + 0, y + 3) = array1(x + 0, y + 0)

temp(x + 1, y + 0) = array1(x + 3, y + 1)
temp(x + 1, y + 1) = array1(x + 2, y + 1)
temp(x + 1, y + 2) = array1(x + 1, y + 1)
temp(x + 1, y + 3) = array1(x + 0, y + 1)

temp(x + 2, y + 0) = array1(x + 3, y + 2)
temp(x + 2, y + 1) = array1(x + 2, y + 2)
temp(x + 2, y + 2) = array1(x + 1, y + 2)
temp(x + 2, y + 3) = array1(x + 0, y + 2)

temp(x + 3, y + 0) = array1(x + 3, y + 3)
temp(x + 3, y + 1) = array1(x + 2, y + 3)
temp(x + 3, y + 2) = array1(x + 1, y + 3)
temp(x + 3, y + 3) = array1(x + 0, y + 3)
END IF

IF d = 5 THEN
temp(x + 0, y + 0) = array1(x + 0, y + 4)
temp(x + 0, y + 1) = array1(x + 1, y + 4)
temp(x + 0, y + 2) = array1(x + 2, y + 4)
temp(x + 0, y + 3) = array1(x + 3, y + 4)
temp(x + 0, y + 4) = array1(x + 4, y + 4)

temp(x + 1, y + 0) = array1(x + 0, y + 3)
temp(x + 1, y + 1) = array1(x + 1, y + 3)
temp(x + 1, y + 2) = array1(x + 2, y + 3)
temp(x + 1, y + 3) = array1(x + 3, y + 3)
temp(x + 1, y + 4) = array1(x + 4, y + 3)

temp(x + 2, y + 0) = array1(x + 0, y + 2)
temp(x + 2, y + 1) = array1(x + 1, y + 2)
temp(x + 2, y + 2) = array1(x + 2, y + 2)
temp(x + 2, y + 3) = array1(x + 3, y + 2)
temp(x + 2, y + 4) = array1(x + 4, y + 2)

temp(x + 3, y + 0) = array1(x + 0, y + 1)
temp(x + 3, y + 1) = array1(x + 1, y + 1)
temp(x + 3, y + 2) = array1(x + 2, y + 1)
temp(x + 3, y + 3) = array1(x + 3, y + 1)
temp(x + 3, y + 4) = array1(x + 4, y + 1)

temp(x + 4, y + 0) = array1(x + 0, y + 0)
temp(x + 4, y + 1) = array1(x + 1, y + 0)
temp(x + 4, y + 2) = array1(x + 2, y + 0)
temp(x + 4, y + 3) = array1(x + 3, y + 0)
temp(x + 4, y + 4) = array1(x + 4, y + 0)

ELSEIF d = -5 THEN
temp(x + 0, y + 0) = array1(x + 4, y + 0)
temp(x + 0, y + 1) = array1(x + 3, y + 0)
temp(x + 0, y + 2) = array1(x + 2, y + 0)
temp(x + 0, y + 3) = array1(x + 1, y + 0)
temp(x + 0, y + 4) = array1(x + 0, y + 0)

temp(x + 1, y + 0) = array1(x + 4, y + 1)
temp(x + 1, y + 1) = array1(x + 3, y + 1)
temp(x + 1, y + 2) = array1(x + 2, y + 1)
temp(x + 1, y + 3) = array1(x + 1, y + 1)
temp(x + 1, y + 4) = array1(x + 0, y + 1)

temp(x + 2, y + 0) = array1(x + 4, y + 2)
temp(x + 2, y + 1) = array1(x + 3, y + 2)
temp(x + 2, y + 2) = array1(x + 2, y + 2)
temp(x + 2, y + 3) = array1(x + 1, y + 2)
temp(x + 2, y + 4) = array1(x + 0, y + 2)

temp(x + 3, y + 0) = array1(x + 4, y + 3)
temp(x + 3, y + 1) = array1(x + 3, y + 3)
temp(x + 3, y + 2) = array1(x + 2, y + 3)
temp(x + 3, y + 3) = array1(x + 1, y + 3)
temp(x + 3, y + 4) = array1(x + 0, y + 3)

temp(x + 4, y + 0) = array1(x + 4, y + 4)
temp(x + 4, y + 1) = array1(x + 3, y + 4)
temp(x + 4, y + 2) = array1(x + 2, y + 4)
temp(x + 4, y + 3) = array1(x + 1, y + 4)
temp(x + 4, y + 4) = array1(x + 0, y + 4)
END IF

'change elements in array1 to those in temp, the rotated block
IF d = 2 OR d = -2 THEN
array1(x + 0, y + 0) = temp(x + 0, y + 0)
array1(x + 0, y + 1) = temp(x + 0, y + 1)

array1(x + 1, y + 0) = temp(x + 1, y + 0)
array1(x + 1, y + 1) = temp(x + 1, y + 1)
END IF

IF d = 3 OR d = -3 THEN
array1(x + 0, y + 0) = temp(x + 0, y + 0)
array1(x + 0, y + 1) = temp(x + 0, y + 1)
array1(x + 0, y + 2) = temp(x + 0, y + 2)

array1(x + 1, y + 0) = temp(x + 1, y + 0)
array1(x + 1, y + 1) = temp(x + 1, y + 1)
array1(x + 1, y + 2) = temp(x + 1, y + 2)

array1(x + 2, y + 0) = temp(x + 2, y + 0)
array1(x + 2, y + 1) = temp(x + 2, y + 1)
array1(x + 2, y + 2) = temp(x + 2, y + 2)
END IF

IF d = 4 OR d = -4 THEN
array1(x + 0, y + 0) = temp(x + 0, y + 0)
array1(x + 0, y + 1) = temp(x + 0, y + 1)
array1(x + 0, y + 2) = temp(x + 0, y + 2)
array1(x + 0, y + 3) = temp(x + 0, y + 3)

array1(x + 1, y + 0) = temp(x + 1, y + 0)
array1(x + 1, y + 1) = temp(x + 1, y + 1)
array1(x + 1, y + 2) = temp(x + 1, y + 2)
array1(x + 1, y + 3) = temp(x + 1, y + 3)

array1(x + 2, y + 0) = temp(x + 2, y + 0)
array1(x + 2, y + 1) = temp(x + 2, y + 1)
array1(x + 2, y + 2) = temp(x + 2, y + 2)
array1(x + 2, y + 3) = temp(x + 2, y + 3)

array1(x + 3, y + 0) = temp(x + 3, y + 0)
array1(x + 3, y + 1) = temp(x + 3, y + 1)
array1(x + 3, y + 2) = temp(x + 3, y + 2)
array1(x + 3, y + 3) = temp(x + 3, y + 3)
END IF

IF d = 5 OR d = -5 THEN
array1(x + 0, y + 0) = temp(x + 0, y + 0)
array1(x + 0, y + 1) = temp(x + 0, y + 1)
array1(x + 0, y + 2) = temp(x + 0, y + 2)
array1(x + 0, y + 3) = temp(x + 0, y + 3)
array1(x + 0, y + 4) = temp(x + 0, y + 4)

array1(x + 1, y + 0) = temp(x + 1, y + 0)
array1(x + 1, y + 1) = temp(x + 1, y + 1)
array1(x + 1, y + 2) = temp(x + 1, y + 2)
array1(x + 1, y + 3) = temp(x + 1, y + 3)
array1(x + 1, y + 4) = temp(x + 1, y + 4)

array1(x + 2, y + 0) = temp(x + 2, y + 0)
array1(x + 2, y + 1) = temp(x + 2, y + 1)
array1(x + 2, y + 2) = temp(x + 2, y + 2)
array1(x + 2, y + 3) = temp(x + 2, y + 3)
array1(x + 2, y + 4) = temp(x + 2, y + 4)

array1(x + 3, y + 0) = temp(x + 3, y + 0)
array1(x + 3, y + 1) = temp(x + 3, y + 1)
array1(x + 3, y + 2) = temp(x + 3, y + 2)
array1(x + 3, y + 3) = temp(x + 3, y + 3)
array1(x + 3, y + 4) = temp(x + 3, y + 4)

array1(x + 4, y + 0) = temp(x + 4, y + 0)
array1(x + 4, y + 1) = temp(x + 4, y + 1)
array1(x + 4, y + 2) = temp(x + 4, y + 2)
array1(x + 4, y + 3) = temp(x + 4, y + 3)
array1(x + 4, y + 4) = temp(x + 4, y + 4)
END IF

'print new array1
GOSUB printArray1

LOCATE 17, 4
PRINT "Press <Esc> to quit exit program, any other key to continue"
GOSUB inkey
IF k\$ = CHR\$(27) THEN END
LOOP

END

'--------------
'DATA FOR ARRAY
DATA A,B,C,D,E
DATA F,G, H,I,J
DATA K,L,M,N,O
DATA P,Q,R,S,T
DATA U,V,W,X,Y

'===========================================================================
'SUBROUTINES

printArray0:
hh = 5: vv = 2
FOR y = 1 TO SS
FOR x = 1 TO SS
LOCATE y * vv + 1, x * hh + 4: PRINT array0(x, y)
NEXT x
NEXT y
RETURN

printArray1:
hh = 5: vv = 2
FOR y = 1 TO SS
FOR x = 1 TO SS
LOCATE y * vv + 1, x * hh + 4: PRINT array1(x, y)
NEXT x
NEXT y
RETURN

drawGrid:
'the following values were obtained by trial and error for horizontal lines
ht = 14 * 3: vt = 20
FOR x = 1 TO SS + 1
LINE (x * ht, vt)-(x * ht, 9 * vt), 15
NEXT x

'the following values were obtained by trial and error for vertical lines
va = 20: vt = vt + 12
FOR y = -1 TO SS
LINE (ht, y * vt + va)-(6 * ht, y * vt + va), 15
NEXT y
RETURN

inkey:
k\$ = "": WHILE k\$ = "": k\$ = INKEY\$: WEND
RETURN

pause:
WHILE INKEY\$ = "": WEND
RETURN
 « Last Edit: January 26, 2008, 02:04:21 AM by Ralph » Logged

Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Dr_Davenstein
Na_th_an

Posts: 2052

 « Reply #9 on: January 25, 2008, 02:20:52 AM »

I also made a small example. I wrote this in FB, using -lang qb, so i hope it runs ok under QBasic. I didn't add bounds checking because I thought it might be good practice for the guy who wants the code to add it himself.

Code:
declare sub rotate_array( mat() as string, px as integer, py as integer, swath as integer )

screen 13
DEFINT A-Z

dim mat(1 to 5, 1 to 5) as string
dim x, y, ch, px, py, swath

for y = 1 to ubound(mat,2)
for x = 1 to ubound(mat,1)

mat(x,y) = chr\$(ch+65)
ch = ch + 1

next x
next y

for y = 1 to ubound(mat,2)
for x = 1 to ubound(mat,1)

locate (y*2)-1,(x*2)-1
print mat(x,y);

locate (y*2)-1,((x+6)*2)-1
print mat(x,y);

next x
next y

px = 3
py = 3
swath = 1

rotate_array( mat(), px, py, swath )

cls
color(15)

for y = 1 to ubound(mat,2)
for x = 1 to ubound(mat,1)

locate (y*2)-1, (x*2)-1
print mat(x,y);

next x
next y

sub rotate_array( mat() as string, px as integer, py as integer, swath as integer )
'BEWARE: NO BOUNDS CHECKING!!!
'adding it might be good practice

dim x, y as integer
dim temp( ubound(mat,1), ubound(mat,2) ) as string

for y = 1 to ubound(mat,2)
for x = 1 to ubound(mat,1)

temp(x,y) = mat(x,y)

next x
next y

for y = -swath to swath
for x = -swath to swath

color(4)
locate ((py-x)*2)-1, ((px+y)*2)-1
print temp(px+y,py-x);

mat(px+x,y+py) = temp(px+y,py-x)

color(14)
locate ((py+y)*2)-1, ((px+x+6)*2)-1
print mat(px+x,py+y);

sleep 1

next x
next y

end sub
 « Last Edit: January 25, 2008, 02:33:55 AM by Dr_Davenstein » Logged
Ralph
Ancient Guru

Posts: 544

 « Reply #10 on: January 25, 2008, 02:09:08 PM »

Dr_Davenstein:

How are you?  Say, I tried your program in QuickBASIC.  The DECLARE SUB requires "parameters".  Since I am not into SUBs enough, I changed your SUB into a subroutine, so, in front of your "rotate", I added GOSUB.  IT WORKED PERFECTLY!  I would like to say that I really feel awed with your very short coding, and I will study it intensely, so that I may learn!  Thank you for posting it.

Of course, to reach the OP's goal, he will have to change from SCREEN 13 to SCREEN 12.  And, I don't know if we can accomodate his array with dimension 56x56!
 « Last Edit: January 26, 2008, 02:17:06 AM by Ralph » Logged

Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Clay Dragon
Member

Posts: 38

 « Reply #11 on: January 25, 2008, 02:56:56 PM »

Hey guys, both of your code work are awesome! I can't wait to see the final results!

Thank you for helping me!

Clay dragon
 Logged
Dr_Davenstein
Na_th_an

Posts: 2052

 « Reply #12 on: January 25, 2008, 09:51:20 PM »

Hi, Ralph. I've been great, really. Thanks for the compliment. How are you doing?

Since I haven't seen you for a while, I'd like to mention this because I programmed something interesting recently. Have you ever heard of anaglyph? It's the name for images/movies that require those red/blue 3d glasses to view correctly. I've always wanted to try making something like that. Well, I did and I'm pretty happy with the results. Anyway, Here's a link, if you're interested.

http://dave-stanley.dyndns.org/programs/stereo.zip

Have you programmed anything fun lately? I mean besides the code above. See ya around!
 Logged
Mac
Senior Member

Posts: 243

 « Reply #13 on: January 26, 2008, 01:39:27 AM »

Anyway, yep, it is hard. I give up. Good luck.

Evidently not too hard for the first team! Thanks for saving the thread, Ralph and Dr. Davidstein.

Mac
 Logged
Ralph
Ancient Guru

Posts: 544

 « Reply #14 on: January 26, 2008, 02:01:17 AM »

Dr_Davenstein:

Quote
Since I haven't seen you for a while
I guess the modern expresion, LOL, is in order.  I haven't ever seen you, nor you, me!  (I just couldn't pass that opportunity up!  I hope you have a good sense of humor.)

From time to time, in this or that QB forum, I see you contributing a post or two, and, usually, the theme is beyond my programming understanding and ability, so, I don't get into the responses.

As to your anaglyph files, I tried to run the first .bas program from your zip file in QB 4.5; no dice, it stopped me at the first line.  So, rather than try to convert the program to run in QB, I ran your two .exe files.  They ran very smoothly, but I am going to have to find me a pair of blue and red "eye glasses", or, at least, a blue and a red piece of cellophane.  The program seems interesting.  The second .exe program, I ran in "mode" 1, the one you seem to prefer, of the four "modes". Undoubtedly, I'll be  missing the main reason for such programs, until I can get my 3-D eye pieces!

The only interesting thing (to me) that I've done is an Excel spreadsheet with IRS Form 1040, which looks "just like" the original, except I haven't used color on it.  I did it for myself, starting out with just the calculations, and ending up with the whole form.  For my simple case, it works fine.  And, once I've inputted all the required data, I just print it out and put it in the mail.  It's been accepted by the IRS for my first go at it for the 2006 tax year, and I will do the same for 2007.  As soon as I send in 2007, I'll advance the one for 2008 as much as I can, assuming some of the probable entries, to see where I can do things to reduce the tax.  I know that there are many programs out there that do this, but, I have always preferred my own.  I always run into things that I

I have not gotten further into fb, as my needs are usually very simple, and I don't want to have to learn more "stuff" whenever I want to do a small program.  QB is so logical for my engineering mind, that I don't want to abandon the simplicity of most of what I do in QB.

 Logged

Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
 Pages: [1] 2