# Drawing Circle!!

This topic is 3206 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I want to draw a circle with a certain radius and also centered where its positioned. I am drawing my circle as really small dots but I cant seem to add the above to my liking.
float angle = 0;
for (int i = 1; i < = 360; i++)
{
segmentLocation.X += (float)Math.Cos(angle);
segmentLocation.Y += (float)Math.Sin(angle);
spriteBatch.Draw(blank, segmentLocation, null, Color.White, angle, new Vector2(blank.Width/2f,blank.Height/2f), 1f, SpriteEffects.None, 1f);
}


What I m trying to do is to draw the circumcircle of a triangle. I have its center and its radius calculated. EDIT: I also have the three points if there's a technique for that :P, I have almost everything apart how to draw the bloody circle :P

##### Share on other sites
Store the center position separately.

center_point.xy = center of triangle;for(...) {  segmentLocation.X = center_point.x + cos(angle);  segmentLocation.Y = center_point.y + sin(angle);  draw(...);}

##### Share on other sites
actually segmentLocation = center_point thats what I was giving it.
thats the only way to know where to start drawing the circle anyway

##### Share on other sites
Yes, but you need to keep it as a separate variable, and update every iteration. You can't just do += cos(angle), but must start from the original center and add the cos/sin(angle) every iteration.

##### Share on other sites
OK, sorry I didn't understand what you meant at first :)

But that doesn't really make it go in its circumcircle the size of the circle is always 1 and can't make it into the needed size every time for different sized triangles

##### Share on other sites
Not sure I understand exactly what you mean, but to draw points around a circle with radius r at center-point c, you can do it like this:
for each angle {  position.x = c.x + r * cos(angle);  position.y = c.y + r * sin(angle);    draw_point_at(position);}

You could also just create a vertex-buffer with the 360 points of a unit-circle and then draw it with a different transformation-matrix, depending on the radius (scale) and center-point (translation) of the circle you want.

##### Share on other sites
Yeah but the method I wrote always draws in a certain size the circle and what I m trying to do is draw a circle that passes from a triangle's 3 vertices, its circumcircle :)

The way I draw the circle makes it always the same size

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633702
• Total Posts
3013451
×