// Returns a point along the surface, expected f from 0 to Length
 public XVector2 GetPointAlongSurface(XReal f)
 {
     for (int p = 0; p < Points.Length; ++p)
     {
         XVector2 p1 = Points[p], p2 = Points[(p + 1) % Points.Length];
         XReal    len = XVector2.Distance(p1, p2);
         if (len > f)
         {
             return(XVector2.Lerp(p1, p2, f / len));
         }
         f -= len;
     }
     throw new Exception("rmPolygon::GetPointAlongSurface(), f is not in range!");
 }
Exemple #2
0
        public override bool IsPointOk(XReal tAreaX, XReal tAreaY)
        {
            var   area = Area;
            XReal dist =
                XVector2.Distance(
                    new XVector2(tAreaX, tAreaY),
                    area.Position
                    );
            XReal distFromEdge = dist - area.Size;

            if (XReal.Abs(distFromEdge) > MaxDistance ||
                XReal.Abs(distFromEdge) < MinDistance)
            {
                return(false);
            }
            return(true);
        }