docs: function (bounds, vertex, next, orthogonal)
  	{
  		var x = bounds.x;
  		var y = bounds.y;
  		var a = bounds.width / 2;
  		var b = bounds.height / 2;
  		var cx = x + a;
  		var cy = y + b;
  		var px = next.x;
  		var py = next.y;
  		
  		// Calculates straight line equation through
  		// point and ellipse center y = d * x + h
  		var dx = parseInt(px - cx);
  		var dy = parseInt(py - cy);
  		
  		if (dx == 0 && dy != 0)
  		{
  			return new mxPoint(cx, cy + b * dy / Math.abs(dy));
  		}
  		else if (dx == 0 && dy == 0)
  		{
  			return new mxPoint(px, py);
  		}
  
  		if (orthogonal)
  		{
  			if (py >= y && py <= y + bounds.height)
  			{
  				var ty = py - cy;
  				var tx = Math.sqrt(a*a*(1-(ty*ty)/(b*b))) || 0;
  				
  				if (px <= x)
  				{
  					tx = -tx;
  				}
  				
  				return new mxPoint(cx+tx, py);
  			}
  			
  			if (px >= x && px <= x + bounds.width)
  			{
  				var tx = px - cx;
  				var ty = Math.sqrt(b*b*(1-(tx*tx)/(a*a))) || 0;
  				
  				if (py <= y)
  				{
  					ty = -ty;	
  				}
  				
  				return new mxPoint(px, cy+ty);
  			}
  		}
  		
  		// Calculates intersection
  		var d = dy / dx;
  		var h = cy - d * cx;
  		var e = a * a * d * d + b * b;
  		var f = -2 * cx * e;
  		var g = a * a * d * d * cx * cx +
  				b * b * cx * cx -
  				a * a * b * b;
  		var det = Math.sqrt(f * f - 4 * e * g);
  		
  		// Two solutions (perimeter points)
  		var xout1 = (-f + det) / (2 * e);
  		var xout2 = (-f - det) / (2 * e);
  		var yout1 = d * xout1 + h;
  		var yout2 = d * xout2 + h;
  		var dist1 = Math.sqrt(Math.pow((xout1 - px), 2)
  					+ Math.pow((yout1 - py), 2));
  		var dist2 = Math.sqrt(Math.pow((xout2 - px), 2)
  					+ Math.pow((yout2 - py), 2));
  					
  		// Correct solution
  		var xout = 0;
  		var yout = 0;
  		
  		if (dist1 < dist2)
  		{
  			xout = xout1;
  			yout = yout1;
  		}
  		else
  		{
  			xout = xout2;
  			yout = yout2;
  		}
  		
  		return new mxPoint(xout, yout);
  	}