Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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 ;
share|improve this question
Set end angle to 2*pi. The spacing between points in radiants is your angleincrement. To get the Euclidean distance between two point the easiest way is calculating the distance of any two neighbouring points of the result. –  Archy Dec 15 '12 at 8:49
add comment

1 Answer

up vote 3 down vote accepted

Set endAngle to 2π. The spacing between points in radians is your angleIncrement.
To get the Euclidean distance between two point the easiest way is calculating the distance between any two neighbouring points of the result.

Also convert endAngle and angelIncrement to float.

share|improve this answer
Thanks for the answer. When i do this private int endAngle = 2 * (int)Math.PI ; i dont get anything if ammount of points is higher than 6. Why? –  Lautaro Dec 15 '12 at 10:11
@Lautaro because your angleIncrementation is int and you're doing integer division when assigning to it. Make angleIncrementation and endAngle a double and use radians (from 0 to 2π) instead of degrees as Archy suggested. double endAngle = 2*Math.PI; double angleIncrementation; –  Niko Drašković Dec 15 '12 at 12:54
Thanks for formatting, I did write that on my phone, same reason I made a comment by mistake :) –  Archy Dec 15 '12 at 18:49
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.