Posts: 3,368
Threads: 195
Joined: Jan 2003
Can't think.
(see below)
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 704
Threads: 0
Joined: Dec 2002
of polygon you're trying to draw. (It seems that you're trying to draw an arbitrary one and just assuming that the line segments you're drawing will close at the end.) You use a variable t3% before defining it, only updating it after you use it the first time. (You may simply be assuming that t3% starts out at zero. Assuming that non-explicitly initialized variables have a zero value is sloppy programming and can be quite dangerous.) Using integer angles seems dangerous. That may relate to your apparent assumption that your polygon ends up closed.
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Posts: 3,368
Threads: 195
Joined: Jan 2003
Glenn, all polygons end up closed.
It's a perfect polygon that should maintain the appropriate width to height ratio and then be slanted.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 1,407
Threads: 117
Joined: Dec 2002
Are you looking for this?
Code:
SCREEN 13
CONST pi = 3.145192
start.x% = 140
start.y% = 100
poly.width% = 20
poly.length% = 40
poly.sides% = 3
poly.slant% = 180 'degrees
cur.x% = start.x%
cur.y% = start.y%
PSET (cur.x%, cur.y%)
t3 = poly.slant% * pi / 180
t2 = 2 * pi / poly.sides%
FOR i% = 1 TO poly.sides%
cur.x% = cur.x% + SIN(t3) * poly.width%
cur.y% = cur.y% + COS(t3) * poly.width%
LINE -(cur.x%, cur.y%), 15
t3 = t3 + t2
NEXT i%
Antoni
Posts: 3,368
Threads: 195
Joined: Jan 2003
Hey, GREAT! Thanks. THe rotation is good, but what I really want is
slant, like the italics are doing. Since the polygons will be drawn on a 2:1 isometric surface, I want them to be flat, not stand.
Code:
SCREEN 13
CONST pi = 3.145192
start.x% = 140
start.y% = 100
poly.width% = 20
poly.length% = 30
poly.sides% = 11
poly.rot% = 45 'degrees
poly.slant% = 45
cur.x% = start.x%
cur.y% = start.y%
PSET (cur.x%, cur.y%)
t3 = poly.rot% * pi / 180
t2 = 2 * pi / poly.sides%
FOR i% = 1 TO poly.sides%
cur.x% = cur.x% + SIN(t3) * poly.width%
cur.y% = cur.y% + COS(t3) * poly.length%
LINE -(cur.x%, cur.y%), 15
t3 = t3 + t2
NEXT i%
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 1,407
Threads: 117
Joined: Dec 2002
I should check my english dictionnary more often...
Antoni
Posts: 704
Threads: 0
Joined: Dec 2002
isn't the issue. The issue is what your code actually draws. QB doesn't know math. That's *your* job.
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Posts: 3,368
Threads: 195
Joined: Jan 2003
I know. But integers are good enough in this case.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 704
Threads: 0
Joined: Dec 2002
If they're what's making your code not work, they aren't. It seems that the code Antoni posted that seemed to work for you used values of t3 that weren't of INTEGER type.
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Posts: 3,368
Threads: 195
Joined: Jan 2003
You're right, decimals are required. However, my code had a different formula for t2, too.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.