Archive for August, 2005

RenderMan

Saturday, August 27th, 2005

I was trying to get Microview up and running on one of the computers at work, and I had to delve into the world of VTK, I’ve been (re)-developing an interest in visualization and 3d software. Practically speaking, I don’t have much use for them– I am neither an artist, nor do I need visualization software for anything other than the cardiac imaging project– for which we already have Microview. But, I was looking for something cool to do, to have a reason to develop my Pythonic skills.

So far, I’ve looked at VTK, Vpython, Coin and Pivy, and Cgkit. Of these, CGKit is the only one I can get working: VTK, Coin and Pivy require compiling to work, and I can’t figure out how to jump Mingw through the hoops, and my Vpython downloads keep hanging. I managed to get CGKit, and even ran Pixie and Aqsis as renderers using it.

It doesn’t seem to be quite what I’m looking for though, and I’m wondering if anything is. My next download is ayam, going as we speak. I’m looking for an environment that facilitates modeling at the level of complexity of, say 3DSMax, but is also easily and quickly extensible (providing an IDE would be great), and doubles as a viewer.

Some of the things I’d like to work on: weird rendering algorithms (like relativistic or cartoonish rendering), texture and shading algos, and curves and surfaces, terrain layout algos. I just ordered a couple of books on Renderman from the library, it looks like a system worth knowing. Too bad POV-Ray, the only raytracing/modeling system I ever bothered learning, doesn’t have a RI interface.

Lebesgue integration

Saturday, August 27th, 2005

The concept behind Lebesgue integration is pretty simple; you can grasp it with one picture:

[illust mp]
pair xaxisend, yaxisend,y,x;
path xaxis;
height := 5cm;
overshoot = height/15;
res := 400;
stretch := 1.4;
radstodeg := 180/3.14159/cm;
x := (1,0);
y := (0,1);

% Draw axes
yaxisend = origin + height*y;
xaxisend = origin + height*x;
drawarrow origin-overshoot*y — yaxisend;
drawarrow origin-overshoot*x — xaxisend+overshoot*x;

% Draw nice function
path graph;
graph = (0, height/2)
for i = 0 upto res: .. (i/res*height, height/2 + sind(stretch*i/res*height*radstodeg)*
2cm ) endfor;
draw graph;

% Draw horiz. lines
path topline, bottomline;
yi = 13*height/50 + height/2;
yim = 3*height/50 + height/2;

label.lft(btex $y_i$ etex, (0, yi));
label.lft(btex $y_{i-1}$ etex, (0, yim));

topline = (origin — xaxisend+overshoot*x) shifted (0, yi);
bottomline = (origin — xaxisend+overshoot*x) shifted (0, yim);
draw topline dashed evenly;
draw bottomline dashed evenly;

% Get intersection points between horiz lines and func
% and corresponding points on the xaxis

(t[1], crap[1]) = graph intersectiontimes bottomline;
(t[2], crap[2]) = graph intersectiontimes topline;
(t[3], crap[3]) = subpath (t[2]+epsilon, length graph) of graph intersectiontimes topline + (t[2],
0); % the epsilon necessary to prevent it from finding t3=t2 incorrectly
(t[4], crap[4]) = subpath (t[1]+epsilon, length graph) of graph intersectiontimes
bottomline + (t[1],0);
(t[5], crap[5]) = subpath (t[4]+epsilon, length graph) of graph intersectiontimes
bottomline + (t[4], 0);
(t[6], crap[6]) = subpath (t[3]+epsilon, length graph) of graph intersectiontimes
topline + (t[3], 0);
for i = 1 upto 6:
z[i] = point t[i] of graph;
endfor

% Check location of intersection points
% fill fullcircle scaled 3bp shifted point t1 of graph;
% fill fullcircle scaled 3bp shifted point t2 of graph;
% fill fullcircle scaled 3bp shifted point t3 of graph;
% fill fullcircle scaled 3bp shifted point t4 of graph;
% fill fullcircle scaled 3bp shifted point t5 of graph;
% fill fullcircle scaled 3bp shifted point t6 of graph;

