Blame mono/Assistance/Geometry.cs

cfceb0
using System;
cfceb0
cfceb0
namespace Assistance {
cfceb0
	public static class Geometry {
d13872
		public static readonly double precision = 1e-8;
cfceb0
		public static readonly double sqrt2Pi = Math.Sqrt(2.0*Math.PI);
cfceb0
		
cfceb0
		public static double logNormalDistribuitionUnscaled(double x, double x0, double w) {
cfceb0
			return Math.Exp(-0.5*Math.Pow(Math.Log(x/x0)/w, 2.0))/x;
cfceb0
		}
cfceb0
		
cfceb0
		public static double logNormalDistribuition(double x, double x0, double w) {
cfceb0
			return logNormalDistribuition(x, x0, w)/(w*sqrt2Pi);
cfceb0
		}
cfceb0
		
cfceb0
		public static void truncateInfiniteLine(Rectangle bounds, ref Point p0, ref Point p1) {
cfceb0
			if (p0.isEqual(p1)) return;
cfceb0
			Point d = p0 - p1;
cfceb0
			if (Math.Abs(d.x)*bounds.height > bounds.width*Math.Abs(d.y)) {
cfceb0
				// horizontal
cfceb0
				double k = d.y/d.x;
cfceb0
				p1 = new Point(bounds.x1, p0.y + k*(bounds.x1 - p0.x));
cfceb0
				p0 = new Point(bounds.x0, p0.y + k*(bounds.x0 - p0.x));
cfceb0
			} else {
cfceb0
				// vertical
cfceb0
				double k = d.x/d.y;
cfceb0
				p1 = new Point(p0.x + k*(bounds.y1 - p0.y), bounds.y1);
cfceb0
				p0 = new Point(p0.x + k*(bounds.y0 - p0.y), bounds.y0);
cfceb0
			}
cfceb0
		}
cfceb0
	}
cfceb0
}