Points around a circumference C#

Posted by Lautaro on Game Development See other posts from Game Development or by Lautaro
Published on 2012-12-15T07:42:06Z Indexed on 2012/12/15 11:24 UTC
Read the original article Hit count: 203

Filed under:
|

Im trying to get a list of vectors that go around a circle, but i keep getting the circle to go around several times. I want one circel and the dots to be placed along its circumference. I want the first dot to start at 0 and the last dot to end just before 360. Also i need to be able to calculate the spacing by the ammount of points.

  List<Vector2> pointsInPath = new List<Vector2>();
    private int ammountOfPoints = 5;
    private int blobbSize = 200;
    private Vector2 topLeft = new Vector2(100, 100);
    private Vector2 blobbCenter;
    private int endAngle = 50;
    private int angleIncrementation;
    public Blobb()
    {
        blobbCenter = new Vector2(blobbSize / 2, blobbSize / 2) + topLeft;
        angleIncrementation = endAngle / ammountOfPoints;

        for (int i = 0; i < ammountOfPoints; i++)
        {
            pointsInPath.Add(getPointByAngle(i * angleIncrementation, 100, blobbCenter));
          //  pointsInPath.Add(getPointByAngle(i * angleIncrementation, blobbSize / 2, blobbCenter));
        }
    }

    private Vector2 getPointByAngle(float angle, float distance, Vector2 centre)
    {
        return new Vector2((float)(distance * Math.Cos(angle) ), (float)(distance * Math.Sin(angle))) + centre ;
    }

© Game Development or respective owner

Related posts about c#

Related posts about trigonometry