Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
June 8th, 2013, 06:59 PM
 kostik1992X
Registered User

Join Date: May 2013
Posts: 5
Time spent in forums: 2 h 4 m 37 sec
Reputation Power: 0
Calculating x with equation ...problem

y = random.randrange(100,300)
#(x-200)**2 + (x-200)**2 = 1000...this is common circle equation
# so in my code i want to put x on one side of equation and all except x to other side
#if a do a little math...x**2 -400x + 40000= 1000-(y-200)**2
#x**2= 1000-(y-200)**2 + 400x - 40000

#there is problem...x just cant stand alone...whatever i would make, x can not be alone....theres always second x which calls for error when i start program because that second x isnt yet defined
#THANKS FOR ANY ADVICE HOW TO CALCULATE X IN THIS EQUATION SO PYTHON WOULDNT CALL FOR ERROR

#2
June 8th, 2013, 09:12 PM
 b49P23TIvg
Contributing User

Join Date: Aug 2011
Posts: 4,150
Time spent in forums: 1 Month 3 Weeks 2 Days 8 h 10 m 11 sec
Reputation Power: 455
Code:
```(x-x0)**2 + (y-y0)**2 == r**2      # equation of circle

(x-x0)**2  == r**2 - (y-y0)**2     # subtract (y-y0)**2 from each side

(x-x0)  == +sqrt(r**2 - (y-y0)**2)    # taking the square root of each side

(x-x0)  == -sqrt(r**2 - (y-y0)**2)    # gives two solutions at each value of y

# next add x0 to each side

# Therefor, given r and y, x0 and y0,

x  == x0+sqrt(r**2 - (y-y0)**2)
x  == x0-sqrt(r**2 - (y-y0)**2)```
__________________
[code]Code tags[/code] are essential for python code!

 Viewing: Dev Shed Forums > Programming Languages > Python Programming > Calculating x with equation ...problem