0 Members and 2 Guests are viewing this topic.
eqn 3, simplified. Probably not, but well...I dont even want to go back through my work to check for errors.
I converted the whole damn thing before I realized there is a problem. The 3rd equation is the one I need simplified, but I typed it wrong.Correct equation to simplify.( sqrt( (Rx-x)^2 + (Ry-(m(x - Tx) + Ty))^2 ) / sqrt( (Tx-x)^2 + (Ty-(m(x - Tx) + Ty))^2 ) ) = oI appreciate your help thus far.Quote from: Smegma on October 18, 2009, 12:55:36 ameqn 3, simplified. Probably not, but well...I dont even want to go back through my work to check for errors.My god. I am probably gonna need to break it down to several smaller equations. Perhaps there is a better way?
In [36]: run forumla-test.pymath.sqrt( (-76.0/-2.0) + (-8.0**2)/(2*(-2.0**2)) ) - -8.0/(2*-2.0)(4.78232998313, -2.78232998313)Fail!
import mathclass point(): x = 0.0 y = 0.0 def __init__(self, ex, why): self.x = ex self.y = whyglobal R, T, m, oR = point(1.0, 5.0)T = point(1.0, 1.0)m = -1.0/1.0o = 1.0def main(): ex = testFormula(R, T, o, m) why = lineFormula(ex, T, m) print('(%s, %s)' % (ex, why)) if ex != 3.0 and why != 3.0: print('Fail!')def testFormula(arrr, tee, ooo, mmm): def fa(): return (mmm**2) - 1 - (ooo**2)*(1+(mmm**2)) def fb(): return arrr.x + mmm*arrr.y - (mmm**2)*tee.x + mmm*tee.y + (ooo**2)*tee.x + (ooo**2)*mmm*tee.y - (mmm**2)*tee.x*(ooo**2) + mmm*tee.y*(ooo**2) ## image version #return arrr.x + mmm*arrr.y + (mmm**2)*tee.x + mmm*tee.y + (ooo**2)*tee.x + (ooo**2)*mmm*tee.y + (mmm**2)*tee.x*(ooo**2) + mmm*tee.y*(ooo**2) def fc(): return ((ooo**2) * ((tee.x**2) + (tee.y**2) - 2.0*(mmm**2)*(tee.y**2) + 2.0*(tee.y**2) + (mmm**2)*(tee.x**2) - 2.0*mmm*(tee.y**2) + (tee.y**2))) - ( (arrr.y**2) - 2.0*mmm*tee.y*arrr.y + 2.0*arrr.y*tee.y + 2.0*arrr.y*tee.y - 2.0*mmm*tee.x*tee.y - (tee.y**2) + (arrr.y**2) + (mmm**2)*(tee.x**2)) ## image version #return ((ooo**2) * ((tee.x**2) + (tee.y**2) + 2.0*(mmm**2)*(tee.y**2) + 2.0*(tee.y**2) + (mmm**2)*(tee.x**2) + 2.0*mmm*(tee.y**2) + (tee.y**2))) - ( (arrr.y**2) + 2.0*mmm*tee.y*arrr.y + 2.0*arrr.y*tee.y + 2.0*arrr.y*tee.y + 2.0*mmm*tee.x*tee.y + (tee.y**2) + (arrr.y**2) + (mmm**2)*(tee.x**2)) print('math.sqrt( (%(fc)s/%(fa)s) + (%(fb)s**2)/(2*(%(fa)s**2)) ) - %(fb)s/(2*%(fa)s)' % {'fa': fa(), 'fb': fb(), 'fc': fc()}) return math.sqrt( (fc()/fa()) + (fb()**2)/(2*(fa()**2)) ) - fb()/(2*fa())def lineFormula(ex, tee, mmm): return mmm * (ex - tee.x) + tee.yif __name__ == "__main__": main()