From matt@users.openverse.com Thu Sep  5 08:15:45 2002
Return-Path: <matt@users.openverse.com>
Delivered-To: andy@users.openverse.com
Received: (qmail 17931 invoked from network); 5 Sep 2002 13:15:45 -0000
Received: from unknown (HELO datapex1.datapex.com) (206.154.148.10)
  by 209.142.196.144 with SMTP; 5 Sep 2002 13:15:45 -0000
Received: from users.openverse.com (qmailr@dns2.0x0deadbeef.net [209.142.196.149])
	by datapex1.datapex.com (8.9.2/8.9.2) with SMTP id JAA08971
	for <unununium@openverse.com>; Thu, 5 Sep 2002 09:34:30 -0400 (EDT)
Received: (qmail 17925 invoked by uid 1014); 5 Sep 2002 13:15:41 -0000
Date: Thu, 5 Sep 2002 08:15:41 -0500
From: Matt <matt@users.openverse.com>
To: unununium@openverse.com
Subject: Torus Scope
Message-ID: <20020905131541.GA17887@users.openverse.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.4i
Status: RO
Content-Length: 1678

Here's your magic, with comments: the torus (with clipping).

[init]
# set constants
n = 1000; pi = acos(-1); pi2 = pi*2; rad = pi/180;

# initial angles and angle deltas
ax = 0; ay = 0; az = 0; adx = 0; ady = 0; adz = 0;

# on-beat sync stuff
width = 1 / 6; width_2 = width / 2;

# clipping vars
cx = 0; cy = 0; cz = -1;

-----

[beat]
# on-beat angle sync stuff
adx = rad * 7 * getosc(width_2, width, 0);
ady = rad * 7 * getosc(width + width_2, width, 0);
adz = rad * 7 * getosc(width * 2 + width_2, width, 0);

-----

[frame]
# old clip var
old_clip = 0;

# adjust the x, y, and z angles
ax = ax + adx; ay = ay + ady; az = az + adz;

# calc. angle sines and cosines here for speed
xcos = cos(ax); xsin = sin(ax); ycos = cos(ay); ysin = sin(ay); zcos = cos(az); zsin = sin(az);

-----

[pixel]
# low-pass filter stuff
v2 = v2 * 0.9 + v * 0.1;

# pseudo-3d polar coords
r1 = 1; r2 = (0.5 + v2 * 0);
a1 = i * pi2; a2 = i * pi2 * 60;

# convert 3d polar -> 3d rect coords
x4 = (r1 + r2 * sin(a2)) * sin(a1);
y4 = r2 * cos(a2);
z4 = (r1 + r2 * sin(a2)) * cos(a1);

# x-axis rotation
x3 = x4;
y3 = y4 * xcos - z4 * xsin;
z3 = y4 * xsin + z4 * xcos;

# y-axis rotation
x2 = x3 * ycos + z3 * ysin;
y2 = y3;
z2 = -x3 * ysin + z3 * ycos;

# z-axis rotation
x1 = x2 * zcos - y2 * zsin - cx;
y1 = x2 * zsin + y2 * zcos - cy;
z1 = z2 - cz;

# clipping
new_clip = bnot(above(z1, 0));
do_clip = bor(new_clip, old_clip);
old_clip = new_clip;

# 3d -> 2d transform, with clip check
x = if(new_clip, 0, x1 / z1);
y = if(new_clip, 0, y1 / z1);

# color
val = if(do_clip, 0, 1 - z1 / 4);
red = val; green = val; blue = val;


-- 
Matt  |  matt@users.openverse.com  |  users.openverse.com/~matt/

