Freesteel Blog » Julian
Tuesday, April 14th, 2009 at 12:45 pm - Machining 4 Comments »
The scallop/constant stepover cutting strategy is theoretically capable of smoothly finishing irregular surfaces inside irregular boundaries (such as rest machining areas).
Unfortunately, it can result in very sharp corners in some of the offsets and — if you’re unlucky — can leave a double stepover gap in the final area of collapse where the narrowest width is slightly less than twice the stepover.

The fact that it’s one of the most technically challenging algorithms to make work (with regards to crashes, infinite loops, and ugly results) makes it easy to predict the deep reluctance of any programmer to do something more advanced with it.
It barely works under the ordinary specification (just giving the constant stepover offsets) after years of development, so you would be insane to intentionally make it more complicated, liable to be slower, and more likely to break.
And — secretly — the last thing you want to do with a difficult and unreliable algorithm is fix a flaw that everyone has gotten used to, which could make it more popular, so that more people run it on more and harder examples, so you get hundreds of fiendish bugs coming down the line next year. At some point a programmer has to move on, and the guys who take over don’t stand a chance.
Unfortunately, last week I thought of a sneaky way of combining pencil milling and constant scallop in order to insert bisecting curves into these collapsing contours. I had the option to do this, because the pencil and scallop strategies go through exactly the same cellular subdividing code in the HSMWorks kernel.

