Signed distance fields

This post is a classic example of the malady known as Jason-itis – idly wondering about a thing, and then having to dive deep down a rabbit hole to satisfy a geeky wish. In this case the thing was ‘I wonder how you make a 3D shape which looks like different shapes from different angles’, and the rabbit hole bottomed out at this GPU-accelerated demo. Let’s look at the stuff in-between.

Continue reading
Advertisement

Blissful unity

Regular readers of this blog will note that 2019 has not been a particularly fecund time for new posts. This is principally due to my getting married recently – typically weddings are events with minimal overlap with the kind of topics I write about here. Unless, of course, one of the people getting married happens to be me.

Continue reading

Walk the walkie, talk the talkie

A few years ago, a building in London known as the ‘walkie-talkie’ (actually 20 Fenchurch Street, but ever since the Gherkin it has been mandatory to give big expensive buildings extremely silly names. Can of Ham anyone?) started setting fire to shops and expensive cars. Let’s have a look at why that might be.


The obvious feature of this skyscraper (other than the almost complete incongruity with the surroundings) is that it is strongly curved inwards on its southern side:

Any inward curvature like this will act to focus the incoming light upon reflection. The fact that the tower curves over at the top also helps reflect the incoming light downwards onto the buildings it looms over.

Intriguingly, the designer of the walkie-talkie Rafael Viñoly was also responsible for a similar ‘death ray’ in Las Vegas. Perhaps he assumed the notoriously feeble British sunshine could never be focussed to high enough intensities to ever cause damage?

I’ll chronicle here my attempt to model this situation, inspired by this paper from my alma mater. While the paper is thorough, follows best scientific practices, and uses proper solar irradiance profiles, the visualisations left me wanting more. Casting proper science aside, let’s right that wrong and dig in.

The building

My initial thought was to model everything in Blender, and just let the rendering engine do all of the hard work of calculating light paths.

To draw up the building, I used the floorplans available here to get the shape correct, and smoothly interpolated the building shape between the floors.

Floor 7, featuring some pretty sweet corner offices.

I also used the surprisingly awesome export feature of OpenStreetMaps which includes building shapes and heights, then ran the export through the equally awesome OSM2World which spits out file formats readable by other 3D software – in this case, Blender.

A bit of modelling, importing, and rendering later, we get a lovely view of this chunk of the City, with some minimal external lighting:

Great (I thought). Let’s stick a sun lamp into the scene, and see which building it focusses on:

This was a bit disappointing – a faint splodge of white was not the death ray I was hoping for. Much fiddling with materials, lighting and renderer settings improved the render slightly, but it was still a struggle to generate anything which looked like it might melt a car.

Doing things properly

Leaving Blender behind then, I loaded the building model into python using trimesh, which also very helpfully does efficient ray-surface intersection calculations. Firing a load of rays at the building surface with direction \mathbf{d}, calculating where they hit, and calculating the reflected ray direction \mathbf{r} using

\displaystyle{ \mathbf{r} = \mathbf{d} - 2 (\mathbf{d} \cdot \mathbf{\hat{n}}) \mathbf{\hat{n}}}

(where \mathbf{\hat{n}} is the normal direction at the surface), I could now trace the evolution of the reflected death ray intensity:

Here the incoming rays are spaced evenly in the plane normal to their direction, and so the density of rays at any point gives the light intensity. This is a simplified approximation, but will suffice for our purposes.

Tracing the paths of many thousands of rays, we can start to see how the reflected light propagates:

The rectangular region contains the intersections between the reflected rays and the ground.

Here is actually the worst-case scenario – at an incident angle of around 16 degrees the light comes to a focus almost exactly on the ground. If we calculate the ray density on the ground, we can plot the ‘focal spot’ produced by the building:

The units on the axes are arbitrary.

Frighteningly, a significant portion of the entire incident light field is focussed to a small point, with the rest spread behind it longitudinally.

Varying the incident ray angle, we see how the light comes in and out of focus (we don’t show the incident rays for clarity):

The non-uniformities in the transverse direction are probably due to non-perfect smoothing of the building mesh – focal spots are very sensitive to departures from surfaces of constant second derivative.

If we plot the maximum intensity of the focal spot as a function of ray angle, there is a clear peak:

From this surprisingly cool site, we know that in summer time in London, the sun is at 16 degrees at 8AM in the morning and 6PM in the evening. Given these are peak commuting times, the unwary commuter could have ended up with a nasty surprise! Indeed, the paper linked above concludes that sun intensities may have been boosted by a factor of up to 16 times.

Fortunately, shortly after London started melting the developers applied some protective covers to the southern face of the building. This is much safer, and the right thing to do, but has the unfortunate side effect of completely ruining my chances of dropping the words ‘death-ray’ into casual conversation. Guess we’ll just have to wait for Rafael’s next great project.

Warped ideas

I was in Rome airport not long ago, and noticed that the reflection of the striped ceiling looked warped and bent due to the non-flatness of the reflecting surface:

img_20170930_163807.jpg
What else to do when waiting in the departures lounge?

As I’m sure will be familiar to any traveller, the excruciating boredom of an airport drives the mind to wander, so here is my derivation of the underlying mirror surface structure from this image.

Continue reading

Axes of rotation

I recently tried my hand at throwing axes at a wall, courtesy of Whistle Punks in London. While this was a fun and satisfyingly macho activity, I noticed that the attendants were careful to position people at various distances from the target to increase their chances of success. This piqued my curiosity, so here I’ll have a look at why that might be.

Continue reading

England and Wales House Prices

The last time I looked at house prices it went pretty well, and I ended up winning a data science competition. There I was only dealing with a million or so records, and a relatively small 120 MB dataset. Then I found out it was possible to download 3.7GB of property sale records for all of England and Wales since 1995, so let’s have another go. Continue reading

On which shaped planet am I the heaviest?

Continuing on from my last post concerning optimisation and Lagrange multipliers, I came across a neat little paper on the arXiv here, which asks and answers the question: what shape should a planet be to maximise the gravitational force at a given position? This is a fun problem, solved using an extension of the techniques from the last post, namely the use of Lagrange multipliers to optimise a function given some constraint.

Continue reading

Stereographic Lampshades

I saw an article on the Guardian website here on the 3D-printing of shapes which project interesting patterns of light. Ignoring the strangely forced Halloween reference, I thought this would be an interesting project to attempt for an arbitrary pattern, perhaps as a personalised lampshade. Buoyed by the continuing high of leftover sweets from Friday night, let’s have a look.

Continue reading