Poincare Disk
Hi,
I'm trying to make a basic program where I have a bunch of circles on a Poincare disk, and one of them is controlled with arrow keys.
What would be handy is to do all the moving code and whatnot in Euclidean space and then make a hyperbolic projection only when I want to actually display stuff.
Unfortunately, I'm not sure how to go about this, or even if it is the best way of doing it.
What I have at the moment are three classes: A main class (not important), and a HypObject class (a generic object that lives on a hyperbolic space) and a Circ class, which extends HypObject. The two methods in question are a method for moving forward by (dx, dy), and a method for drawing the object in the appropriate place with appropriate scaling.
The moving method, which is in the HypObject class, as far as I've been able to figure, is:
publicvoid move(double dx,double dy)
{
//diskX and diskY are the circle's
//current location in the unit disk centered at the origin
double x = diskX;
double y = diskY;
//Using the metric tensor to
//calculate the distance being moved
double ds = 2*Math.sqrt(dx*dx + dy*dy)/(1 - x*x - y*y);
double theta = Math.atan(dy/dx);
double R = 1;
if(y >= 0)
{
R = (x*x + y*y - 1) / (2*y);
}
else
{
R = (x*x + y*y - 1) / (-2*y);//?
}
//R now represents the radius of the circle that makes
//the geodesic tangent to the (Euclidean) vector (dx, dy).
//Using this, we can move a distance ds
//along this arc in the appropriate direction to get
//the new diskX and diskY:
double psi = ds / R;
double D = Math.sqrt(dx*dx + dy*dy);
//The cartesian coords of the center of the ``geodesic circle'':
double cx = x + (R*dy) / D;
double cy = y - (R*dy) / D;
double newX = cx + R*Math.sin(psi - theta);
double newY = cy - R*Math.cos(psi - theta);
diskX = newX;
diskY = newY;
}
That's the gist of my current approach, but I'll want to get this one settled out before I start drawing things.
It seems somewhat wrong, judging from numerical output, but I'm not exactly sure what to fix, as it doesn't really follow the way of doing this I was hoping to get.
Thanks in advance for your help!

