public EDND(double weight, string category, ICoordinated object3D, int label) { Weight = weight; Category = category; Object3D = object3D; Label = label; }
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); }
public double ForceForeign(ICoordinated from, ICoordinated to) { var dist = from.Distance(to); var optimalMinDistance = 100; return(-Math.Max(0, (optimalMinDistance - dist) / optimalMinDistance)); }
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); }
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)); }
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); }
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); }
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); }
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); }
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)))); }
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 }); }
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; } }
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)); }
public static void SetValuesTo(this ICoordinated valueTaker, ICoordinated model) { valueTaker.X = model.X; valueTaker.Y = model.Y; valueTaker.Z = model.Z; }
public static void Move(this ICoordinated valueTaker, ICoordinated vector) { valueTaker.X += vector.X; valueTaker.Y += vector.Y; valueTaker.Z += vector.Z; }
public static void Multiply(this ICoordinated valueTaker, double multiplier) { valueTaker.X *= multiplier; valueTaker.Y *= multiplier; valueTaker.Z *= multiplier; }
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); } }
//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); }
private double GetDistanceBetweenAgents(ICoordinated agent1, ICoordinated agent2) { return(GetDistance(agent1.X, agent1.Y, agent2.X, agent2.Y)); }
public static double ScalarProduct(this ICoordinated a, ICoordinated b) { return(a.X * b.X + a.Y * b.Y + a.Z * b.Z); }
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))); }
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))); }
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; }