cylinder
This commit is contained in:
parent
1056bca3ad
commit
5e281482b4
16
context/cylinder.lua
Normal file
16
context/cylinder.lua
Normal file
@ -0,0 +1,16 @@
|
||||
function mtscad.Context:cylinder(radius, height, hollow)
|
||||
radius = math.floor(radius + 0.5)
|
||||
local min_radius, max_radius = radius * (radius - 1), radius * (radius + 1)
|
||||
for z = -radius, radius do
|
||||
for y = 0, height-1 do
|
||||
for x = -radius, radius do
|
||||
local squared = x * x + z * z
|
||||
if squared <= max_radius and (not hollow or squared >= min_radius) then
|
||||
self
|
||||
:translate(x, y, z)
|
||||
:set_node()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,13 +1,13 @@
|
||||
function mtscad.Context:dome(radius, hollow)
|
||||
local min_radius, max_radius = radius * (radius - 1), radius * (radius + 1)
|
||||
local min_radius, max_radius = radius * (radius - 1), radius * (radius + 1)
|
||||
for z = -radius, radius do
|
||||
for y = 0, radius do
|
||||
for x = -radius, radius do
|
||||
local squared = x * x + y * y + z * z
|
||||
if squared <= max_radius and (not hollow or squared >= min_radius) then
|
||||
self
|
||||
:translate(x, y, z)
|
||||
:set_node()
|
||||
self
|
||||
:translate(x, y, z)
|
||||
:set_node()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,15 +1,15 @@
|
||||
function mtscad.Context:sphere(radius, hollow)
|
||||
local min_radius, max_radius = radius * (radius - 1), radius * (radius + 1)
|
||||
for z = -radius, radius do
|
||||
for y = -radius, radius do
|
||||
for x = -radius, radius do
|
||||
local squared = x * x + y * y + z * z
|
||||
if squared <= max_radius and (not hollow or squared >= min_radius) then
|
||||
for z = -radius, radius do
|
||||
for y = -radius, radius do
|
||||
for x = -radius, radius do
|
||||
local squared = x * x + y * y + z * z
|
||||
if squared <= max_radius and (not hollow or squared >= min_radius) then
|
||||
self
|
||||
:translate(x, y, z)
|
||||
:set_node()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user