/// <summary> /// Returns a random vector which has components within the given interval. /// </summary> /// <param name="random"></param> /// <param name="interval"></param> /// <returns></returns> public static Vector3d NextVector3d(this Random random, Intervald interval) { return(new Vector3d( interval.Evaluate(random.NextDouble()), interval.Evaluate(random.NextDouble()), interval.Evaluate(random.NextDouble()))); }
/// <summary> /// /// </summary> /// <param name="point"></param> /// <param name="from"></param> /// <param name="to"></param> /// <returns></returns> public static Vector3d Remap(Vector3d point, Interval3d from, Interval3d to) { point.X = Intervald.Remap(point.X, from.X, to.X); point.Y = Intervald.Remap(point.Y, from.Y, to.Y); point.Y = Intervald.Remap(point.Z, from.Z, to.Z); return(point); }
/// <summary> /// Expands this interval to include another /// </summary> /// <param name="other"></param> public void Include(Intervald other) { if (IsDecreasing) { IncludeNeg(other.A); IncludeNeg(other.B); } else { IncludePos(other.A); IncludePos(other.B); } }
/// <summary> /// /// </summary> /// <param name="points"></param> public Interval2d(IEnumerable <Vector2d> points) : this() { (var x, var y) = points.First(); X = new Intervald(x); Y = new Intervald(y); foreach (var p in points.Skip(1)) { X.IncludePos(p.X); Y.IncludePos(p.Y); } }
/// <summary> /// /// </summary> /// <param name="random"></param> /// <param name="interval"></param> /// <param name="result"></param> /// <returns></returns> public static void NextMatrix3d(this Random random, Intervald interval, out Matrix3d result) { result = new Matrix3d( interval.Evaluate(random.NextDouble()), interval.Evaluate(random.NextDouble()), interval.Evaluate(random.NextDouble()), interval.Evaluate(random.NextDouble()), interval.Evaluate(random.NextDouble()), interval.Evaluate(random.NextDouble()), interval.Evaluate(random.NextDouble()), interval.Evaluate(random.NextDouble()), interval.Evaluate(random.NextDouble()) ); }
/// <summary> /// Returns the union of a and b. /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static Intervald Union(Intervald a, Intervald b) { a.Include(b.A); a.Include(b.B); return(a); }
/// <summary> /// /// </summary> /// <param name="t"></param> /// <param name="from"></param> /// <param name="to"></param> /// <returns></returns> public static double Remap(double t, Intervald from, Intervald to) { return(SlurMath.Remap(t, from.A, from.B, to.A, to.B)); }
/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> public void Deconstruct(out Intervald x, out Intervald y, out Intervald z) { x = X; y = Y; z = Z; }
/// <summary> /// /// </summary> /// <param name="x0"></param> /// <param name="x1"></param> /// <param name="y0"></param> /// <param name="y1"></param> /// <param name="z0"></param> /// <param name="z1"></param> public Interval3d(double x0, double x1, double y0, double y1, double z0, double z1) { X = new Intervald(x0, x1); Y = new Intervald(y0, y1); Z = new Intervald(z0, z1); }
/// <summary> /// /// </summary> /// <param name="center"></param> /// <param name="offsetX"></param> /// <param name="offsetY"></param> /// <param name="offsetZ"></param> public Interval3d(Vector3d center, double offsetX, double offsetY, double offsetZ) { X = new Intervald(center.X - offsetX, center.X + offsetX); Y = new Intervald(center.Y - offsetY, center.Y + offsetY); Z = new Intervald(center.Z - offsetZ, center.Z + offsetZ); }
/// <summary> /// /// </summary> /// <param name="a"></param> /// <param name="b"></param> public Interval3d(Vector3d a, Vector3d b) { X = new Intervald(a.X, b.X); Y = new Intervald(a.Y, b.Y); Z = new Intervald(a.Z, b.Z); }
/// <summary> /// /// </summary> /// <param name="center"></param> /// <param name="offsetX"></param> /// <param name="offsetY"></param> public Interval2d(Vector2d center, double offsetX, double offsetY) { X = new Intervald(center.X - offsetX, center.X + offsetX); Y = new Intervald(center.Y - offsetY, center.Y + offsetY); }
/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> public Interval2d(Intervald x, Intervald y) { X = x; Y = y; }
/// <summary> /// /// </summary> /// <param name="other"></param> /// <param name="epsilon"></param> /// <returns></returns> public bool ApproxEquals(Intervald other, double epsilon = D.ZeroTolerance) { return (SlurMath.ApproxEquals(A, other.A, epsilon) && SlurMath.ApproxEquals(B, other.B, epsilon)); }
/// <summary> /// Returns a random matrix which has components within the given interval. /// </summary> /// <param name="random"></param> /// <param name="interval"></param> /// <returns></returns> public static Matrix4d NextMatrix4d(this Random random, Intervald interval) { NextMatrix4d(random, interval, out Matrix4d m); return(m); }
/// <summary> /// /// </summary> /// <param name="ab"></param> public Interval2d(Vector2d ab) { X = new Intervald(ab.X); Y = new Intervald(ab.Y); }
/// <summary> /// /// </summary> /// <param name="x0"></param> /// <param name="x1"></param> /// <param name="y0"></param> /// <param name="y1"></param> public Interval2d(double x0, double x1, double y0, double y1) { X = new Intervald(x0, x1); Y = new Intervald(y0, y1); }
/// <summary> /// Returns the region of a that is also in b. /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static Intervald Intersect(Intervald a, Intervald b) { throw new NotImplementedException(); }
/// <summary> /// /// </summary> /// <param name="ab"></param> public Interval3d(Vector3d ab) { X = new Intervald(ab.X); Y = new Intervald(ab.Y); Z = new Intervald(ab.Z); }
/// <summary> /// Returns the region of a that is not in b. /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static Intervald Difference(Intervald a, Intervald b) { throw new NotImplementedException(); }
/// <summary> /// /// </summary> /// <param name="a"></param> /// <param name="b"></param> public Interval2d(Vector2d a, Vector2d b) { X = new Intervald(a.X, b.X); Y = new Intervald(a.Y, b.Y); }
/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> public Interval3d(Intervald x, Intervald y, Intervald z) { X = x; Y = y; Z = z; }
/// <summary> /// /// </summary> /// <param name="point"></param> /// <param name="from"></param> /// <param name="to"></param> /// <returns></returns> public static Vector2d Remap(Vector2d point, Interval2d from, Interval2d to) { point.X = Intervald.Remap(point.X, from.X, to.X); point.Y = Intervald.Remap(point.Y, from.Y, to.Y); return(point); }