Beispiel #1
0
        /// <summary>
        /// Construct
        /// </summary>
        /// <param name="body"></param>
        /// <returns></returns>
        private static List<Node> Construct(CircleBody body, int distanceFromBody, int maxDistanceBetweenEachNode)
        {
            List<Node> result = new List<Node>();

            int numNodes = (int)(2 * MathHelper.Pi * body.GetRadius()) / maxDistanceBetweenEachNode;

            for (int i = 0; i < numNodes; i++)
            {
                float angle = ((float)i / (float)numNodes) * MathHelper.TwoPi;
                Vector2 angleUnitVector = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle));
                result.Add(new Node(body.GetPosition() + (body.GetRadius() + distanceFromBody) * angleUnitVector));
            }

            return result;
        }