Java

9 07 2008

I tried to teach myself some Java from a book I’ve had for years (I remember buying it at Waterstone’s in Ealing Broadway back when I didn’t exclusively use the internet to accumulate stuff). I’ve done some simple things like porting binary (which wasn’t too hard), making a program for finding the arithmetic, geometric or harmonic mean of an indefinitely long list of numbers (will adjust that to perform a quick iteration to find the arithmetic-geometric mean) and an iterative factorial thing.

What I want to do eventually is write some routines to a) solve a system of linear equations in 3 variables via matrices b) absorb plotter and c) do splines.

I’ve made headway with the algorithmic techniques already. I made a spreadsheet to solve the equations in a way similar to my sum of r4 thing so when you enter two points (x co-ord, y co-ord, gradient at that point), it tells you the coefficents of the cubic required to draw smoothly through those points.

I tested it with Grapher (a superb application). For people unfamiliar with cubic splines, a different function is plotted between each pair of points that joins up with the next one at the same gradient, so as to create the appearance of a smooth curve. For this, the gradient at each point, as explained in the picture, was just the gradient between that point and the next. Probably not the best way to do it, but it seemed to work, kind of… I believe you can do some magic with the second derivative too. I’ll look into it. Have a look.

If the gradient at the point (xn, yn) is mn, maybe I should’ve said:

mn = ((yn - yn-1)/(xn - xn-1) + (yn+1 - yn)/((xn+1 - xn))/2

That is, the mean of the gradient between the previous point and this one, and the gradient between this one and the next.

I played around a little with Swing but have so far only made an infinite number of replicating, unclosable windows.

I’m also finding Coda even more useful than before. I can just work from a split-screen of its inbuilt terminal and the .java file I’m working on (it highlights Java syntax - how nice!).

Pax


Actions

Informations

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>