/// <summary> /// Sets random hyperplane which has points in the given region /// </summary> /// <param name="region"></param> /// <param name="hplane"></param> public static void SetRandPlane(Hyperrect region, ref Hyperplane hplane) { hplane.Point.SetRandom(region); hplane.Normal.SetRandom(-1.0, 1.0); hplane.Normal.Multiply(1.0 / Math.Sqrt(hplane.Normal.SquaredNorm())); hplane.Distance = hplane.Point.DotProduct(hplane.Normal); }
/// <summary> /// Sets each component of this vector to a random value within the region /// </summary> /// <param name="ro"></param> /// <param name="limA"></param> /// <param name="range"></param> public static void SetRandom(this double[] ro, Hyperrect region) { for (int i = 0; i < ro.Length; i++) { ro[i] = region.PointA[i] + (region.PointB[i] - region.PointA[i]) * Rnd.NextDouble(); } }