Beispiel #1
0
 static bool Intersect(PlanktonLine lineA, PlanktonLine lineB, out float lineA_parameter, out float lineB_parameter)
 {
     bool rc = true;
     if (lineA.m_from == lineB.m_from)
     {
         lineA_parameter = 0f;
         lineB_parameter = 0f;
     }
     else if (lineA.m_from == lineB.m_to)
     {
         lineA_parameter = 0f;
         lineB_parameter = 1f;
     }
     else if (lineA.m_to == lineB.m_from)
     {
         lineA_parameter = 1f;
         lineB_parameter = 0f;
     }
     else if (lineA.m_to == lineB.m_to)
     {
         lineA_parameter = 1f;
         lineB_parameter = 1f;
     }
     else
     {
         lineA_parameter = 0.5f;
         lineB_parameter = 0.5f;
         ////计算
     }
     return rc;
 }
Beispiel #2
0
 public float MaximumDistanceTo(PlanktonLine L)
 {
     float a, b;
     a = MaximumDistanceTo(L.m_from);
     b = MaximumDistanceTo(L.m_to);
     return ((a < b) ? b : a);
 }
Beispiel #3
0
 public float MinimumDistanceTo(PlanktonLine L)
 {
     //公垂线
     PlanktonXYZ A, B;
     float a, b, t = 0, x = 0, d = 0;
     bool bCheckA, bCheckB;
     bool bGoodX = Intersect(this, L, out a, out b);
     bCheckA = true;
     if (a < 0f) a = 0f; else if (a > 1f) a = 1f; else bCheckA = !bGoodX;
     bCheckB = true;
     if (b < 0f) b = 0f; else if (b > 1f) b = 1f; else bCheckB = !bGoodX;
     A = PointAt(a);
     B = L.PointAt(b);
     d = A.DistanceTo(B);
     if (bCheckA)
     {
         L.ClosestPointTo(A, ref t);
         if (t < 0f) t = 0f; else if (t > 1f) t = 1f;
         x = L.PointAt(t).DistanceTo(A);
         if (x < d)
             d = x;
     }
     if (bCheckB)
     {
         ClosestPointTo(B, ref t);
         if (t < 0f) t = 0f; else if (t > 1f) t = 1f;
         x = PointAt(t).DistanceTo(B);
         if (x < d)
             d = x;
     }
     return d;
 }
Beispiel #4
0
 public bool Equals(PlanktonLine other)
 {
     return (this == other);
 }