Пример #1
0
 /// <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);
 }
Пример #2
0
 /// <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);
 }
Пример #3
0
 /// <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);
 }
Пример #4
0
 /// <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())));
 }
Пример #5
0
        /// <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(SlurMath.Remap(t, from.A, from.B, to.A, to.B));
        }
Пример #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="points"></param>
        public Interval2d(IEnumerable <Vec2d> points)
            : this()
        {
            var p = points.First();

            X = new Intervald(p.X);
            Y = new Intervald(p.Y);

            Include(points.Skip(1));
        }
Пример #7
0
        /// <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);
            }
        }
Пример #8
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 = Intervald.Remap(point.X, from.X, to.X);
     point.Y = Intervald.Remap(point.Y, from.Y, to.Y);
     return(point);
 }
Пример #9
0
 /// <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);
 }
Пример #10
0
 /// <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);
 }
Пример #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ab"></param>
 public Interval2d(Vec2d ab)
 {
     X = new Intervald(ab.X);
     Y = new Intervald(ab.Y);
 }
Пример #12
0
 /// <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);
 }
Пример #13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 /// <param name="tolerance"></param>
 /// <returns></returns>
 public bool ApproxEquals(Intervald other, double tolerance = SlurMath.ZeroTolerance)
 {
     return
         (SlurMath.ApproxEquals(A, other.A, tolerance) &&
          SlurMath.ApproxEquals(B, other.B, tolerance));
 }
Пример #14
0
 /// <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;
 }
Пример #15
0
 /// <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();
 }
Пример #16
0
 /// <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);
 }
Пример #17
0
 /// <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);
 }
Пример #18
0
 /// <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);
 }
Пример #19
0
 /// <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);
 }
Пример #20
0
 /// <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);
 }
Пример #21
0
 /// <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);
 }
Пример #22
0
 /// <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();
 }
Пример #23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 public Interval2d(Intervald x, Intervald y)
 {
     X = x;
     Y = y;
 }
Пример #24
0
 /// <summary>
 /// Expands this interval to include another
 /// </summary>
 /// <param name="other"></param>
 public void Include(Intervald other)
 {
     Include(other.A);
     Include(other.B);
 }
Пример #25
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 /// <param name="tolerance"></param>
 /// <returns></returns>
 public bool ApproxEquals(Intervald other, double tolerance = SlurMath.ZeroTolerance)
 {
     return(Math.Abs(other.A - A) < tolerance && Math.Abs(other.B - B) < tolerance);
 }