Alternate way to draw Circle - Lesson 11

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
Radix
Posts: 10
Joined: April 14th, 2013, 3:53 pm

Alternate way to draw Circle - Lesson 11

Post by Radix » April 14th, 2013, 4:17 pm

Hi

I used an alternate method to draw the circle. ;) I think it's simpler. You draw two segments instead of four. It is based on Chili's method. See the attached picture for further explanation.

Code: Select all

	
        float radSqr = rad * rad;
	float temp = 2; 
	float what = rad / sqrt(temp);

                for( int x = -what; x <= what; x++ )
		{
			int y = sqrt( radSqr - x*x ) + 0.5f;
			PutPixel( x0 + x, y0 + y,r,g,bl);
			PutPixel( x0 + x, y0 - y,r,g,bl);
		}
		
                for( int y = -what; y <= what; y++ )
		{
			int x = sqrt( radSqr - y*y ) + 0.5f;
			PutPixel( x0 + x, y0 + y,r,g,bl);
			PutPixel( x0 - x, y0 + y,r,g,bl);
		}
Attachments
Lesson11.png
Lesson11.png (35.5 KiB) Viewed 3351 times

Radix
Posts: 10
Joined: April 14th, 2013, 3:53 pm

Re: Alternate way to draw Circle - Lesson 11

Post by Radix » April 14th, 2013, 4:19 pm

Or maybe not lol

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Alternate way to draw Circle - Lesson 11

Post by LuX » April 14th, 2013, 5:42 pm

Your equations made no sense at all.
If you are referring to Bresenham's Midpoint circle algorithm I think it's exactly the one chili uses. You can't get much faster than that.
ʕ •ᴥ•ʔ

Radix
Posts: 10
Joined: April 14th, 2013, 3:53 pm

Re: Alternate way to draw Circle - Lesson 11

Post by Radix » April 16th, 2013, 9:04 pm

D3DGraphics::DrawCircle(int x0, int y0, int rad, int r, int g, int b)

Radix
Posts: 10
Joined: April 14th, 2013, 3:53 pm

Re: Alternate way to draw Circle - Lesson 11

Post by Radix » April 17th, 2013, 1:43 pm

This method splits the circle with an "X" shape vs. the "+" shape used in the tutorial. It's based on the technique used in Lesson 10. See picture attached.
Attachments
10.PNG
10.PNG (2.15 KiB) Viewed 3272 times

Radix
Posts: 10
Joined: April 14th, 2013, 3:53 pm

Re: Alternate way to draw Circle - Lesson 11

Post by Radix » April 17th, 2013, 3:44 pm

This is meant to share an alternative way I stumbled upon... I am not implying it is better.
--- ----

On a side note these lessons rock!!! If I was a school teacher I would make every kid in my class (and petition the whole school) to take it as a requirement. Even if one doesn't have aspirations for a career in gaming/programming, it's so essential to build the type of thinking used in programming (problem solving with the tools available) and to demistify computers. This lessons are awesome for the very reason that they make learning not only extremely accessible (by assuming no prior knowledge - and being free lol) but also that it makes learning fun (and easy to share with friends).
So yah - a big shout out to Chilli and everyone else who makes this possible.

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Alternate way to draw Circle - Lesson 11

Post by albinopapa » April 17th, 2013, 9:41 pm

Of course you would have to censor Chili.

Fuck censorship poop that corn.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Post Reply