/// <summary> /// /// </summary> /// <param name="d0"></param> /// <param name="d1"></param> /// <returns></returns> public static Interval3d Intersect(Interval3d d0, Interval3d d1) { d0.X = Intervald.Intersect(d0.X, d1.X); d0.Y = Intervald.Intersect(d0.Y, d1.Y); d0.Z = Intervald.Intersect(d0.Z, d1.Z); return(d0); }
/// <summary> /// /// </summary> /// <param name="point"></param> /// <param name="from"></param> /// <param name="to"></param> /// <returns></returns> public static Vec3d Remap(Vec3d 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> /// /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static Interval3d Union(Interval3d a, Interval3d b) { a.X = Intervald.Union(a.X, b.X); a.Y = Intervald.Union(a.Y, b.Y); a.Z = Intervald.Union(a.Z, b.Z); return(a); }
/// <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 Vec3d NextVec3d(this Random random, Intervald interval) { return(new Vec3d( interval.Evaluate(random.NextDouble()), interval.Evaluate(random.NextDouble()), interval.Evaluate(random.NextDouble()))); }
/// <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) { if (!from.IsValid) { throw new InvalidOperationException("Can't remap from an invalid interval"); } return(zMath.Remap(t, from.A, from.B, to.A, to.B)); }
/// <summary> /// /// </summary> /// <param name="points"></param> public Interval2d(IEnumerable <Vec2d> points) : this() { (var x, var y) = points.First(); X = new Intervald(x); Y = new Intervald(y); foreach (var p in points.Skip(1)) { X.IncludeIncreasing(p.X); Y.IncludeIncreasing(p.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="a"></param> /// <param name="b"></param> /// <returns></returns> public static Interval2d Union(Interval2d a, Interval2d b) { a.X = Intervald.Union(a.X, b.X); a.Y = Intervald.Union(a.Y, b.Y); return(a); }
/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> public Interval2d(Intervald x, Intervald y) { X = x; Y = y; }
/// <summary> /// /// </summary> /// <param name="ab"></param> public Interval2d(Vec2d ab) { X = new Intervald(ab.X); Y = new Intervald(ab.Y); }
/// <summary> /// Expands this interval to include another /// </summary> /// <param name="other"></param> public void Include(Intervald other) { Include(other.A); Include(other.B); }
/// <summary> /// /// </summary> /// <param name="other"></param> /// <param name="tolerance"></param> /// <returns></returns> public bool ApproxEquals(Intervald other, double tolerance = zMath.ZeroTolerance) { return (zMath.ApproxEquals(A, other.A, tolerance) && zMath.ApproxEquals(B, other.B, tolerance)); }
/// <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="point"></param> /// <param name="from"></param> /// <param name="to"></param> /// <returns></returns> public static Vec2d Remap(Vec2d 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); }
/// <summary> /// /// </summary> /// <param name="center"></param> /// <param name="offsetX"></param> /// <param name="offsetY"></param> /// <param name="offsetZ"></param> public Interval3d(Vec3d 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="ab"></param> public Interval3d(Vec3d ab) { X = new Intervald(ab.X); Y = new Intervald(ab.Y); Z = new Intervald(ab.Z); }
/// <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> /// /// </summary> /// <param name="center"></param> /// <param name="offsetX"></param> /// <param name="offsetY"></param> public Interval2d(Vec2d 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="a"></param> /// <param name="b"></param> public Interval2d(Vec2d a, Vec2d b) { X = new Intervald(a.X, b.X); Y = new Intervald(a.Y, b.Y); }
/// <summary> /// /// </summary> /// <param name="a"></param> /// <param name="b"></param> public Interval3d(Vec3d a, Vec3d b) { X = new Intervald(a.X, b.X); Y = new Intervald(a.Y, b.Y); Z = new Intervald(a.Z, b.Z); }
/// <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="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> /// 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(); }