/// <summary> /// This returns each link dotted with up /// NOTE: up must be a unit vector /// </summary> private static double[] GetDots(LinkResult2[] links, DoubleVector up, Point3D center, Vector3D line, Point3D[] points) { throw new ApplicationException("flawed"); // If it's an exact match, then the link is sitting on the center point if (links.Length == 1 && links[0].IsExactMatch) { return null; } double[] retVal = new double[links.Length]; for (int cntr = 0; cntr < links.Length; cntr++) { if (links[cntr].IsExactMatch) { throw new ApplicationException("Can't have an exact match in a list of non exact matches"); // or in any list greater than one } Point3D pointOnLine = Math3D.GetClosestPoint_Line_Point(center, line, points[links[cntr].Index]); // See if it's on the line //if( } // Exit Function return retVal; }
public static LinkResult3[] Test3(Point3D fromSearch, Point3D toSearch, LinkResult2[] from, LinkResult2[] to, Point3D[] points) { throw new ApplicationException("flawed"); // Check for exact match if (from.Length == 1 && to.Length == 1) { return new LinkResult3[] { new LinkResult3(from[0], to[0], 1d) }; } // Get a line between the two points Vector3D line = toSearch - fromSearch; #region FLAWED // I started by defining an up vector, but the points could go left or right of in, so I would need a double vector. Rather than go // through all that effort, just dot the froms to the tos directly //// Get an arbitrary orthoganal that will be defined as an up vector //Vector3D orth = Math3D.GetArbitraryOrhonganal(line).ToUnit(); //double[] fromDots = GetDots(from, orth); //double[] toDots = GetDots(to, orth); #endregion // Get the best matches }
/// <summary> /// Test2 takes an original point, and chooses the nearest X items from the new positions. /// /// Say two of those original points had a link. Now you could have several new points that correspond to one /// of the originals, linked to several that correspond to the second original /// /// This method creates links from one set to the other /// </summary> public static LinkResult3[] Test4(LinkResult2[] from, LinkResult2[] to, int maxReturn) { // Find the combinations that have the highest percentage List<Tuple<int, int, double>> products = new List<Tuple<int, int, double>>(); for (int fromCntr = 0; fromCntr < from.Length; fromCntr++) { for (int toCntr = 0; toCntr < to.Length; toCntr++) { products.Add(new Tuple<int, int, double>(fromCntr, toCntr, from[fromCntr].Percent * to[toCntr].Percent)); } } // Don't return too many IEnumerable<Tuple<int, int, double>> topProducts = null; if (products.Count <= maxReturn) { topProducts = products; // no need to sort or limit } else { topProducts = products. OrderByDescending(o => o.Item3). Take(maxReturn). ToArray(); } // Normalize double totalPercent = topProducts.Sum(o => o.Item3); LinkResult3[] retVal = topProducts. Select(o => new LinkResult3(from[o.Item1], to[o.Item2], o.Item3 / totalPercent)). ToArray(); return retVal; }
public LinkResult3(LinkResult2 from, LinkResult2 to, double percent) { this.From = from; this.To = to; this.Percent = percent; }