Functions | |
function | geometryimages (nm, typ) bury_output() |
if (strcmp(typ,"png")) set(0 | |
*endif | if (isempty(findstr(octave_config_info("DEFS"),"HAVE_QHULL"))&&(strcmp(nm,"voronoi")||strcmp(nm,"griddata")||strcmp(nm,"convhull")||strcmp(nm,"delaunay")||strcmp(nm,"triplot"))) sombreroimage(nm |
elseif (strcmp(typ,"txt")) image_as_txt(nm) | |
elseif (strcmp(nm,"voronoi")) rand("state" | |
triplot (tri, x, y,"b") = voronoi (x, y, tri) | |
plot (vx, vy,"r") | |
plot (xc, yc,"g-","LineWidth", 3) | |
axis ([0, 1, 0, 1]) | |
legend ("Delaunay Triangulation","Voronoi Diagram") | |
print (cstrcat(nm,".", typ), cstrcat("-d", typ)) elseif(strcmp(nm | |
triplot | rand ("state", 2) x = rand (20, 1) |
triplot (tri, x, y) | |
griddata | rand ("state", 1) |
griddata (x, y, z, xx, yy) = meshgrid(linspace(-1,1,32)) | |
plot (x(k), y(k),'r-', x, y,'b+') | |
x (T(:, 2)) | |
x (T(:, 3)) | |
x (T(:, 1))] | |
y (T(:, 2)) | |
y (T(:, 3)) | |
y (T(:, 1))] | |
plot (X, Y,"b", x, y,"r*") | |
inpolygon | randn ("state", 2) |
plot (vx, vy, x(in), y(in),"r+", x(!in), y(!in),"bo") | |
endif | bury_output () = figure (1) |
set (f,"visible","off") | |
if (strcmp(nm,"voronoi")) rand("state" | |
endfunction function | sombreroimage (nm, typ) if(strcmp(typ |
fputs (fid,"+-----------------------------+\n") | |
fputs (fid,"| Image unavailable because |\n") | |
fputs (fid,"| of a missing QHULL library. |\n") | |
fclose (fid) | |
title ("Sorry, graphics not available because octave was\\ncompiled without the QHULL library.") | |
end_unwind_protect endif endfunction function | image_as_txt (nm) fid |
fputs (fid,"\n") | |
fputs (fid,"+---------------------------------+\n") | |
fputs (fid,"| Image unavailable in text mode. |\n") | |
Variables | |
defaulttextfontname | |
*endif | typ = -1 |
x = rand(10,1) | |
y = rand(10,1) | |
tri = delaunay (x, y) | |
hold | on = meshgrid(x,y) |
pc = tri2circ (tri(end,:), x, y) [-1:0.01:1] | |
xc = r * sin(pi*pc) + c(1) | |
yc = r * cos(pi*pc) + c(2) | |
z = sin(2*(x.^2+y.^2)) | |
k = convhull (x, y) | |
T = delaunay (x, y) | |
X = [ x(T(:,1)) | |
Y = [ y(T(:,1)) | |
vx = cos (pi * [-1 : 0.1: 1]) | |
vy = sin (pi * [-1 : 0.1 : 1]) | |
in = inpolygon (x, y, vx, vy) | |
endfunction | function [r, c] |
m = (y(1:end-1) - y(2:end)) ./ (x(1:end-1) - x(2:end)) | |
c = [xc, yc] | |
r = sqrt ((xc - x(1)).^2 + (yc - y(1)).^2) | |
endfunction function txt | fid = fopen (sprintf ("%s.txt", nm), "wt") |
return | |
unwind_protect | mesh (x, y, z) |
axis | ( | ) |
bury_output | ( | ) | = figure (1) |
elseif | ( | strcmp(nm,"voronoi") | ) |
elseif | ( | strcmp(typ,"txt") | ) |
fclose | ( | fid | ) |
fputs | ( | fid | , | |
"+---------------------------------+\n" | ||||
) |
fputs | ( | fid | , | |
"\n" | ||||
) |
fputs | ( | fid | , | |
"| of a missing QHULL library. |\n" | ||||
) |
fputs | ( | fid | , | |
"| Image unavailable because |\n" | ||||
) |
fputs | ( | fid | , | |
"+-----------------------------+\n" | ||||
) |
endfunction function geometryimages | ( | nm | , | |
typ | ||||
) |
griddata | ( | x | , | |
y | , | |||
z | , | |||
xx | , | |||
yy | ||||
) | = meshgrid(linspace(-1,1,32)) |
if | ( | strcmp(nm,"voronoi") | ) |
* endif if | ( | isempty(findstr(octave_config_info("DEFS"),"HAVE_QHULL"))&&(strcmp(nm,"voronoi")||strcmp(nm,"griddata")||strcmp(nm,"convhull")||strcmp(nm,"delaunay")||strcmp(nm,"triplot")) | ) |
if | ( | strcmp(typ,"png") | ) |
end_unwind_protect endif endfunction function image_as_txt | ( | nm | ) |
legend | ( | "Delaunay Triangulation" | , | |
"Voronoi Diagram" | ||||
) |
plot | ( | X | , | |
Y | , | |||
"b" | , | |||
x | , | |||
y | , | |||
"r*" | ||||
) |
unwind_protect_cleanup print | ( | cstrcat(nm,".", typ) | , | |
cstrcat("-d", typ) | ||||
) |
griddata rand | ( | "state" | , | |
1 | ||||
) |
errorbar rand | ( | "state" | , | |
2 | ||||
) | = rand (20, 1) |
inpolygon randn | ( | "state" | , | |
2 | ||||
) |
set | ( | f | , | |
"visible" | , | |||
"off" | ||||
) |
endif endfunction function sombreroimage | ( | nm | , | |
typ | ||||
) |
title | ( | " | Sorry, | |
graphics not available because octave was\\ncompiled without the QHULL library." | ||||
) |
triplot | ( | tri | , | |
x | , | |||
y | ||||
) |
x | ( | T(:, 1) | ) |
x | ( | T(:, 3) | ) |
x | ( | T(:, 2) | ) |
y | ( | T(:, 1) | ) |
y | ( | T(:, 3) | ) |
y | ( | T(:, 2) | ) |
id m = (y(1:end-1) - y(2:end)) ./ (x(1:end-1) - x(2:end)) |
unwind_protect mesh(x, y, z) |
hold on = meshgrid(x,y) |
endif return |
T = delaunay (x, y) |
x tri = delaunay (x, y) |
catch x = rand(10,1) |
otherwise y = rand(10,1) |
z = sin(2*(x.^2+y.^2)) |