Пример #1
0
 /// <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 = Interval1d.Remap(point.X, from.X, to.X);
     point.Y = Interval1d.Remap(point.Y, from.Y, to.Y);
     return(point);
 }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 public void Include(Interval2d other)
 {
     X.Include(other.X);
     Y.Include(other.Y);
 }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 /// <param name="tolerance"></param>
 /// <returns></returns>
 public bool ApproxEquals(Interval2d other, double tolerance)
 {
     return(X.ApproxEquals(other.X, tolerance) && Y.ApproxEquals(other.Y, tolerance));
 }
Пример #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <returns></returns>
 public static Interval2d Union(Interval2d a, Interval2d b)
 {
     a.X = Interval1d.Union(a.X, b.X);
     a.Y = Interval1d.Union(a.Y, b.Y);
     return(a);
 }
Пример #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="d0"></param>
 /// <param name="d1"></param>
 /// <returns></returns>
 public static Interval2d Intersect(Interval2d d0, Interval2d d1)
 {
     d0.X = Interval1d.Intersect(d0.X, d1.X);
     d0.Y = Interval1d.Intersect(d0.Y, d1.Y);
     return(d0);
 }
Пример #6
0
 /// <summary>
 /// Returns a random 2d vector which has components within the given interval
 /// </summary>
 /// <param name="random"></param>
 /// <param name="interval"></param>
 /// <returns></returns>
 public static Vec2d NextVec2d(this Random random, Interval2d interval)
 {
     return(new Vec2d(
                interval.X.Evaluate(random.NextDouble()),
                interval.Y.Evaluate(random.NextDouble())));
 }