![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
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... |
|
|
|
|
|
#2 | |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
Quote:
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? |
|
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: May 2005
Location: Indiana
Posts: 130
Rep Power: 4
![]() |
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 |
|
|
|
|
|
#4 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
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.
![]() |
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: May 2005
Location: Indiana
Posts: 130
Rep Power: 4
![]() |
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. |
|
|
|
|
|
#6 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
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. ![]() |
|
|
|
|
|
#7 |
|
Hobbyist Programmer
Join Date: May 2005
Location: Indiana
Posts: 130
Rep Power: 4
![]() |
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. |
|
|
|
|
|
#8 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
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. |
|
|
|
|
|
#9 | |||
|
Hobbyist Programmer
Join Date: May 2005
Location: Indiana
Posts: 130
Rep Power: 4
![]() |
Quote:
Quote:
Quote:
|
|||
|
|
|
|
|
#10 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,799
Rep Power: 5
![]() |
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? ..................... |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|