Smallworld


I rock.

I now have generalised circles drawing properly. Looks great. Weird, but makes intuitive sense when you play with the draggers. I’ve noticed this before: while you are writing the code, the lines and arcs skip around the screen in weird ways but with an underlying logic that you can sort of grasp. When you finally get it right, they move in ways that are just a little dull, by comparison. They give you an “Oh. Is that all?” feeling. The motions lock together in predictable ways.

Anyway. The next issue is drawing line segments. This is kinda crucial, because network graphs tend to be made of them.

How to model them? One way is just to keep points a and b, but that does not uniquely specify a line. Oh sure – it does if the unit circle is the elliptic plane, but my thingy is rapidly going to get too complicated for that to work well.

Ok. How about modelling it as a circle Γ, which contains the line segment, end points a and b? Well – that’s numerically unstable. I seriously dislike it – a and b will drift away from Γ. It will actually work ok, mostly, but it won’t be as nice as it could be.

So, how about two circles Γ, which contains the line segment, and Ζ, which cuts Γ at points a and b? That portion of the boundary of Γ which happens to lie inside Ζ is our line segment.

Cool. Now we are getting there. But how to choose Ζ? There’s a pencil of circles that will do the job. Well, we could just take the straight line that cuts a and b and use that. Under transformation, it will still be correct. The problem there is if Γ happens to be a straight line. Well, what about the circle where ab is a diameter? It will always be smaller than Γ. Well … except in the case where ab happens to be a diameter of Γ. This is a general problem: we need a simple way of choosing a suitable Ζ which is never identical to Γ.

The circle at right angles to Γ which intersects it at a and b fits the bill perfectly.

But how to find it? Easy as pie!

Create the moebius transform Η that maps a to (-1,0), b to (1, 0), and the center of Γ to ∞. (an if{} to handle when Γ is a straight line – easy) Our line segment ab is now the straight line from (-1,0) to (1, 0). Our Ζ’ is simply the unit circle. And so Ζ is simply the unit circle transformed by Η-1, which we already know how to do. Voila!

So, with class “LineSegment” modelled as two circles, I need some graphics primitives to return a java Shape for the arc. Transforming the segment is a matter of transforming the circles that describe it, which we can already do.

I probably need a constructor as well. In addition to a general one, and one that creates a straight line, I want one that specifically returns that line segment from a to b where a to be are inside the unit circle and the segment is a straight line in elliptical space (ie: the stereographic projection of). Shoot – while I’m at it I may as well do a constructor for the poincare projection of hyperbolic space, too.

Straight lines in the projection of elliptical space are circles that pass through the unit circle at diametrically opposite points. Straight lines in the Poincare projection of hyperbolic space are circles at right angles to the unit circle. In both cases, they are unique for a given ab with the stipulation that they don’t cross the circle (meaning that there’s a possibility of fun when a or b is on the unit circle).

Note that in hyperbolic space, a point p can be identified with 1/p. In elliptical space, p can be identified with -1/p. This means that given a segment ab, the shortest line segment joining them is not necessarily the segment contained in the unit circle. This will become important much, much later :) .

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: