Esempio n. 1
0
 public EDND(double weight, string category, ICoordinated object3D, int label)
 {
     Weight   = weight;
     Category = category;
     Object3D = object3D;
     Label    = label;
 }
Esempio n. 2
0
        public double ForceNbs(ICoordinated from, ICoordinated to)
        {
            var dist = from.Distance(to);

            return(Math.Min(25, -8 + dist * 0.5));
            //return -Math.Min(100, Math.Exp(-dist * 0.01)) + Math.Log(dist);
        }
Esempio n. 3
0
        public double ForceForeign(ICoordinated from, ICoordinated to)
        {
            var dist = from.Distance(to);

            var optimalMinDistance = 100;

            return(-Math.Max(0, (optimalMinDistance - dist) / optimalMinDistance));
        }
Esempio n. 4
0
        public static ICoordinated Normalize(this ICoordinated vector)
        {
            var length = Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y + vector.Z * vector.Z);

            vector.X /= length;
            vector.Y /= length;
            vector.Z /= length;
            return(vector);
        }
Esempio n. 5
0
        public double ForceRepell(ICoordinated from, ICoordinated to)
        {
            var dist = from.Distance(to);

            var distOne = 20;

            return(Math.Min(0, -distOne + dist * 0.25));
            //return -distOne / (3 * dist);
            //return -Math.Min(10, Math.Exp(-dist * 0.01));
        }
Esempio n. 6
0
        public static Vector Plus(this ICoordinated a, ICoordinated b)
        {
            var vector = new Vector();

            vector.X = a.X + b.X;
            vector.Y = a.Y + b.Y;
            vector.Z = a.Z + b.Z;

            return(vector);
        }
Esempio n. 7
0
        public static double AngleBetween(this ICoordinated point, ICoordinated a, ICoordinated b)
        {
            var distA    = point.Distance(a);
            var distB    = point.Distance(b);
            var DistC    = a.Distance(b);
            var angleCos = (Math.Pow(distA, 2) + Math.Pow(distB, 2) - Math.Pow(DistC, 2)) / (2 * distA * distB);
            var angle    = Math.Acos(angleCos);

            return(angle);
        }
Esempio n. 8
0
        public static Vector Minus(this ICoordinated a, ICoordinated b)
        {
            var vector = new Vector();

            vector.X = a.X - b.X;
            vector.Y = a.Y - b.Y;
            vector.Z = a.Z - b.Z;

            return(vector);
        }
Esempio n. 9
0
        public static Vector CrossProduct(this ICoordinated a, ICoordinated b)
        {
            var cp = new Vector();

            cp.X = a.Y * b.Z - a.Z * b.Y;
            cp.Y = a.Z * b.X - a.X * b.Z;
            cp.Z = a.X * b.Y - a.Y * b.X;

            return(cp);
        }
Esempio n. 10
0
        public double ForceRepell(ICoordinated from, ICoordinated to)
        {
            var dist = from.Distance(to);

            var distOne = 20;

            //  return 20 * Math.Min(0, -distOne + dist * 0.25);
            //   return -distOne / (3 * dist);
            //  return 12 * -Math.Min(100, Math.Exp(-dist * 0.0));
            return(-1000 * (1 / (Math.Pow(dist, 1.1))));
        }
Esempio n. 11
0
        private Vector getVector_(ICoordinated first, ICoordinated second)
        {
            if (second == null || first == null)
            {
                return(new Vector());
            }

            return(new Vector
            {
                X = second.X - first.X,
                Y = second.Y - first.Y
            });
        }
Esempio n. 12
0
        public HessePlane(ICoordinated a, ICoordinated b, ICoordinated c)
        {
            NormalVector = (b.Minus(a)).CrossProduct(c.Minus(a));
            NormalVector.Normalize();

            RootDistance = a.ScalarProduct(NormalVector);
            if (RootDistance < 0)
            {
                RootDistance   *= -1;
                NormalVector.X *= -1;
                NormalVector.Y *= -1;
                NormalVector.Z *= -1;
            }
        }
Esempio n. 13
0
        public double ForceNbs(ICoordinated from, ICoordinated to)
        {
            var dist = from.Distance(to);

            //if (dist < 50)
            //    return 25;
            //if( dist < 200)
            //{
            //    return  (dist-50) * 0.125;
            //}
            //else

            //return (dist-200) * 0.5;
            return(Math.Pow(Math.Log(dist), 2));
        }
