Posts: 224
Threads: 7
Joined: Apr 2022
Reputation:
14
11-08-2022, 01:46 AM
(This post was last modified: 11-08-2022, 03:11 AM by vince.)
Code: (Select All) dim shared pi, p, q, d, z0, t, f, sw, sh
sw = 800
sh = 600
d = 700
z0 = 1500
pi = 4*atn(1)
dim x(16), y(16), z(16), w(16)
x(0)=0-1: y(0) =0-1: z(0) =0-1: w(0) = 0-1
x(1)= 1: y(1) =0-1: z(1) =0-1: w(1) = 0-1
x(2)= 1: y(2) = 1: z(2) =0-1: w(2) = 0-1
x(3)=0-1: y(3) = 1: z(3) =0-1: w(3) = 0-1
x(4)=0-1: y(4) =0-1: z(4) =1: w(4) = 0-1
x(5)= 1: y(5) =0-1: z(5) =1: w(5) = 0-1
x(6)= 1: y(6) = 1: z(6) =1: w(6) = 0-1
x(7)=0-1: y(7) = 1: z(7) =1: w(7) = 0-1
x( 8)=0-1: y( 8) =0-1: z( 8) =0-1: w( 8) = 1
x( 9)= 1: y( 9) =0-1: z( 9) =0-1: w( 9) = 1
x(10)= 1: y(10) = 1: z(10) =0-1: w(10) = 1
x(11)=0-1: y(11) = 1: z(11) =0-1: w(11) = 1
x(12)=0-1: y(12) =0-1: z(12) =1: w(12) = 1
x(13)= 1: y(13) =0-1: z(13) =1: w(13) = 1
x(14)= 1: y(14) = 1: z(14) =1: w(14) = 1
x(15)=0-1: y(15) = 1: z(15) =1: w(15) = 1
screen _newimage(sw, sh, 32)
do
for t = 0 to 8*pi step 0.01
cls
f=0
i = 0
proj x(i), y(i), z(i), w(i)
pset (p, q)
for i=1 to 3
proj x(i), y(i), z(i), w(i)
line -(p, q)
next
i = 0
proj x(i), y(i), z(i), w(i)
line -(p, q)
i = 4
proj x(i), y(i), z(i), w(i)
pset (p, q)
for i=4 to 7
proj x(i), y(i), z(i), w(i)
line -(p, q)
next
i = 4
proj x(i), y(i), z(i), w(i)
line -(p, q)
for i=0 to 3
proj x(i), y(i), z(i), w(i)
pset (p, q)
proj x(i+4), y(i+4), z(i+4), w(i+4)
line -(p, q)
next
f = 1
k = 8
i = 0+k
proj x(i), y(i), z(i), w(i)
pset (p, q), _rgb(255,0,0)
for i=1+k to 3+k
proj x(i), y(i), z(i), w(i)
line -(p, q), _rgb(255,0,0)
next
i = 0+k
proj x(i), y(i), z(i), w(i)
line -(p, q), _rgb(255,0,0)
i = 4+k
proj x(i), y(i), z(i), w(i)
pset (p, q), _rgb(255,0,0)
for i=4+k to 7+k
proj x(i), y(i), z(i), w(i)
line -(p, q), _rgb(255,0,0)
next
i = 4+k
proj x(i), y(i), z(i), w(i)
line -(p, q), _rgb(255,0,0)
for i=0+k to 3+k
proj x(i), y(i), z(i), w(i)
pset (p, q), _rgb(255,0,0)
proj x(i+4), y(i+4), z(i+4), w(i+4)
line -(p, q), _rgb(255,0,0)
next
for i=0 to 7
f = 0
proj x(i), y(i), z(i), w(i)
pset (p, q)
f = 1
proj x(i+k), y(i+k), z(i+k), w(i+k)
line -(p, q)
next
_display
_limit 50
next
loop
sub proj(x, y, z, w)
xx = x
yy = y*cos(t) - w*sin(t)
zz = z
ww = y*sin(t) + w*cos(t)
d2 = 3
w0 = 3
xx = xx*d2/(w0 + ww)
yy = yy*d2/(w0 + ww)
zz = zz*d2/(w0 + ww)
xxx = xx*cos(t) - zz*sin(t)
zzz = xx*sin(t) + zz*cos(t)
xx = xxx
zz = zzz
a = pi/3
b = pi/12
xxx = xx*cos(a) - yy*sin(a)
yyy = xx*sin(a) + yy*cos(a)
xx = xxx
yy = yyy
yyy = yy*cos(b) - zz*sin(b)
zzz = yy*sin(b) + zz*cos(b)
yy = yyy
zz = zzz
xx = 100*xx
yy = 100*yy
zz = 100*zz
p = sw/2 + 2*xx*d/(yy + z0)
q = sh/2 - 2*zz*d/(yy + z0)
end sub
Posts: 456
Threads: 63
Joined: Apr 2022
Reputation:
10
11-08-2022, 03:07 AM
(This post was last modified: 11-08-2022, 03:09 AM by PhilOfPerth.)
I was curious about 4D, so I copy/pasted the code, but I get an error in line 41: illegal function call. Do I need another file?
edit: I just noticed its a JS file, so I guess I'm not able to run it.
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.)
Posts: 224
Threads: 7
Joined: Apr 2022
Reputation:
14
Hi, Phil. Yes, the programs I intend to post here have only been tested in QBJS and use new high tech QBJS features.
Since this program is mostly compatible with QB64PE I have modified the above post to be so, so feel free to try the above again
Posts: 2,700
Threads: 124
Joined: Apr 2022
Reputation:
134
Before this line was missing the 32
Screen _NewImage(sw, sh, 32)
Now it's there.
b = b + ...
Posts: 490
Threads: 95
Joined: Apr 2022
Reputation:
23
11-08-2022, 03:26 AM
(This post was last modified: 11-08-2022, 06:48 PM by CharlieJV.)
[i]EDIT: OOPS, I had set my screen mode to 12, and that should have been 18. Correction made. The red color vince has in there adds a really nice touch.[/i]
Posts: 224
Threads: 7
Joined: Apr 2022
Reputation:
14
very nice, Charlie, thanks for the link.
Suppose I wanted to write a wiki article on 4D geometry with various example codes, with BAM I could start tiddling my willy away with the tiddlywiki
Posts: 490
Threads: 95
Joined: Apr 2022
Reputation:
23
11-08-2022, 03:52 AM
(This post was last modified: 11-08-2022, 06:47 PM by CharlieJV.)
(11-08-2022, 03:33 AM)vince Wrote: very nice, Charlie, thanks for the link.
Suppose I wanted to write a wiki article on 4D geometry with various example codes, with BAM I could start tiddling my willy away with the tiddlywiki
You know, one can be as happy as the day is long, tiddling one's wiki, wiki-ing one's tiddly, and throwing in a willy for the trifecta ménage-à-trois, just remember to get proper rest and nutrition.
Then again, to be here for a long time vs being here for a good time ...
Giggles aside, seeing as your code essentially works as is, I figured a link to BAM export to run the program when it is so easy to do: what the hey.
It is a really sharp program. Totally mesmerising. If I smoked the wacky tabacky, I'd have a doobie goin' while watching that animation, man.
EDIT: OOPS, I had set my screen mode to 12, and that should have been 18. Correction made. The red color vince has in there adds a really nice touch.
Posts: 456
Threads: 63
Joined: Apr 2022
Reputation:
10
(11-08-2022, 03:13 AM)vince Wrote: Hi, Phil. Yes, the programs I intend to post here have only been tested in QBJS and use new high tech QBJS features.
Since this program is mostly compatible with QB64PE I have modified the above post to be so, so feel free to try the above again
Oh wow!
Looks beautiful Vince! Looks so simple, too!
I'm not game to even look at QBJS, although I did start on Javascript a while back... I guess that's what the JS refers to?
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.)
Posts: 2,700
Threads: 124
Joined: Apr 2022
Reputation:
134
11-08-2022, 06:12 PM
vince on a roll at a few forums!
Nice translation Charlie! (I suspect it wasn't hard, vince code is pretty Basic!)
b = b + ...
Posts: 490
Threads: 95
Joined: Apr 2022
Reputation:
23
11-08-2022, 06:19 PM
(This post was last modified: 11-10-2022, 01:21 PM by CharlieJV.)
(11-08-2022, 06:12 PM)bplus Wrote: vince on a roll at a few forums!
Nice translation Charlie! (I suspect it wasn't hard, vince code is pretty Basic!)
All vince's original, and quite awesome, code.
The only required change for BAM: add a subroutine declaration at the top.
- EDIT: Oh yeah, and BAM does need the "CALL" statement to call a subroutine
Me just being fussy: changed the third parameter on _NEWIMAGE.
EDIT: OOPS, I had set my screen mode to 12, and that should have been 18. Correction made. The red color vince has in there adds a really nice touch.
|