program made by noob

Discuss whatever you want here--both QB and non-QB related. Anything from the DEF INT command to the meaning of life!

Moderators: Pete, Mods

Post Reply
User avatar
Raspberrypicker
Veteran
Posts: 55
Joined: Thu Aug 02, 2007 4:54 pm
Location: Florida

program made by noob

Post by Raspberrypicker »

I just thought this was really funny.

I just started using qbasic, and I'm working with 3-D rotations. So I figured I try to make the program myself before copying the turtorial's example. Look what I came out with:

**********************************************************

DIM c!(360), s!(360)

DIM SHARED x(4), y(4), z(4)
DIM x2(4), y2(4), z2(4)
DIM x3(4), y3(4)

FOR i = 1 TO 360
c!(i) = COS(i * 3.14 / 180)
s!(i) = SIN(i * 3.14 / 180)
NEXT

x(1) = 50
y(1) = 50
z(1) = 25

x(2) = 50
y(2) = 50
z(2) = -25

x(1) = 50
y(1) = 50
z(1) = 25

x(2) = 50
y(2) = 50
z(2) = -25


xcenter = 150
ycenter = 100
zcenter = 256

phi = 1
theta = 1

SCREEN 7, 0, 1, 0

DO
keyed$ = INKEY$

FOR i = 1 TO 4
x2(i) = -x(i) * s!(theta) + y(i) * c!(theta) 'controls horizontal rotation
y2(i) = -x(i) * c!(theta) * s!(phi) - y(i) * s!(theta) * s!(phi) - z(i) * c!(phi) + p 'controls vertical rotation
z2(i) = -x(i) * c!(theta) * c!(phi) - y(i) * s!(theta) * c!(phi) - z(i) 'controls distance from points
NEXT

FOR i = 1 TO 4
x3(i) = 256 * (x2(i) / (z2(i) + zcenter)) + xcenter 'controls horizontal rotation
y3(i) = 256 * (y2(i) / (z2(i) + zcenter)) + ycenter 'controls vertical rotation
NEXT
CLS

FOR i = 1 TO 4
PSET (x3(i), y3(i)), 1
NEXT

FOR i = 1 TO 3
LINE (x3(i), y3(i))-(x3(i + 1), y3(i + 1)), 15
LINE (x3(i), y3(i))-(x3(i - 1), y3(i - 1)), 15
NEXT

PCOPY 1, 0

phi = phi + 1
theta = theta + 1

IF phi > 360 THEN phi = phi - 360
IF theta > 360 THEN theta = theta - 360

LOOP UNTIL keyed$ = CHR$(27)

********************************************************

The funny thing is that it's supposed to be a square revolving around the center!
LOL!

In the end I had to use the example. :S
Fruit Pickin'
sid6.7
Veteran
Posts: 318
Joined: Tue Jun 21, 2005 8:51 am
Location: west USA
Contact:

Post by sid6.7 »

oh that is funky...

its obviously a math thing somewhere in all your
variables you have.
User avatar
Raspberrypicker
Veteran
Posts: 55
Joined: Thu Aug 02, 2007 4:54 pm
Location: Florida

Post by Raspberrypicker »

ok, well now i made a triangle revolve around a central point which looks pretty awsome, but it's still not what I want. I don't know how I came out with 3 lines instead of 4. Two lines must be the same line because in that convuluted one I made there was only 3 lines as well.

Oh well I'll fix it later. I think i need more practice before I work on 3-d rotations anyways.
Fruit Pickin'
Post Reply