hyperbolic_paraboloid.lua
NAME
hyperbolic_paraboloid
FUNCTION
hyperbolic_paraboloid(n, r, a, b)
NOTES
Generate hyperbolic paraboloid (z = x^2/a^2 - y^2/b^2) surface.
Example:
require("plot_simple")
plot = plot_simple.new()
plot:add_static(zeGrf.new("light"))
require("hyperbolic_paraboloid")
xyz, nor = hyperbolic_paraboloid(32, 1, 1, 1)
xyz:scale(100, 100, 100)
shape = zeGrf.new("polygon")
shape:set{type = "quads", vertex = xyz,
vertex_normal = nor, color = {0, .7, .7, 1}}
plot:add(shape)
plot:animate()
NPUTS
n - slices between -r and r
r - range
a, b - hyperbolic parameters
OUTPUTS
Two zeVertex objects containing coordinates and normals of quads.
SOURCE
require("surface_generator")
function hyperbolic_paraboloid(n, r, a, b)
assert(n >= 8)
assert(r > 0)
assert(a ~= 0)
assert(b ~= 0)
a, b = a*a, b*b
local function sfunc(u, v)
return u, v, u*u/a - v*v/b
end
local function nfunc(u, v)
return zeMake.normal2(0, 0, 0, 1, 0, 2*u/a, 0, 1, -2*v/b)
end
local U, V = zeUtl.new("double", "double")
U:range(-r, r/n, 2*n+1)
U:copy(V)
local xyz = surface_generator(U, V, sfunc)
local nor = surface_generator(U, V, nfunc)
return xyz, nor
end