Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 25th, 2005, 6:43 PM   #1
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
The Function Of A Circle.

For part of my Graphical User Interface, I require the ability to draw custom circles. What I need to know is, given an X position of the outside curve of a circle, what equation determines the two Y values?

Please pardon my inexperience in high school math, as I'll need to know the complete equation if possible.

Thankyou in advance.


Edit, I made a circle and these are the co-ordinates for the bottom right curve, where x=0 and y=0 at the bottom most point.

x|y
0|0
1|0 
2|1
3|1 
4|1 
5|2
6|3
7|4
7|5
7|6
8|7
8|8

But I can't exactly find a simple function out of that, at least by my limited methods of solving for quadratics, etc...
Sane is offline   Reply With Quote
Old Jul 25th, 2005, 7:19 PM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
Quote:
Today, 07:13 PM #2
EverLearning
Hobbyist Programmer




Join Date: May 2005
Location: Indiana
Posts: 122
I can't understand quite what is your question, but if you are looking for equation of a circle it's:
x^2 + y^2 = 1
Solving for y will give you +- value, since y = x^2, y >= 0 for all x.
Somehow your data does not reflect that, but I can stake my life on the formula being correct.
____________________
www.physicsforums.com

"All men by nature desire to know" -Aristotle, Metaphysics
Oh, that's probably because my X and Y start on the axis of the bottom of the circle, not the radius. As well as I used a very small circle, so the data will not be completely accurate.

Thanks for the answer.

Edit: Okay, so how do I exclude X? To get the equation where I just input X to solve for Y?
Sane is offline   Reply With Quote
Old Jul 25th, 2005, 7:23 PM   #3
EverLearning
Hobbyist Programmer
 
EverLearning's Avatar
 
Join Date: May 2005
Location: Indiana
Posts: 130
Rep Power: 4 EverLearning is on a distinguished road
If I understand your question, you are looking for equation of a circle, it's:
x^2 + y^2 = r^2 in most common form (0,0) being the center, r -radius.
Solving for y will give you +- value, since f(x) = x^2, f(x) >= 0 for all x.
If the center is shifted from the origin:
(x-a)^2 + (y-b)^2 = r^2
where a and b are (x,y) coordinates of the center of the circle, respectively.

ps: sorry there, firefox acting out on me
__________________
got math? yumm...

"All men by nature desire to know" -Aristotle, Metaphysics
EverLearning is offline   Reply With Quote
Old Jul 25th, 2005, 7:38 PM   #4
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
But I still need an equation where I can just input X and a radius and get a Y? I have no idea how to exclude that equation or use it to my benefits.
Sane is offline   Reply With Quote
Old Jul 25th, 2005, 7:47 PM   #5
EverLearning
Hobbyist Programmer
 
EverLearning's Avatar
 
Join Date: May 2005
Location: Indiana
Posts: 130
Rep Power: 4 EverLearning is on a distinguished road
It's called "solving" for y:

(x-a)^2 + (y-b)^2 = r^2
(y-b)^2 = r^2 - (x-a)^2
y-b = sqrt(r^2 - (x-a)^2)
y = sqrt(r^2 - (x-a)^2) + b

of course, you don't say what is given in the problem so I assume a, b, r are known.
__________________
got math? yumm...

"All men by nature desire to know" -Aristotle, Metaphysics
EverLearning is offline   Reply With Quote
Old Jul 25th, 2005, 8:19 PM   #6
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
I know, I don't know how to solve for stuff. Hehehe.

I'm grade 9, and inexperienced in certain areas of higher level math.

Thanks a lot bud.
Sane is offline   Reply With Quote
Old Jul 25th, 2005, 8:35 PM   #7
EverLearning
Hobbyist Programmer
 
EverLearning's Avatar
 
Join Date: May 2005
Location: Indiana
Posts: 130
Rep Power: 4 EverLearning is on a distinguished road
Welcome.
Yeah, you have not seen higher level math yet
An important fact which is ignored a lot of times is that, from purely mathematical standpoint, equation for the circle is not a function, since (in simple terms) it produces 2 values ( + and - ) of y for single x.
__________________
got math? yumm...

"All men by nature desire to know" -Aristotle, Metaphysics
EverLearning is offline   Reply With Quote
Old Jul 25th, 2005, 8:47 PM   #8
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
Well actually I have seen higher level math. I've been taking Calculus and Grade 13 Probability for the past year. However my education has been purely general, so my coverage is very limited.

With your equation, oddly enough from a set of x values, keeping a, b, and r consistent doesn't change the y value. I'm sure there is nothing wrong with my program. But it's very strange...

I'd show you the program and output, but it's on my laptop.
Sane is offline   Reply With Quote
Old Jul 25th, 2005, 8:59 PM   #9
EverLearning
Hobbyist Programmer
 
EverLearning's Avatar
 
Join Date: May 2005
Location: Indiana
Posts: 130
Rep Power: 4 EverLearning is on a distinguished road
Quote:
Well actually I have seen higher level math. I've been taking Calculus and Grade 13 Probability for the past year. However my education has been purely general, so my coverage is very limited.
*chuckle-chuckle* nevermind *chuckle* solving for unknown variables is 7th grade algebra, but that's besides the point...

Quote:
With your equation, oddly enough from a set of x values, keeping a, b, and r consistent doesn't change the y value. I'm sure there is nothing wrong with my program. But it's very strange...
No it does not make sense, because x is changing, you cannot get the same value unless it's an equation of a horizontal line, which it is not. I don't know the language you are using or whatever, but I know in C <math.h> it does not account for negative values, i.e. it is always single absolute value. In addition it depends on the data types you are using, int truncates decimals and if you take x(i) very close to each other, y will not appear to change.

Quote:
I'd show you the program and output, but it's on my laptop.
copy-paste maybe? or at least input-output? if you are interested enough, that is. And perhaps describe precisely what is given, seemingly unrelated information may happen to be useful.
__________________
got math? yumm...

"All men by nature desire to know" -Aristotle, Metaphysics
EverLearning is offline   Reply With Quote
Old Jul 25th, 2005, 9:14 PM   #10
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
I didn't think solving that kind of equation was grade 7. I guess I assumed it would be the same kind of solving of ax^2 + bx + c = 0, to, x = -b+-((b^2-4ac)^0.5/2a). Because I know for a fact that isn't grade 7. Well I just need to prove to myself that my first impression on the equation was false:

(x-a)^2 + (y-b)^2 = r^2
(x-a)(x-a) + (y-b)(y-b) = r^2
x^2 + (x)(-a) + (-a)(x) + a^2 + y^2 + (y)(-b) + (-b)(y) + b^2 = r^2
x^2 + y^2 + a^2 + b^2 + (x)(-a)^2 + (y)(-b)^2 = r^2
...err

I don't know what kind of freaky math they taught you in grade 7, but damn it must be working...! o_o We won't learn this until grade 11.

Anyways. Yes, even when I change X, it doesn't consider it in the equation for some reason. I just get like 3.003450100000^e032 or something. I'm using Python.

And how am I supposed to copy paste it if I did it on my wireless laptop? .....................
Sane is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:26 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC