Skip Navigation | ANU Home | Search ANU | SoCS | Staff Login
The Australian National University
ANU College of Engineering and Computer Science
School of Computer Science
Printer Friendly Version of this Document

UniSAFE

ericm's blog

Code for calculating the intersection of two circles

I needed to calculate the intersecting points between two circles in Java and ended up with :

public XYPoint[] intersect(Circle b) {
double d = c.distance(b.c);
if (d >= r + b.r || r + d < b.r || b.r + d < r)
return null;

double ax2 = c.x * c.x;
double ay2 = c.y * c.y;
double bx2 = b.c.x * b.c.x;
double by2 = b.c.y * b.c.y;
double ar2 = r * r;
double br2 = b.r * b.r;
double lx = 2.0 * (b.c.x - c.x);
double ly = 2.0 * (b.c.y - c.y);
double l = ar2 - br2 - ax2 - ay2 + bx2 + by2;

double qa = lx * lx + ly * ly;

Fission DVB usb card from Aldi

Hoping to get this card working....

The Pegasus Pen - Getting it working on linux

This is a simple pen device (with vendor:product id 0e20:0100) which enables you to have what you write on paper read by the computer. When the USB device is plugged in it appears as the file /dev/usb/hiddev0, I read a sequence of bytes from this file and attempt work out the xy-position. The java code is available in my junk code directory. Note you need to make this file user readable with chmod.

Syndicate content