/// <summary> /// /// </summary> /// <param name="t"></param> /// <param name="from"></param> /// <param name="to"></param> /// <returns></returns> public static double Remap(double t, Interval1d from, Interval1d 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> /// Expands this interval to include another /// </summary> /// <param name="other"></param> public void Include(Interval1d other) { Include(other.A); Include(other.B); }
/// <summary> /// /// </summary> /// <param name="other"></param> /// <param name="tolerance"></param> /// <returns></returns> public bool ApproxEquals(Interval1d other, double tolerance = zMath.ZeroTolerance) { return(Math.Abs(other.A - A) < tolerance && Math.Abs(other.B - 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 Interval1d Difference(Interval1d a, Interval1d b) { throw new NotImplementedException(); }
/// <summary> /// Returns the region of a that is also in b. /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static Interval1d Intersect(Interval1d a, Interval1d b) { throw new NotImplementedException(); }
/// <summary> /// Returns the union of a and b. /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static Interval1d Union(Interval1d a, Interval1d b) { a.Include(b.A); a.Include(b.B); return(a); }