#### Archived

This topic is now archived and is closed to further replies.

# Drawing a circle with vertices?

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

## Recommended Posts

How can I use vertices and DrawPrimitive to create a circle?

##### Share on other sites
Equation for a circle:

r² = (x-h)² + (y-k)²

Where r is the radius, (x,y) is your point on the circle, and (h,k) is the center of the circle.

##### Share on other sites
better yet:

x = Rcos(theta)
y = Rsin(theta)

use values between 0 and 2pi. More values = more circular circle.

##### Share on other sites
Yes thank you for giving me equations for circles which I already knew. Now, how do I apply this to the vertices in DirectX?

[edited by - Sardius2 on August 14, 2003 10:16:24 PM]

##### Share on other sites
It sounds like what you''re asking is, "How do I use DirectX?"

Step 1: Learn DirectX.

Specifically, you lock a vertex buffer, copy values, unlock it, set it up.. blah blah. You use DirectX, basically.

I like pie.

##### Share on other sites
Sounds like your not very helpful. I know how to do all that. Im not asking how to draw with Direct3d, I''m asking how to create the circle in the vertices. But aparently no one else here knows how to do that. Moot point then?

##### Share on other sites
AP gave you your x and your y, what else do you need? Simply iterate from 0 to 2pi, the size of the ''step'' between iteration decides the smoothness of the circle.

##### Share on other sites
Yes, amazingly, no one here has figured out how to draw circles, and frankly, we''re quite upset about it, so no need to rub salt in old wounds!!

This is as far as we''ve gotten (we are presently working on getting more DARPA funding)
1. Create a vertex buffer, fill it with 2 vertices to draw a line. If you can draw it, have a beer.
2. Add one more vertex to the buffer and draw a line strip. If the strip draws, have another beer.
3. Use the aforementioned equations when adding more points to the vertex buffer. If you can implement the equations, have another beer.

At this point, we usually pass out and wake up with serious headaches (we''re lightweights), forcing us to start at #1. Perhaps you can get farther.

##### Share on other sites
quote:
Original post by Anonymous Poster
Yes, amazingly, no one here has figured out how to draw circles, and frankly, we''re quite upset about it, so no need to rub salt in old wounds!!

This is as far as we''ve gotten (we are presently working on getting more DARPA funding)
1. Create a vertex buffer, fill it with 2 vertices to draw a line. If you can draw it, have a beer.
2. Add one more vertex to the buffer and draw a line strip. If the strip draws, have another beer.
3. Use the aforementioned equations when adding more points to the vertex buffer. If you can implement the equations, have another beer.

At this point, we usually pass out and wake up with serious headaches (we''re lightweights), forcing us to start at #1. Perhaps you can get farther.

when I was doing this same thing, I substituted 3 beers, (instead of 1) so it took me 3 days to do a circle!!

for the ones who want to try this:::

First you x and y values for a circle are based on itinerations.

Than follow AP''s post, or teh Pythagorean theorum, based on what you learned about VB and IB.

CHEERS!

(Too Many beers)

Matt

##### Share on other sites
Where and how do I preform the iterations? I have been putting my vertex coordinates ina custom vertex structure that I created, but how would I create an iteration to do put in the vertex coordinates for me, when this is all stored inside a structure?

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

• 27
• 20
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631700
• Total Posts
3001791
×