% Draw the differential areas
path a[];
for i = 0 upto 2:
a[1+i] = (x[1+2*i],0) — subpath (t[1+2*i], t[2*(i+1)]) of graph –
(x[2*(i+1)],0) — cycle;
fill a[1+i] withcolor .9white; % Change to hatching
endfor;
draw graph;

% Draw and label the subsets of the xaxis associated with the differential areas
pair setlabelpos, startlabelarrowpsn;
setlabelpos = (height, -height/4);
startlabelarrowpsn = (height/1.5, -height/5);

pickup pencircle scaled 1.25;
for i = 0 upto 2:
draw (x[1+2*i],0) — (x[2*(1+i)],0);
endfor;
pickup defaultpen;

label.lft(btex $E_i= \{ x : y_{i-1} \leq f(x) \leq y_i \}$ etex, setlabelpos);
for i = 0 upto 2:
drawarrow startlabelarrowpsn — ((x[1+2*i]+x[2*(1+i)])/2, -overshoot) — ((x[1+2*i]+x[2*
(1+i)])/2, -overshoot/5);
endfor;

% Label the main idea of Lebesgue integration
pair idealabelpos;
idealabelpos = (height, height);
label.lft(btex $y_{i-1} l(E_i) \leq A_i \leq y_i l(E_i)$ etex, idealabelpos);

[/illust]

Riemannian integration breaks up the x-axis into intervals and calculates the area of the graph of a function above these segments, then adds them up, and takes the limit reached as the size of the segments go to zero to be the integral of the function. Here, the only concept of size that is needed is that for an interval:  $ \mu : [a,b] \mapsto b-a .

Lebesgue integration instead breaks up the y-axis into intervals, and calculates the area formed by the complicated sets E_i, then takes the limit as the length of the y intervals go to zero. In this case, we need a more complicated measure  \mu : {\mathcal P}(\R) \rightarrow [0, +\infty) .

This is what we learned the first week of Real Analysis, roughly, as a motivation for studying measure theory, which allows us to construct measures that work for any set (not just \R), giving us integration over some weird spaces. Fascinating, ain’t it?

Demographics in Technical Fields

Wednesday, August 24th, 2005

I know I’ve kvetched on this point before, but now I have more hard statistics (source: “Mathematics in Public” opinion piece by Richard Schaar, Notices of the AMS Vol52):

  • 53% of incoming college students will take remedial mathematics or English courses; over half will never graduate.
  • 56% of engineering Ph.D.’s earned at U.S. universities in 2000 went to foreign nationals.
  • Between 1995 and 1999, engineering degrees awarded in China increased 37%; in the US they declined 20%.

I have a personal anecdote to the second statistic: in the grad. Stochastic process class I’m taking, 70% of the class is Indian, 30% is Chinese, and there is one white guy and one black guy. I’m not surprised, at all, by the last one– in fact, I’m surprised the discrepancy isn’t higher. But, more than 50% of our students don’t graduate? That’s ridiculous.

Why is all of this so? Borrowing from Richard Hofstadter, I think there are two reasons, both manifestations of the ever-present American anti-intellectualist tendency: 1) unreflective instrumentalism, and 2) unrestrained hedonism. The first is the idea that abstract ideas are no good, only practical skills are relevant; accordingly, math and science are only interesting (rather, tolerable) at a so-called practical level, which precludes research. The second is the consumer culture mentality that says basically, work is good only for getting money to buy the things you want. So why spend the time and effort getting a technical PhD when you could just go into, say, business?

America’s in a sad state. We’re so damned lazy!

Markov Random Fields, Wavelets, and Terrain Generation

Saturday, August 20th, 2005

