Drawing a circle with vertices?

Started by
14 comments, last by Sardius2 20 years, 8 months ago
How can I use vertices and DrawPrimitive to create a circle?
Alan
Advertisement
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.
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
better yet:

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

use values between 0 and 2pi. More values = more circular circle.
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]
Alan
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.
[sub]My spoon is too big.[/sub]
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?
Alan
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.
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.
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

TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
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?
Alan

This topic is closed to new replies.

Advertisement