T
toyko
So yeah, I have this assignment for my computer science class,
http://pages.cpsc.ucalgary.ca/~boyd/231/as1.pdf so far this is what I have
wrote, any suggestions cause I am stuck!
xc, yc = input()
r = input()
x1, y1 = input()
x2, y2 = input()
a = (x2 - x1)**2 + (y2 - y1)**2
b = 2((x1 - xc)(x2 - x1) + (y1 - yc)(y2 - y1))
c = (x1 - xc)**2 + (y1 - yc)**2 - r**2
discrim = (b * b - 4 * a * c) ** 0.5
Q = (-b + discrim) / (2 * a)
Q = (-b - discrim) / (2 * a)
x = (1-Q) * x1 + Qx2
y = (1-Q) * y1 + Qx2
# CIRCLE
print "circle", xc, yc, r
# LINE
print "line", x1, y1, x2, y2
http://pages.cpsc.ucalgary.ca/~boyd/231/as1.pdf so far this is what I have
wrote, any suggestions cause I am stuck!
xc, yc = input()
r = input()
x1, y1 = input()
x2, y2 = input()
a = (x2 - x1)**2 + (y2 - y1)**2
b = 2((x1 - xc)(x2 - x1) + (y1 - yc)(y2 - y1))
c = (x1 - xc)**2 + (y1 - yc)**2 - r**2
discrim = (b * b - 4 * a * c) ** 0.5
Q = (-b + discrim) / (2 * a)
Q = (-b - discrim) / (2 * a)
x = (1-Q) * x1 + Qx2
y = (1-Q) * y1 + Qx2
# CIRCLE
print "circle", xc, yc, r
# LINE
print "line", x1, y1, x2, y2