Esempio n. 14
0
 public static void SetValuesTo(this ICoordinated valueTaker, ICoordinated model)
 {
     valueTaker.X = model.X;
     valueTaker.Y = model.Y;
     valueTaker.Z = model.Z;
 }
Esempio n. 15
0
 public static void Move(this ICoordinated valueTaker, ICoordinated vector)
 {
     valueTaker.X += vector.X;
     valueTaker.Y += vector.Y;
     valueTaker.Z += vector.Z;
 }
Esempio n. 16
0
 public static void Multiply(this ICoordinated valueTaker, double multiplier)
 {
     valueTaker.X *= multiplier;
     valueTaker.Y *= multiplier;
     valueTaker.Z *= multiplier;
 }
Esempio n. 17
0
        public static double determineCurvingCase(this ICoordinated point, IEnumerable <ICoordinated> otherPoints, double flatnessPlane)
        {
            var isConvex   = false;
            var isFlat     = false;
            int left       = 0;
            int right      = 0;
            int Inplane    = 0;
            var neighbours = otherPoints.ToList();

            for (int i1 = neighbours.Count - 1; i1 >= 1; i1--)
            {
                var nb1 = neighbours[i1];

                for (int i2 = i1 - 1; i2 >= 0; i2--)
                {
                    var nb2 = neighbours[i2];

                    var plane = new HessePlane(nb1, nb2, point);

                    for (int i4 = 0; i4 < neighbours.Count; i4++)
                    {
                        if (i4 == i1 || i4 == i2)
                        {
                            continue;
                        }
                        var otherNb = neighbours[i4];

                        var dist = otherNb.DistanceValue(plane);

                        if (Math.Abs(dist) < flatnessPlane)
                        {
                            Inplane++;
                        }
                        else
                        {
                            if (dist < 0)
                            {
                                left++;
                            }
                            else
                            {
                                right++;
                            }
                        }
                    }

                    if (Inplane == 0)
                    {
                        if (left == 0 || right == 0)
                        {
                            isConvex = true;
                        }
                    }
                    else
                    {
                        if (left == 0 || right == 0)
                        {
                            isFlat = true;
                        }
                    }

                    if (isConvex)
                    {
                        break;
                    }
                }
                if (isConvex)
                {
                    break;
                }
            }
            if (isConvex)
            {
                return(1);
            }
            else if (isFlat)
            {
                return(0);
            }
            else
            {
                return(-1);
            }
        }
Esempio n. 18
0
        //public static Vector Subtr(this ICoordinated a, ICoordinated b)
        //{
        //    var vector = new Vector();

        //    vector.X = a.X - b.X;
        //    vector.Y = a.Y - b.Y;
        //    vector.Z = a.Z - b.Z;

        //    return vector;
        //}
        public static double DistanceValue(this ICoordinated vector, HessePlane plane)
        {
            return(vector.ScalarProduct(plane.NormalVector) - plane.RootDistance);
        }
Esempio n. 19
0
 private double GetDistanceBetweenAgents(ICoordinated agent1, ICoordinated agent2)
 {
     return(GetDistance(agent1.X, agent1.Y, agent2.X, agent2.Y));
 }
Esempio n. 20
0
 public static double ScalarProduct(this ICoordinated a, ICoordinated b)
 {
     return(a.X * b.X + a.Y * b.Y + a.Z * b.Z);
 }
Esempio n. 21
0
 public static double Length(this ICoordinated from)
 {
     return(Math.Sqrt(Math.Pow(from.X, 2.0) + Math.Pow(from.Y, 2.0) + Math.Pow(from.Z, 2.0)));
 }
Esempio n. 22
0
 public static double Distance(this ICoordinated from, ICoordinated to)
 {
     return(Math.Sqrt(Math.Pow(from.X - to.X, 2.0) + Math.Pow(from.Y - to.Y, 2.0) + Math.Pow(from.Z - to.Z, 2.0)));
 }
Esempio n. 23
0
 public static void Add(this ICoordinated a, ICoordinated b)
 {
     a.X = a.X + b.X;
     a.Y = a.Y + b.Y;
     a.Z = a.Z + b.Z;
 }