For some reason– boredom?– I started to think about terrain generation, and came up with the idea of using a markov random field model and the inverse wavelet transform to generate more realistic terrain. Actually, I remember why now: I was watching a special on the biblical Exodus on tv, and they had beautiful pictures of a wadi that the Israelites may have passed through when fleeing Egypt. That reminded me of some pictures I had seen of the Wadi Rum in a travel magazine last week in the jury deliberation room, and as I was looking at the tv, I was thinking that I’ve never seen any computer generated imagery of rough terrain that has a convincing texture at medium range, where most photos are taken.

I think the problem is that the procedures used to generate the terrains are either too perfectly fractal, so there is no qualitative difference between the finer details on the crags, etc., than the geological-sized features, or too smooth (as in the ones based on fourier techniques). Since I’ve been dealing a lot with wavelets lately, they came up as a possible means for getting a good compromise between fractalness and randomness. Well, provided you have some way of getting the wavelet coefficients, and they are sufficiently random. So, why not use a random field model generated from actual landscape data?

All day, I’ve been looking for a simple introduction to random field models (MM or otherwise), and then I realized I have a pretty good intro in one of my books. Hopefully, I’ll understand it enough to implement something useful in Python.

A Library of Echoes

Thursday, August 18th, 2005

“A Library of Echoes”: that sounds like a good title for a novel, kind of like “The Constant Gardener”. But in this case, I saw this promoted as a metaphor for the effect that counter-piracy schemes will have on our society:

What these kinds of dependencies create in our society is a library of echos, things that once existed, but now are lost. Things locked in a closet somewhere never to see the light of day again. And the worst part, we won’t know what we are missing. Just imagine now, if you will, if the content locking mechanisms now being proposed and implemented in our time existed much earlier in history. Just imagine.

The full article is at K5, but it may be more interesting to do the Gedanken experiment suggested in the excerpt before reading it.

I’ve been musing about creation for a while now, so this article hit me hard. Although, I was thinking more along the tune of how almost no one does any original work– most people work in throw-away jobs, and are very replaceable (in the sense of utility, not humanity). Even among those that get ‘higher’ educations, not everyone turns out to make useful original contributions. The author of a survival guide for mathematicians I was reading earlier to prepare for my grad school admission process was almost fatalistic about this: he said 90% of PHds in mathematics don’t do any original work (i.e. other than relatively unimaginative extensions and generalizations and specializations of others’ works), and of those who do, most of them remain within the area they wrote their thesis on.

If creativity, imaginativity is such a rare thing, it begs the question of how best to foster it, and let the whole world reap the benefits. Or at least, it does the latter if you think that it should be a common resource. Sadly, it seems that the best way to achieve this first goal is to have copyright protection laws, because then the fruits of a person’s creative labors can be sold, so they are motivated to make the effort. But this also means that the second goal can’t be perfectly achieved, because not everyone has money.

Lest Darkness Falls

Wednesday, August 17th, 2005

I had ordered a bunch of books a while back from interlibrary loan, from when I had read some reviews of old classic sci-fi works, and they all came in at the same time, so today I picked up six novels:

  • Lest Darkness Falls, by L. Sprague de Camp
  • Creatures of Light and Darkness by Roger Zelazny
  • Nine Princes in Amber by Roger Zelazny
  • Jack of Shadows by Roger Zelazny
  • The Worm Ouroboros by E. R. Eddison
  • Titus Groan by Mervyn Peake

They all look really good! Over the weekend and pass two days, I’ve read Lord of Light and Donnerjack by Zelazny, and Nova by Samuel Delany. The Zelazny ones were excellent, and Nova had a decent plot— which is saying a lot for a Delany novel: the others I’ve read seem not to— so it seems that the guy who did the reviews has a good taste. Certainly, I’m enjoying Lest Darkness Falls, and looking forward to more Zelazny.

I think Zelazny is the type of writer I’d like to be: he’s poetic, but not overly so, and his books leave you wondering what subtle points you missed. And of course, his heroes are larger than life, but still human. Actually, it would be more accurate to say: if I were a writer, I’d like to be a cross between Zelazny and Neal Stephenson.

Progress in wavelet land.

Saturday, August 13th, 2005

