youtube vid or it didn't happen ;)
Here
Reguarding border, if you want to continue with simple geometry manipulation, you could simply extrude the edges, ie: from each edge build a trapezium.
public static void main(String[] args) {
System.out.println("Accurate: " + Math.sqrt(3*3+4*4));
System.out.println("Approximation: " + 1/fastInverseSqrt(3*3+4*4));
}
static final public float fastInverseSqrt(float x)
{
float xhalf = 0.5f*x;
int bitValue = Float.floatToRawIntBits(x);
bitValue = 0x5f3759df - (bitValue >> 1);
x = Float.intBitsToFloat(bitValue);
x = x*(1.5f - xhalf*x*x);
x = x*(1.5f - xhalf*x*x);
// iterate for more accuratcy or not.
// inlined for speed-speed
//x = x*(1.5f - xhalf*x*x);
//x = x*(1.5f - xhalf*x*x);
//x = x*(1.5f - xhalf*x*x);
return x;
}
Accurate: 5.0
Approximation: 5.000018