help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Graphical Plotting Help Needed for Windows...


From: martin_helm
Subject: Re: Graphical Plotting Help Needed for Windows...
Date: Tue, 22 Dec 2009 06:28:59 -0800 (PST)



Jason Martin-13 wrote:
> 
> Thank you Matsuoka, Ben, and Martin.  I am updating my cygwin 
> installation to get make working properly and will try to get jhandles 
> to work properly here.  I will also look at flt until I can get jhandles 
> working.  I looked at octaviz before and couldn't get the svn to attach 
> properly so I think that one is out for the time being.
> 
> Jason
> 
> 

You can fake a little bit the light functionality of jhandles with fltk by
defining yourself a function which calculates the shading (I quickly wrote
it so I cannot guarantee that everything is correct)

function C = calc_cdata(amb, dif, spec, shine, normals, lvec, vvec)
  lvec = lvec/norm(lvec);
  vvec = vvec/norm(vvec);
  normals = normals ./ repmat(sqrt (sumsq (normals, 2)), [1, 3]);
  C = amb*ones(size(normals, 1), 1) \
  + dif*diffuse(normals(:,1), normals(:,2), normals(:,3), lvec) \ 
  + spec*specular(normals(:,1), normals(:,2), normals(:,3), lvec, vvec);
endfunction

(it is analogous to what you will find in surfl)

and then use it like this 

backend("fltk")
close all; clear all; clc; format long e;
fun_function = inline('cos(x)+cos(y)+cos(z)','x','y','z');
% Don't really need to use an inline function here,
% but just to review.
points=linspace(-pi,pi,51);
[x,y,z]=meshgrid(points,points,points);
% Make a 3-D mesh grid or else graphing f won't work.
% Notice this is a grid of 51^3 = 132,651 spatial points.
f = fun_function(x,y,z);
% Make the 132,651 data points at each spatial point.
[F, v] = isosurface (x, y, z, f, 1.1); 
N = isonormals(x,y,z,f,v);
% ambience, diffuse, specular and specular shine coefficients are used 
C = calc_cdata(.5,1.0, 1.0,10.0, N, [-1;.5;-2], [-1; 0; 0]);
p = patch ("Faces", F, "Vertices", v, "FaceVertexCData", C, \ 
  "FaceColor", "interp", "EdgeColor", "none"); 
colormap(copper(256));
ca = caxis; caxis([0, ca(2)]) 
shading interp 
view(45,30) 
grid on;
title(['My Fun Function, Contour Value = ',num2str(1.1)]);
xlabel('X');ylabel('Y');zlabel('Z');
axis([-pi,pi,-pi,pi,-pi,pi]);

on my machine this takes 0.37 sec for the script and less than 1 sec to show
the graphics with fltk.

It looks like that

http://www.mhelm.de/octave/iso_with_light.png

Hope that helps.

- mh

-- 
View this message in context: 
http://old.nabble.com/Graphical-Plotting-Help-Needed-for-Windows...-tp26881157p26889181.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]