The computer is in Papadakis’ office, so now I’m in there just about every day— I’ll even be going there this Sunday. The big rush is to get MicroView up and working, which is a lot more complicated than it should be, mostly because I don’t have root access to the math department servers. Then I could just install everything I need in the usual dl, compile, make install fashion, but I don’t, so I have to hack around it. Basically, I had to install Tcl/Tk, Python, and VTK under my home directory, which involves a lot of hunting for configuration switches and figuring out what arcane invocations are necessary to make them use each other instead of the system default installations (which wouldn’t work, since they don’t have the corresponding development headers and other stuff installed). All Friday I was working on that, and I got it to the point where Python depended on Tcl/Tk correctly, but I had to leave right after I think I figured out a way to get VTK to depend on Python and Tcl/Tk correctly. I forgot to tell Papadakis I have jury duty on Monday, so I’m going to try to get this done on Sunday so by Monday I can let him know if we need to bother the network sysadmin to try and do all this stuff at the network level…

On a less technical note, we got a new post-doc, Juan… who seems to have been one of John Benedetto’s grad students. I found that out when I asked Papadakis whether Benedetto is an EE or a math prof— he’s a math prof., at the University of Maryland. I haven’t really talked to him yet; I’m picking up a weirdly unanimated vibe from him, like he doesn’t really want to be here, working on this. I don’t know if I’m just imagining it or what; time will tell.

Refinability, reversed

Wednesday, August 10th, 2005

Recall that a function f is refinable iff there is a sequence of coefficients \alpha_k such that  f(x) = \sum_{k=1}^\infty \alpha_k f(x-k) for all x. So presumably, if I give you a refinable function, you can find the coefficients of refinability.

Question: if I give you a sequence \alpha_k (in l^2(\N) for simplicity), can you find an f \in L^2(\R) that has that sequence as its coefficients of refinability?

My mountain of work

Friday, August 5th, 2005

I’ve never been fascinated by mountain climbing, or even hiking, but after next semester, I’ll be an expert. Here’s the current list of high priority items I’ll be working on next semester:

  • the Cardiac imaging project with Papadakis
  • proctoring for the engineering college
  • 19 hours of class, with 2 of them grad level
  • studying for the general and math subject GRE exams
  • applying to grad school, and for fellowships

None of these daunt me so much as the last one: I hate asking for recommendations. First, I don’t talk to my professors, ever, so I have no basis for an outstanding recommendation. Second, I don’t like asking busy people to do things for me. I’ll have no compunctions about asking Papadakis though, since it seems like I’ll be working my ass off on that project :) Essay writing isn’t my thing either, but comparatively easier. The application writing and such will be crammed into my weekends and other such instances of copious free time.

I’ve managed to convince myself I’ll be able to study in adequate amounts for my GRE exams by reading over the weekends— if I cram material in, 4 hours per day, I should be able to review all of calculus in a month, and likewise for diff. eq.— and doing several problems a day. As for proctoring, I have to hold 4 hours a week of office time when students can come in for help on homework or just understanding material in class— the latter situation never occurs, and the former is very rare— and that’s about how much time it takes me to grade their assignments, so I’ll do the grading then, and complete all my proctoring responsibilities at once.

While my approach to handling the others is all settled, I don’t yet know how I’m going to reconcile my classes with the cardiac project. I’m worried mostly that I won’t be able to study as much as I’d like to for the real variable class I’m taking, one of the two grad classes. The other is a stochastic processes class being offered by the engineering department, so should offer no significant challenge, except for time needed to do the homework. My other classes should be easy: philosophy, telecommunications, advanced linear algebra, and political science— again, only time needed to do the homework and write the papers.

One good thing: I now have a key to Papadakis’ office, and eventually a computer will be set up in there so I can work on the project whenever I have time— no more 9-5 in the computer lab. If I want, I can spend a whole Saturday up here working; not that I would. As a side benefit, I can keep my books for my classes around that part of the campus in there so I don’t have to lug them around.

Efficiency is the watchword now.