Compare commits

...

3 Commits

Author SHA1 Message Date
Nils Dagsson Moskopp 5dcf714cd1
Partially slice 3D rendered donut along its polodial direction 2023-10-16 19:20:30 +02:00
Nils Dagsson Moskopp 0c6d9a4d85
Partially slice 3D rendered donut along its torodial direction 2023-10-16 19:16:29 +02:00
Nils Dagsson Moskopp ef65de54c0
Make 3D rendered donut appear solid 2023-10-16 19:05:56 +02:00
1 changed files with 15 additions and 3 deletions

View File

@ -6,7 +6,7 @@
-- cargo-culted by erle 2023-09-18
local theta_spacing = 0.1 -- 0.07
local theta_spacing = 0.01 -- 0.07
local phi_spacing = 0.002 -- 0.02
local R1 = 1
@ -43,13 +43,25 @@ function render_frame(A, B)
local sinB = math.sin(B)
-- theta goas around the cross-sectional circle of a torus
for theta=0, 2*math.pi, theta_spacing do
local theta = 0
while theta <= 2*math.pi do
if ( theta < 2*math.pi * 1/8 ) or ( theta > 2*math.pi * 7/8 ) then
theta = theta + (theta_spacing * 16)
else
theta = theta + theta_spacing
end
-- precompute sines and cosines of theta
local costheta = math.cos(theta)
local sintheta = math.sin(theta)
-- phi goes around the center of revolution of a torus
for phi=0, 2*math.pi, phi_spacing do
local phi = 0
while phi <= 2*math.pi do
if ( phi > 2*math.pi * 3/8 ) and ( phi < 2*math.pi * 5/8 ) then
phi = phi + (phi_spacing * 128)
else
phi = phi + phi_spacing
end
-- precompute sines and cosines of phi
local cosphi = math.cos(phi)
local sinphi = math.sin(phi)