frame_shape.lua
NAME
frame_shape
FUNCTION
frame_shape(x0, y0, z0, x1, y1, z1)
NOTES
Create a polygon obect as a frame.
if x0 = x1, the frame is perpendicular to the x-axis.
if y0 = y1, the frame is perpendicular to the y-axis.
if z0 = z1, the frame is perpendicular to the z-axis.
INPUTS
x0, y0, z0 - the first vertex of the frame
x1, y1, z1 - the second vertex of the frame diagonal to the first
OUTPUTS
An zePolyon object
SOURCE
require("register")
function frame_shape(x0, y0, z0, x1, y1, z1)
local shape, xyz = zeGrf.new("polygon", "vertex")
shape:set{type = "quads", vertex = xyz}
if (x0 == x1) then
xyz:add(x0, y0, z0)
xyz:add(x0, y1, z0)
xyz:add(x0, y1, z1)
xyz:add(x0, y0, z1)
elseif (y0 == y1) then
xyz:add(x0, y0, z0)
xyz:add(x1, y0, z0)
xyz:add(x1, y0, z1)
xyz:add(x0, y0, z1)
elseif (z0 == z1) then
xyz:add(x0, y0, z0)
xyz:add(x1, y0, z0)
xyz:add(x1, y1, z0)
xyz:add(x0, y1, z0)
else
error("invalid input.")
end
return shape
end