public double EuclideanDistanceTo(Point3Dd other) { return(Math.Sqrt(Math.Pow(other.X - X, 2) + Math.Pow(other.Y - Y, 2) + Math.Pow(other.Z - Z, 2))); }
public double EuclideanDistanceTo(Point3Dd other) { return Math.Sqrt(Math.Pow(other.X - X, 2) + Math.Pow(other.Y - Y, 2) + Math.Pow(other.Z - Z, 2)); }
public double EuclideanDistanceTo(Point3Dd other) { return(this.CenterPoint().EuclideanDistanceTo(other)); }
uint SSDTLoopEco(IList <Point3DExd> scluster, Point3Dd rootPoint = null) { if (rootPoint == null) { // use double sweep algorithm. Point3DExd p = scluster[0]; uint maxDistance = 0; // とりあえず何かセットしておかないとunassigned variableと言われてしまうので for (int i = 0; i < 2; i++) { foreach (var q in scluster) { q.ResetFlag(); } var que = new Queue <Point3DExd>(); p.SetFlag(); p.Distance = 0; que.Enqueue(p); maxDistance = 0; while (que.Count > 0) { var q = que.Dequeue(); foreach (var next in q.cobj) { if (next.flag == false) { next.SetFlag(); next.Distance = q.Distance + 1; que.Enqueue(next); maxDistance = Math.Max(maxDistance, next.Distance); // set final node to p p = next; } } } } foreach (var q in scluster) { q.ResetFlag(); } return(maxDistance); } else { // let p is root node. // p is node that argmin~p (distance(p, rootPoint)) Point3DExd p = scluster[0]; foreach (var q in scluster) { q.ResetFlag(); double dp = Math.Pow(p.X - rootPoint.X, 2) + Math.Pow(p.Y - rootPoint.Y, 2) + Math.Pow(p.Z - rootPoint.Z, 2); double dq = Math.Pow(q.X - rootPoint.X, 2) + Math.Pow(q.Y - rootPoint.Y, 2) + Math.Pow(q.Z - rootPoint.Z, 2); if (dq < dp) { p = q; } } var que = new Queue <Point3DExd>(); p.Distance = 0; que.Enqueue(p); uint maxDistance = 0; while (que.Count > 0) { var q = que.Dequeue(); foreach (var next in q.cobj) { if (next.flag == false) { next.Distance = q.Distance + 1; maxDistance = Math.Max(maxDistance, next.Distance); que.Enqueue(next); } } } foreach (var q in scluster) { q.ResetFlag(); } return(maxDistance); } }
public double EuclideanDistanceTo(Point3Dd other) { return this.CenterPoint().EuclideanDistanceTo(other); }