After three days of solid coding, I got the above result. There are a lot of reliability issues and huge complexities involved in joining up the cells. Not to mention how the linking is going to be programmed — which is hopefully someone else’s problem.
What to do now? There are a lot of advanced scallop bugs/deficiencies which would take reams of new code to solve properly. It’s difficult to justify doing this just for the bugs, but a brand new feature makes it worthwhile. It’s sometimes an advantage to allow problems to stack up.
What about all the other questions?
Well, if I didn’t think I had some sort of ownership stake in this code, I’d’ve kept quiet about this new idea, and nobody would know. The incentives for creativity do not occur out in the maladministered “free-market” between companies; the incentives — and disincentives — for creativity are actioned internally within each company, and depend on the relationships with their employees and their common morale. It can happen nowhere else.
Not that any of the economic experts seem to pay attention to this dynamic. They all work for universities and have no idea what it’s like to have all your intellectual credit stripped from you systematically by law. Lovely that, isn’t it? They think it’s your own fault for agreeing to be employed under the usual terms and conditions, neglecting to observe that no alternative is ever offered.
Free software is the only way forward.
Meanwhile, over at WorldCADaccess there’s a report of Solidworks and AutoCAD giving free crippled copies of their multi-thousand-dollar products to verifiably unemployed CAD workers, possibly because they’re worried talented people will spend their time working on free CAD software that could ultimately threaten the profitable stagnation of the industry.
Tuesday, April 14th, 2009 at 10:58 am - Adaptive 5 Comments »
The Society of Manufacturing Engineers (“Members consider the consequences of their work and societal issues pertinent to it”) ran the Westec 2009 trade show in Los Angeles, which finished on 2 April 2009.
Blogger Derek Goodwin visited the Mastercam booth there and reported:
I ran into Mike Macarthur, national sales manager for Robb Jack corporation and he showed me some incredible video on his iphone of 1/2″ diameter endmills cutting 1″ deep at 75 inches per minute in 6Al4V titanium, using Dynamic milling, he has promised to forward some links and a presentation, so look for this in a future article.
Now things are gearing up for the sister-show, Eastec 2009, in Springfield MA on 19 May 2009, and Mastercan’s has made its press kit available.
Their new “Dynamic milling” technique looks a lot like our old Adaptive Clearing strategy, which we invented in 2004.
Obviously, it can’t be the same code, or we would have seen some sort of a contract relating to it, got paid a tiny stipend for fixing on-going bugs, and so on. Still, those people at Mastercam have managed to produce a finished product without all the usual embarrassing intervening stages of half-baked flawed and buggy versions that you tend to get in this line of work. They must be much cleverer at programming than we are not to experience all the same set-backs and mistakes. I’d like to hear from them — the people who coded it; not the be-suited managers.
We, at Freesteel, are in eager to share the extremely limited CAM programming expertise there appears to be in the world, and we intend to lend support to any other programming team who is attempting to unnecessarily replicate our work, rather than follow the cheaper and more reliable option of buying the code from us. Programmers must have maximum freedom to pursue whatever apparently irrational course of development they feel is right because — who knows — they might actually be better than us at writing algorithms such as this. It’ll give us something to compete against. Otherwise we’ll get lazy and work on other things.
That’s why a couple of years ago we gave a DLL copy of the Adaptive Clearing algorithm to Delcam so they could bind it into their into the internal development versions of their products and better experiment against it while they were writing their own version.
Since they do not appear to have done this, it can only mean that Delcam don’t feel that this clearing algorithm adds any value to their products. Which is fine. It’s probably the attitude of most of the major CAM companies, most of whom won’t even go that far. Their recommendations of the worth of any strategy doesn’t only depend on whether or not they’ve got it, does it?
Without an organization of any kind representing the interests of users of CAM software, it’s impossible for the ordinary joe to see through the totally self-serving information that comes out of all corners of the business.
Still. It’s not as bad as the financial “industry”. It’s only software, not people’s livelihoods.
Friday, April 10th, 2009 at 3:48 pm - Kayak Dive Comments Off on Kayak diving under Llandudno Pier
Here’s a soothing video I put together from a quick excursion towards the Great Orme and under Llandudno Pier last weekend. (If I’d read that wikipedia article I’d have known that it was intended to land large ferries at the end, and would have had a look — except for the fishing line.)
Now I’m in Matienzo (Spain) at its permanent british caving expedition with a hang-over while it’s raining outside. Ho hum.
Friday, April 10th, 2009 at 3:40 pm - Whipping Comments Off on Parliament catching up on Public Whip
Just received a tip-off about the new design of the Parliament web-page heralded by this dreadful press release:
Why are we doing it?
The Parliament website aims to make Parliamentary information more accessible, show that Parliament is relevant, and enable people to connect and engage with Parliament. The aim of the redesign is to:
- provide a site that is modern, fresh and engaging;
- refine the routes to information, making it more accessible for the user; and
- offer more focused, timely and dynamic content to improve the overall user experience.
One of the new bits is the Lords Division Analysis, which threatens to render our old Public Whip website (made in 2003) obsolete.
Obviously this will take them a lot of unnecessary time and expense because — for some unknown reason — they’ve chosen not to take a copy of all our lovely free code and build from it, and instead are continuing to pretend that all our years of volunteer effort simply doesn’t exist! What’s the point? Do you just enjoy wasting your precious lives shoveling code in to and out of binary holes to no effect so long as you get a wage?
Anyways, it’s only got the Lords divisions from January 2009 with URLs like so:
http://services.parliament.uk/LordsDivisionsAnalysis/session/2008_09/division/20090401/number/5
Local Democracy, Economic Development and Construction Bill [HL]
Lord Hanningfield moved amendment 166, after clause 79, to insert the new clause Delegation by regional development agencies. The House divided:Contents: 33
Not Contents: 69
Result: Government victory
There are no links on the names, or links to the debate, or links to the Bill or to the amendment 166 or to clause 79 — which I think are pretty essential for this page to be of any use.
Oh, and the links to the lists of votes by party: don’t be fooled. They’re not implemented using AJAX.
Searching for other comments about this new feature only shows up a note on Page 52 of House of Lords reform chronology since 1997 document referring to a “House of Lords division analysis database” — so there must be one, from which these few pages are being derived.
So, while the highly paid staff and other software consultants cut-off in their own little world inside the Parliamentary estate appear to do their business without any notice of what people are doing on the outside, we at Public Whip don’t try to pretend that our website is the answer to everything. It isn’t. This is why I’ve programmed in the deep links to the Lords Division Analysis pages where they exist. Try it from this division from 1 April which I have motion text edited, with links, explanations and so forth to look kind of like this:
The majority of Lords voted against inserting a new clause[1] into the Local Democracy, Economic Development and Construction Bill which would have actually resulted in a new clause in the Regional Development Agencies Act 1998[2] which said:
Delegation of functions by regional development agencies
Subject to the provisions of this section, a regional development agency shall have power to arrange for the discharge of any of their functions by a local authority within their area, or jointly by a group of local authorities within that area.Following a short debate, the proposer of this motion (Lord Hanningfield) begged leave to withdraw this amendment. Unusually there was an objection to this, and the matter was pressed to a vote.[3]
- [1] Lord Hanningfield, House of Lords, 1 April 2009
- [2] Regional Development Agencies Act 1998, Statute Law Database.
- [3] Lord Hanningfield, House of Lords, 1 April 2009
This is what the people in Parliament should be doing: untangling this horrible morass of legislative cross-referencing of their own making so that normal people stand a change of finding out what the hell is going on!
Why am I still having to do it? ooo, it makes me so cross. How do they get away with being so useless for so many years on end?
Friday, April 3rd, 2009 at 12:21 pm - Whipping 3 Comments »
It’s a heavy topic, and I haven’t much time. I don’t know how we got here, but it’s a lot better than it was in the 1980s when MPs started “work” at 2pm to give them time to deal with all their “business interests” in the banking sector. Apparently these outside activities helped them keep in touch with the outside world and suppliment their inadequate income — until too much sleaze was coming to light.
They’ve made the argument that MPs don’t get paid enough to attract the high calibre individuals who don’t want to take a break in the lucrative careers to work for such a pittance. This has been said back in 1996, and probably a lot of times since.
Now, a lot of much cleverer, harder working, consciencious and honourable people than the current pack of MPs do very effective and important jobs for much lower pay, and get by well on it. There is no evidence that the party system, whose headquarters are all located in London and who act as the gate-keepers to Parliament (as evidenced by their ability to parachute in what ought to be totally inadequate candidates) is at all capable of sifting in good candidates — in terms of ability to serve the public interest.
Where do these candidates come from? There should be a live survey of their backgrounds, scraped from their wikipedia templates.
How could the high-calibre but not-paid-enough candidates story play out?
Suppose there is a rather garrulous businessman in the high finance who gets on well with people. His peers — including revolving door civil servants, political party advisors, and closed clique media — suggest to him why not run for Parliament. You could do us a lot of good there, making sure the tax code is moth-eaten piece of toilet paper, and none of the regulatory bodies work. But I can’t afford it, he says. I need my yacht in the Mediterrainian, and my wife wants to go shopping in Dubai every weekend. The kids are in Westminster School. That’s what you do with lots of money. I wouldn’t have these problems if I didn’t earn so much.
Don’t worry, we’re trying to get the pay raised up to appropriate levels so that our sorts of people with our sorts of sympathies are going to be willing to be put forward for service.
What about the House of Lords?
Well, Gordon Brown tried appointing some businessmen as goats (Government of all talents), but it didn’t work out. There was no filtration at all for capabilities. You’ve got to go through at least some test of mettle.
Meantime, there’s always fiddling the expenses to keep your life up to the level to which you have become accustomed. And it’s a good thing: We don’t want to have honest people in Parliament. We want them to be like us, in the business world — just greedy, small-minded, petty, self-interested individuals with no morals who can easily be bought, and are able to cover up for us. After all, if you’ve shown off your true character over some trivial expenses because you feel duty-bound to fly close to the wind and not play safe even though you are paid loads, then you are qualified to represent the money interests against the people.
I was thinking about business expenses a while ago. The standard procedure is that a company reimbursing expenses is equivalent to the company buying the goods and services directly.
So, in this day and age, it would be pretty convenient for employees to always use a special company credit card, which deals with expenses and logs the purchases. Anything else is their own business. No more form fiddling.
It’s also supposed to be a standard rule that everything the company buys belongs to the company, and if you want to keep it for your own personal use, you have to buy it from the company at a fair rate. At least that’s how it would work if shareholder’s interests actually counted, because more often than not the managers on the ground are able to shuffle stuff around with no come-back.
This is where there’s a problem with tax. For if a company buys a bar of gold, and then gives it to you as a gift (or sells it at a cheap rate), then you can sell it on to redeem its value because it’s yours, and you can evade a lot of tax that would have been paid had the company just given cash.
This was happening years ago in the 1990s where I worked regarding company cars. Some of the staff got company cars which they drove around for free on expenses. They redeemed the value of this gift by not running their own car. This eventually became taxable (as with any beneficial gift you receive from a company) and the scam stopped.
I’m not really an expert on these things, but the words seemed to be “qualifying expenses”. A salesman driving to a customer wouldn’t have to pay tax on the journey, but the programmers running to and from work in their shiny company cars do not qualify.
There’s a lot of tax law and forms involving this, which applies to ordinary people:
Under general Income Tax law, a director or employee is taxable on the full amount of earnings received and this generally includes reimbursed expenses he or she may receive. The employee may, however, obtain a deduction from those earnings under Section 336 ITEPA 2003 for qualifying expenses. That is to say, the level of income is reduced by the qualifying expenditure in calculating the tax due.
So, all the money you receive in goods and cash from the company has to be considered. And you can deduct only the qualifying expenses from this before you calculate your tax.
The expenses rule which applies to travel costs also covers related subsistence costs. This type of expenditure qualifies for a deduction where it is part of the cost of travel necessarily incurred in the performance of the duties, or for necessary attendance at a temporary workplace. So, in general, payments by an employer for an employee’s accommodation and subsistence when staying away from home overnight on business are not taxed.
So, anyway, there’s kind of a lot of this stuff, loopholes and all (including an inexcusable issue with air miles). What’s almost certainly not allowed — for ordinary people — is putting your hotel expenses towards a second home mortgage somewhere, and then keeping that afterwards (without paying lots of tax on that).
So, are MPs taxed on their second homes, which they have kitted out with fine furnature?
I don’t know.
There’s this article about their paying tax on the capital gains on one of their two theoretical homes. Normally if you sell two properties whose value is higher than what they were bought for, you pay no tax on your primary home, and you pay tax on the profit on your second home. The article reports that MPs can each decide for themselves which one is which, and so they invariably chose the London one which had gained more value. It smells awfully similar to Lord Conrad Black’s cheat on his company regarding a property he decided he wanted to buy at the original price — like it was a share option.
But what about tax on the original expenses that were paid to buy that second home? There’s this statement:
Members of the House of Commons, the Scottish Parliament, the National Assembly for Wales and the Northern Ireland Assembly may have homes a long way away from the Parliament or Assembly and so may need accommodation near it. Alternatively they may need accommodation in their constituency. Expenditure that is incurred in connection with the provision of this accommodation is not qualifying expenditure for PMAs.
I can’t work out what PMA means.
I gotta go. So I’ll leave you with some links to special HM Revenue & Customs tax forms just for MPs.
Form MP2 says: “Tick box 1.6 if you held ministerial office”.
Notes MPN4 say:
If you were a Member of Parliament
Fill in one copy of the Parliament Pages
If you were a Minister in the House of Commons
Fill in one copy of the Parliament Pages for your income as an MP and one for your ministerial office – but see below if you changed office.
If you were a Minister in the House of Lords
Fill in one copy of the Parliament Pages – but see below if you changed office.
If you changed office during the year
Fill in a separate copy of the Parliament Pages for each office from which you received any income in the year ended 5 April 2007.
If you held a non-parliamentary office or employment at the same time
Fill in a separate set of Employment Pages for each non-Parliamentary employment from which you received
any income.
I also see:
Your Parliamentary income includes the value of any accommodation and ancillary services (for example, heating, lighting or cleaning) you (or your family or household) get by reason of your office as an MP. (If you have the benefit of any accommodation by reason of another office or employment, enter it on separate Pages covering that office or employment.) The value of some accommodation is exempt from tax, for instance, if there is a special threat to your security and the accommodation is provided as part of special security arrangements. If you have agreed with us that your accommodation is exempt, do not enter anything in box 1.14 unless circumstances have changed. However, there is still a charge to tax on the ancillary services. This is usually limited to 10% of your salary from the office concerned. Enter this value in box 1.14.
I’m not able to find forms MP1 and the rest. There are similar special forms for the Scottish Parliament.
All of which is morally hazardous, because these are the people who oversee the tax code in this country. If they’re getting their dispensations from it, then they don’t really come into contact with its effects, and they feel more predisposed towards giving dispensations to other classes of self-important individuals for whom they share sympathies.
The reverse at least has happened with the Freedom of Information Act, but by an oversight was applied to Parliament, and then by public outrage has not been disapplied to Parliament.
Because the Freedom of Information Act applies to MPs, they’re discovering first hand what a powerful tool it is, and they’ll hopefully not have any sympathy with groups who want to exempt themselves from this Act.
And finally, there’s this suggestion of getting rid of these housing expenses altogether (the other expenses remain) and replacing it with a £24,000 pay hike, because of all the trouble it’s causing. Evidently, MPs and ministers can’t be trusted to operate their own affairs without getting into deep trouble the first time someone from outside their clique gets to look.
Bad idea.
The one thing that should exist in politics are little bits of personal temptation, whose consequence can get out and which are easy for the public to understand. These stories reveal more about their characters than any policy arguments over theoretical things. I’d rather have that than not know.
Tuesday, March 24th, 2009 at 12:52 pm - Whipping 3 Comments »
Due to the electoral system in the UK (taking account of the long-term political social capital and connections to the press, as well as the technicalities of the system), the only way to get democratic representation is through a political party. And the political parties that are established in Parliament at the moment have an effective lock on the system.
Since practically forever, new political parties with any influence have only emerged as a result of
- fission – where an established party splits (eg the SDP)
- fusion – where two political corpses merge and all the experienced people and political capital are able to re-enforce one another (eg UKIP)
- the entry of an already powerful outside social movement – (eg The Labour Party from the unions).
- loonies
Political Parties don’t come from a “political movement created with the goal of making politics more accessible, politicians more accountable and political institutions more transparent”, because no such movement exists.
All right, there is a small movement of this kind, which has resulted in websites like PublicWhip being founded, but I can honestly report, on the basis of the total lack of support it has gained from any part of “civil society”, that there is no real social movement whatsoever out there yet. There might be an substantial public disquiet, but it doesn’t amount to anything that threatens to do anything.
To sustain a political movement (before it becomes like some sold-out empty brand like New Labour that can live on for far too long on the unquestioning store of rotting compost it laid down over the last hundred years), you need real tangible grievances, not some kind of list of well-meaning proposals. You need actual anger shown, naming and blaming. Even if it is biased and misinformed, like blaming everything on Europe or blaming everything on foreigners. To prove my point, UKIP and the BNP do provide an endless succession of up-to-date grievances enough to keep the pot boiling. Nothing like that from the Jury Team.
Conventionally, right wing parties (which the BNP supposedly is, though I’m not really sure) are supposed to loath gays. So it’s kind of cool that one of their common complaints against Muslims is that they hate homosexuals. There is no predictability. Policies are driven by political phonomena like Jörg Haider. The BNP has a lot of posts which include the word Israel which provide the evidence that the conventional anti-Jewishness has translated to being anti-Muslim without leaving a trace behind. Whatever works.
According to the Electoral Commission, the Jury Team was founded on 13 March 2009 by the millionaire Sir Paul Judge, husband of the Atomic Kitten.
Judge was high in the Conservative Party during the John Major government and he also founded the gigantic £8million Judge Business School in the middle of Cambridge which is currently training the next batch of financial wizards and appointed business leaders to completely f*** the economy up as a consequence of their criminally inadequate education which misses out every lesson from the long and distinguished history (doomed to repeat itself) of general financial f***-ups that have systematically occurred in the past 400 years.
Judge’s most recent donations to the Conservative Party are a measly £4k on 10 December 2003, £8k on 21 April 2004, £5k on 10 November 2004, £10k on 22 April 2005, and £6k on 10 October 2008.
The official Jury’s Team party descriptions include:
- Democracy 2.0
- Democracy, Accountability, Transparency
- Politics for the People
- Politics Isn’t Working
- Politics with Principles
- Politics without Parties
The registers of donations are recorded per quarter, so there’s no information about a party that was founded only a week ago.
Parties appear and disappear. Here is the final statement of accounts on the Cut Tax on Petrol and Diesel Party which got 118 votes on the Crewe and Nantwich by-election. (For the record, PublicWhip got none by wasting no time with electoral fantasies.)
There’s also Your Party founded in 2004 and deregistered in 2006 which “aimed to give people genuine power in the decision making process by using a form of direct democracy”.
This one pissed me off because it got radio and BBC coverage, when there is still not a single article on the Public Whip — possibly because it’s now old and established and not news, while back in 2003 when it was news we had no media connections to get something as trivial as a new web-page reported on.
These things show up the flaws in the selectivity of the media reporting. I am confident that Public Whip will still be going on long after Jury Team gets deregistered, because it’s essential, sustainable (from my own income), and no one else does what it does. It could do what it does a lot more effectively with more support. But that’s only going to happen once the pointless news media feels it’s time to tell people the who, what, where, when, why and how of what it does. Otherwise people will go on thinking that it’s some kind of Government website.
While at the Green Party conference last weekend, some guy came and gave a fringe talk on his Campaign for Democracy project, which was equally irritating because it’s a guaranteed failure.
I’ve not had that much involvement in the electoral system, but I’ve seen enough to realize that it’s damn hard, requires some serious expertise, and novices need not apply. You will be taken to the cleaners. Never, never go out and form your own political party, unless you have experienced at least one election cycle working in functioning party at the bottom. Even then it can crash like the Socialist Labour Party established by Arthur Scargill in 1996 — a man who ought to know a thing or two about putting up a good fight.
Whatever.
The Jury Team has been getting some coverage on the BBC.
The Guardian opined:
Why start a political movement when you must know you are almost certain to get nowhere, thereby disillusioning any volunteers you attract in the process?
Similar stuff is also happening in Ireland.
How many times to I have to say it:
If you don’t like how politics is run, go join and get involved in the running of a real mainstream political party. They rule the system. There is no other way. If reasonable people don’t start joining and start attempting to affect political parties in greater numbers, then don’t be surprised that they (and consequently the whole political system) remain staffed by weirdos.
Thursday, March 19th, 2009 at 11:52 am - Whipping 1 Comment »
There is a theory that webpages that serve lots of data (like Farmsubsidy.org or the Guardian’s new and totally befuddling Open platform thingy) ought to provide an effective API to access the data (in addition to their own surf-able front-end) for power-users to design different front-ends of their own, and “mash up” the data in ways that the designers of the original website were not clever enough to think of.
An API is basically just a webpage containing the data without any pretty decoration in a form that standard programming functions can easily parse into an internal representation. A popular one is JavaScript Object Notation (JSON).
To facilitate this theory, it is proposed that your standard data serving website ought to be separated into two independent pieces — the first piece is just the API server on the database, and the second piece just queries this API and decorates the data into nice normal looking webpages. Both components can be on the same server, but having them separated out means that the API is proven to be sufficiently well powerful enough to generate the standard webpages.
(Normally if you just threw in some random API functions onto your website without yourself intending to use them for real, there’s no reason to expect it’ll be enough to do anything with.)
The MediaWiki API (for accessing data out of Wikipedia) is not powerful enough to recreate the site. You can obtain just about anything from it (for example the Caves of Yorkshire category), but not the actual text from any page.
This infuriated me for hours as I kept looking everywhere for this obvious function, and they don’t say that it’s deliberately not there. Wikipedia also blocks you from webcrawling their pages because it would “overload their servers”. Instead, you have to do some kind of deeply irritating Wikipedia:Database_download, which I was trying to do one time, before I got too annoyed with the process. It was all part of my effort to make the PublicWhip database of MPs be a direct reflection of a fast and special implementation of DBpedia. It needs to get updated on demand, so that when an MP resigns and the fact gets noted on his Wikipedia page, it appears in the database. Maybe one day. Or someone else can do it. I keep spreading this idea around in the hope that it happens. I mean, if so many people were writing webcrawlers of Wikipedia that they got annoyed enough to block them, why can’t I find one person among their bumbers interested enough to do something this blindingly useful.
Speaking of which, TheyWorkForYou has an API as well, serving 19 functions in 6 different formats.
I’m not sure many people have actually used it productively.
There is no API for PublicWhip— although the webpages themselves are so big and tabular they are practically like API output in raw form. People complain about the PublicWhip interface because it’s so complicated and intimidating. The next time I get lectured about how it would magically all make sense and be accessible to everyone if only it was designed by someone a million times better than me, I’m replacing all the pages with pictures of a kittens. Or maybe we ought to make clear the objective of a website when it’s being criticized. Everyone can understand and appreciate fluffy kittens, can’t they? But then they won’t learn anything about Parliamentary votes, will they? It will never be pretty. Admittedly the website could be a whole lot better, but it will never be as good as pictures of kittens. And I would expect a web designer who is trying to make it better to know as much as he or she can about Parliamentary votes in order that they don’t unintentionally delete all that data and replace it with kittens. Part of the idea of making APIs is it’s a cop-out: “if you can present the data of this website better, here are some tools for it.” You are free to decorate it with kittens.
The policy with PublicWhip is that when anyone asks about an API, they get given login and passwords onto the (still sick) seagrass server (on which it is hosted) so they can write exactly what they want.
Hasn’t worked yet, though. But it does suggest something.
A web API is an Interface.
As with all interfaces, it’s not possible to make it generally suitable for everything. In general in most intensive programming, you design the interface while you are making the application. Like, “I need another function to do this thing”, so I have to go back and put it into the interface. It’ll never be complete; it only has to be powerful enough to get the job done that you’re doing at the time.
Therefore the API will be limited by the jobs you thought it was going to do when it was being designed and implemented.
Hence, if you made something powerful enough to serve data into a google mashup, then it’s probably going to be limited to just that, and you shouldn’t be disappointed when the best that any of your users can build with it is another google mashup.
We yawn at it. But its predetermined, like those scrapheap challenge episodes where happen to find two bits of scrap that somehow have all the right bits to bolt together.
People are not going to make something like a barchart of the Parliamentary data aggregated statistically, or a scatter-plot graph of MPs’ travel expenses against (a) distance from London or (b) cost derived from the isochrome travel map (That would need an iso-cost travel map. Who’s going to make one?). The data is simply not there available through the TheyWorkForYou/API. The API is limited, and so all the results are limited.
Well, I suppose you could work around it by polling the API repeatedly in order to recreate the data in your own database and then query it. But do you know how much quicker+easier (= much more likely someone will do it) it would be to simply access the database from within the webserver?
The proposal is that tools should be made available to Roll Your Own API.
Specifically, if the website is built within a framework, such as Django, then the basic components are the views (small functions that assemble lists of data from the database) and templates (concise systems for transforming lists and items of data into a nice looking webpage).
What you need is to put one views function and one template file into a wiki system, so that people can use all the power of the database queries and function writing, and all the power of the template to write it out in whatever format they want (JSON, XML, CSV, RDF, whatever, a new one every year) for their downstream application they are building.
That way, we won’t wind up writing a whole bunch of API functions that can only run google maps (if that) with a proliferation of output formats that tick the boxes, yet don’t actually seem to lead to any wider use.
Clearly, for fastest work, the same programmer has got have developmental access to both sides of the interface– not as it is now where some guy who doesn’t know the eventual uses the data writes some boring API functions in one year, and three years later someone else tries to use it in spite of all the gaps.
My proposal could, of course, be done as an API where the URL takes two parameters:
http://www.webpageurl.com/djangoapi?views=”someverylongstringofpythoncode”&template=”anotherverylongstringoftemplatecode”
but that would be cheating.
In the future, all such innovative websites that are interested in feeding data into other modules are going to use one of these many Javascript-based source code editors which will allow you to deposit fragments of code on the server such that the right stuff is served up on a webpage.
The best codewiki I’ve found so far is this demo of the orc programming language. Lovely work.
With this technology, these fruitless APIs are going to be dead in the water (they were never alive in the first place).
Just another fine theory that didn’t really work because no one thought it out for long enough.
Of course, I’m almost certainly entirely wrong as usual. For proof, go see all the activity going on at the Apps for America competition.
Friday, March 6th, 2009 at 8:33 am - Cave 1 Comment »
My attempt last weekend to complete a bit of cave surveying and have it uploaded onto an overlay of googlemaps was thwarted by lazy university students who were meant to come with us, and (following our actually doing the survey of part of the sump canal in IrebyFell Cavern) an interruption for beer.
The latter is always going to happen on a caving weekend. I don’t know what we can do about it. Our work (the squiggly white passage) showed up three days late.
Then on Monday we went digging with the Misty Mountain Mud Miners in the Easgill System.
Here’s a little video to prove that it was indeed misty and we were mining mud. The scones we ate for tea were pretty horrible, being the cheapest kind that could be bought at the supermarket. The day ended sooner than expected because we hit a rock. They’re going to have to come back next week with some capping equipment.
Friday, March 6th, 2009 at 5:07 am - Whipping 2 Comments »
Just showed up at Cambridge to find Francis all het up about the Political Parties and Elections Bill, having read this posting on the Your Right to Know blog about how MPs had just summarily voted to make yet more information about themselves secret.
This connects to the MPs’ expenses debate which I posted about earlier in the year, drawing attention to the paranoid Julian Lewis MP and his concerns over disclosing MPs’ addresses in case some “self-taught follower of al-Qaeda… goes on the internet, conveniently finds 646 addresses and sends 646 packages containing something explosive, horrible or, at the very least, abusive to 646 unprotected mail boxes.”
What an amazingly vivid and childish imagination.
But then you would expect it of a guy who writes prize-winning essays (prize awarded by the, never-seen-a-war-they-didn’t-like, Gentleman’s Club, RUSI) such as “Nuclear disarmament vs. peace in the 21st century”, in which he presents his cockeyed bogus case for nuclear weapons, including the usual lowlights:
- Only atomic weapons brought Japanese surrender in the Second World War
- Mutually assured destruction is a safe guarantor of peace
- There is a propensity for dictatorships to go to war with dictatorships, and for democracies and dictatorships to clash, whilst few – if any – examples exist of liberal democracies attacking each other.
- If we relied on the protection of American nuclear weapons, then an aggressor is likely miscalculate their commitment to us and annihilate our cities
- The Non Proloferation Treaty does not commit the United Kingdom to nuclear disarmament
- The purpose of the British nuclear deterrent is to minimize the prospect of the United Kingdom being attacked by mass-destruction weapons.
For a guy who’s spent so much of his time embedded in the military thinking establishment, he has practically nothing of any interest to say. It’s basically no better than President Bush’s understanding of history, and it ignores interesting questions like:
- What about the Soviet invasion of Manchuria, also in August 1945, and the suggestion that the development of atomic weapons delayed the acceptance of a Japanese surrender until the technology could be properly tested on human victims?
- Why exactly doesn’t the US overthrow of the democratic government in Iran in 1953, or the 16 year Vietnam War count in those figures?
- If nuclear weapons are supposedly the reason why we don’t get attacked, why is it not obvious to ask why we would get attacked, when we don’t have anything anyone wants, like oil?
- How much closer would we have had to get to nuclear armageddon during the cuban missile crisis before the policy of mutually assured destruction doesn’t look quite such a safe ticket?
- Do you think Russia will ever bother to point their military forces at us again, now that they can shut off the gas pipeline and bring us to our knees?
- If everyone knew we weren’t even slightly going to work towards nuclear disarmament, do you think so many countries would have bothered to sign the Nuclear Non-Proliferation Treaty?
Anyways, wisdom and intellectual honesty were never qualifications for being an MP, not when you’re spreading the sort of message the purveyors of violence want to hear.
As it was.
For many years, ballot papers in the UK have listed the home addresses of the candidates standing for election, as well as their names and political parties, so people knew exactly who they were.
Julian Lewis knows this, and appeared to come to terms with it, because in the same speech last year about the 646 packages containing something horrible mailed to the 646 MPs, he said:
As Simon Hughes pointed out, once every four or five years we have to reveal our constituency address in the process of getting elected. But the fact that we have to do that with some of our addresses, some of the time, is no reason whatever for our having to do it with all our addresses, all the time, in an easily accessible form. Of course, if someone who is targeting a particular MP and means to track him or her down in order to do him or her harm puts in enough effort, it will be possible to do so.
Nevertheless, this tiny loophole must have bugged him enough because this week he sponsored a whole raft of rule changes to the procedures for Parliamentary elections and got them voted into the Political Parties and Elections Bill. There was no debate about his law changes whatsoever, and a lot of MPs considered it highly irregular to the extent that they even argued with the Speaker about it:
David Heath: Further to that point of order, Mr. Deputy Speaker. [ Interruption. ] I am sorry to weary the House with this boring bit of procedure, which involves whether we debate a matter before it is added to a Bill, but does not that procedure specify that it relates to all Government amendments and new clauses, and was this not a Back Bencher’s amendment or new clause, which is quite different?
Following this altercation, the slimeball who hates everyone who doesn’t love the bomb shouted:
Is there any way in which, within the rules, I can place on the record the fact that although both the Government and the Opposition treated this free vote as a free vote, the Liberal Democrats whipped all their Members to vote one way!
No doubt irrelevant details, such as the fact that the Liberal Democrats assessed President Bush’s gratuitous plan to invade Iraq far better than he and his party did, will get buried when he pens his next childish essay on the subject.
I can’t find anything useful among any of his writings, and I’ve looked hard. There are the usual empty lies like:
Saddam threw the inspection team out of Iraq in 1998. This gave him more than four years to create stocks of chemical and biological weapons which could be hidden in any cellar or hole under a rock in the desert.
Now why would a war-monger want to forget about an important military action like Operation Desert Fox (also in 1998), unless its particulars happened to conflict with the rational for prosecuting the next unnecessary premeditated act of aggression?
Selectivity and the lack of any the need to make excuses for things present in the record abounds.
Meanwhile, in the land of luminaries like George Shultz, US secretary of state from 1982 to 1989, William Perry, US secretary of defense from 1994 to 1997, Henry Kissinger, nobel peace prize winning war criminal and US secretary of state from 1973 to 1977, and Sam Nunn, former chairman of the Senate Armed Services Committee, comes this article in the Wall Street Journal last year:
Toward a Nuclear-Free World
The accelerating spread of nuclear weapons, nuclear know-how and nuclear material has brought us to a nuclear tipping point. We face a very real possibility that the deadliest weapons ever invented could fall into dangerous hands.
The steps we are taking now to address these threats are not adequate to the danger. With nuclear weapons more widely available, deterrence is decreasingly effective and increasingly hazardous.
One year ago, in an essay in this paper, we called for a global effort to reduce reliance on nuclear weapons, to prevent their spread into potentially dangerous hands, and ultimately to end them as a threat to the world. The interest, momentum and growing political space that has been created to address these issues over the past year has been extraordinary, with strong positive responses from people all over the world.
Agreeing with their analysis, taking account as it does of all sorts of events and opportunities out there in the real world, means I am a pinko lefty commie, no doubt.
But you’re safe as long as no one who has a chance to vote for you gets told where you live. This provision, of course, does not apply to European Parliamentary candidates, Scottish Parliament candidates, or local council candidates, none of whose lives are at risk, or are worth protecting. It also doesn’t apply to directors of registered companies whose addresses are available for as little as one pound from Companies House.
I wonder how long before they start to claim that, as a consequence of their extreme politicial power over the destiny of the nation, it’s important that we don’t get told where they live either.
Thursday, February 19th, 2009 at 4:31 pm - Machining 1 Comment »
Hm. This image didn’t come out quite as badly as I would have expected. Maybe I’ll do more like this.
In the non-axial projection function for a general cutter shape, it’s necessary to find the intersection between a line and a torus — for the case of a bull-nosed cutter against one of the corners of a triangle.
As you can see, there are four points of intersection of this polynomial surface, and no symmetries to simplify it down. Therefore, you can expect to solve a quartic function.
Luckily, I added the Quick and memorable solution [of a quartic] from first principles section in Wikipedia, so I could find it when I finally needed it.
I managed to get this far without it by using offset ellipse technology which gives enough global structure to contain a robust iterative solution (you need to find a point on either side of the curve to begin the algorithm and avoid stabbing in the dark).
Without loss of generality, the torus can be placed at the origin in the XY plane. Its flat radius is f, and corner radius is c (so, csq = c*c). Consider a line that intersects the torus. Without loss of generality, we can rotate the assembly so that the line lies in a single plane parallel to the YZ plane, so its coordinates (for variable x) are
(x + s, d, x * l)
where l is the slope to the XY plane, and (s, d) is the point it intersects the XY plane.
We need to solve the equation:
(r - f)^2 + (x * l)^2 = c^2
where r = sqrt((x + s)^2 + d^2)
So, here is my [PUBLIC DOMAIN] code for doing it, within the function ToroidLineIntersect
I’ve in-lined the quartic and cubic solutions so that some of their partial calculations can be optimized.
I’ll come back to this later and find more of the bugs when we run some tests on it. It’s important to get real world values here. I don’t know if the system is going to want to put in very large values of l, for example. If this is unstable, there might be enough negotiation with the higher order algorithms to ask them to round these cases to a vertical drop-down, which will make almost no difference to the operation of those algorithms, but make a great improvement in calculation efficiency.
It’s wise to steer clear of the weak spots in the mathematics.
// trivial functions
double Square(double X) { return X*X }
double Cbrt(double X) { return (X < 0.0 ? -pow(-X, 1./3) : pow(X, 1./3)); }
#define TOL_ZERO(X) ASSERT(fabs(X) < 0.00001) // macro to check things are adding up correctly
// subroutine performing one iteration and commiting the value
void ToroidLineIntersectSubiter(double& x, bool& bres, double lx, double f,
double dsq, double ss, double lsqp1, double lcr)
{
double rfr = lx * (lx * lsqp1 + 2 * ss) + lcr;
if (rfr < 0.0)
return;
double rfrL = 2 * sqrt(dsq + Square(lx + ss)) * f;
// avoid doing in a loop, since one iteration is almost always enough
double e1 = rfrL - rfr;
if (fabs(e1) > 1e-8) // the iteration
{
// double der = 2 * (lx * lsqp1 + ss) - 2 f * 0.5 * (dsq + Square(lx + ss))^-0.5 * 2 (lx + ss)
double der = 2 * (lx * lsqp1 + ss) - 4 * Square(f) * (lx + ss) / rfrL;
double nlx = lx + e1 / der;
double nrfr = nlx * (nlx * lsqp1 + 2 * ss) + lcr;
double nrfrL = 2 * sqrt(dsq + Square(nlx + ss)) * f;
double e2 = nrfrL - nrfr;
if (fabs(e2) < fabs(e1))
lx = nlx;
}
if (!bres || (lx > x))
{
x = lx;
bres = true;
}
}
//////////////////////////////////////////////////////////////////////
// Main function
//////////////////////////////////////////////////////////////////////
bool ToroidLineIntersect(double& x, double f, double csq, double dsq,
double ss, double l)
{
// solve point p = P3(x + s, d, x * l) intersecting the torus (flat=f, corner=c) for max x
// or: (P2(x+s,d).Len() - f)^2 + (x*l)^2 = csq
// dsq = d*d
// r*r = (x+s)^2 + dsq = x^2 + 2xs + s^2 + dsq
// csq = (x*l)^2 + (r-f)^2 = x^2 * lsq + r^2 - 2rf + f^2
// = x^2(lsq + 1) + 2xs + s^2 + dsq - 2rf + f^2
// 2rf = x^2(lsq + 1) + 2xs + (s^2 + dsq - csq + f^2)
double lsqp1 = Square(l) + 1.0;
double br = 2 * ss / lsqp1;
double lcr = Square(ss) + dsq - csq + Square(f);
double cr = lcr / lsqp1;
double rr = 2 * f / lsqp1;
// r rr = x^2 + x br + cr
// (x^2 + 2xs + s^2 + dsq) * rr^2 = x^4 + x^3 br 2 + x^2 (br^2 + cr 2) + x (br cr 2) + cr^2
double rrsq = Square(rr);
double b = br / 2;
double qb2 = Square(br) + 2 * cr - rrsq;
double qb1 = 2 * cr * br - 2 * ss * rrsq;
double qb0 = Square(cr) - Square(ss) * rrsq - dsq * rrsq;
// 0 = x^4 + x^3 4 b + x^2 qb2 + x qb1 + qb0
// convert to a depressed quartic
// x = u - b
// 0 = u^4 - u^3 4 b + u^2 6 b^2 - u 4 b^3 + b^4 +
// u^3 4 b - u^2 12 b^2 + u 12 b^3 - 4 b^4 +
// u^2 qb2 - u 2 qb2 b + b^2 qb2
// u qb1 - b qb1
// + qb0
double bsq = Square(b);
double qc = -6 * bsq + qb2;
double qd = 8 * b * bsq - 2 * qb2 * b + qb1;
double qe = -3 * Square(bsq) + bsq * qb2 - b * qb1 + qb0;
// 0 = u^4 + u^2 qc + u qd + qe = (u^2 + p u + q) (u^2 + r u + s) -- factored out
// multiplying out and reducing the unknowns gives:
// 0 = p + r, qc = q + s + p r, qd = p s + q r, qe = q s
// qc + p^2 = s + q, qd / p = s - q, qe = s q
// (qc + p^2)^2 - (qd / p)^2 = 4 qe
// P = p^2 gives:
// 0 = P^3 + P^2 2 qc + P (qc^2 - 4 qe) - qd^2
double cb = 2 * qc;
double cc = Square(qc) - 4 * qe;
double cd = -Square(qd);
// 0 = P^3 + P^2 cb + P cc + cd
// now solve the cubic
double cbsq = Square(cb);
double ccq = (3 * cc - cbsq) / 9;
double ccr = (9 * cb * cc - 27 * cd - 2 * cb * cbsq) / 54;
double ccqcb = ccq * Square(ccq);
double disc = ccqcb + Square(ccr);
double psq;
if (disc >= 0.0)
{
double discrt = sqrt(disc);
psq = Cbrt(ccr + discrt) + Cbrt(ccr - discrt) - cb / 3;
}
else
{
double crho = sqrt(-ccqcb);
double cthet = acos(ccr / crho);
psq = 2 * Cbrt(crho) * cos(cthet / 3) - cb / 3;
}
TOL_ZERO(Square(psq) * (psq + cb) + psq * cc + cd);
if (psq < 0.0)
return false;
// 0 = u^4 + u^2 qc + u qd + qe = (u^2 + pq u + qq) (u^2 + rq u + sq) -- factored out
double pq = sqrt(psq);
double rq = -pq;
double sq = (qc + psq + qd / pq) / 2;
double qq = (qc + psq - qd / pq) / 2;
bool bres = false;
// we're solving, which has been squared. The
// 2rf = x^2(lsq + 1) + 2xs + (s^2 + dsq - csq + f^2)
// solve (u^2 + rq u + sq) = 0
double qqur = Square(rq) - 4 * sq;
if (qqur >= 0.0)
{
double qqurs = sqrt(qqur);
double u1 = (-rq - qqurs) / 2;
TOL_ZERO(u1*u1*u1*u1 + u1*u1 * qc + u1 * qd + qe);
double u2 = (-rq + qqurs) / 2;
TOL_ZERO(u2*u2*u2*u2 + u2*u2 * qc + u2 * qd + qe);
ToroidLineIntersectSubiter(x, bres, u1 - b, f, dsq, ss, lsqp1, lcr);
ToroidLineIntersectSubiter(x, bres, u2 - b, f, dsq, ss, lsqp1, lcr);
}
// solve (u^2 + p u + q) = 0
double qqup = Square(pq) - 4 * qq;
if (qqup >= 0.0)
{
double qqups = sqrt(qqup);
double u1 = (-pq - qqups) / 2;
TOL_ZERO(u1*u1*u1*u1 + u1*u1 * qc + u1 * qd + qe);
double u2 = (-pq + qqups) / 2;
TOL_ZERO(u2*u2*u2*u2 + u2*u2 * qc + u2 * qd + qe);
ToroidLineIntersectSubiter(x, bres, u1 - b, f, dsq, ss, lsqp1, lcr);
ToroidLineIntersectSubiter(x, bres, u2 - b, f, dsq, ss, lsqp1, lcr);
}
return bres; // actual value is in the x
}
