python geometry help

Posted by Enriquev on Stack Overflow See other posts from Stack Overflow or by Enriquev
Published on 2010-06-16T15:38:19Z Indexed on 2010/06/16 15:42 UTC
Read the original article Hit count: 239

Filed under:
|

Hello,

I have the following problem, I am trying to find the following distances (F1 and F2): circle

This is what I have as of now:

def FindArrow(self, X1, Y1, X2, Y2, X3, Y3):
    self.X1 = float(X1)
    self.Y1 = float(Y1)
    self.X2 = float(X2)
    self.Y2 = float(Y2)
    self.X3 = float(X3)
    self.Y3 = float(Y3)
    #center coords of the circle
    self.Xc = None
    self.Yc = None
    #radius
    self.R = None

    #F1 and F2
    self.FAB = None
    self.FBC = None

    #check if the coordinates are collinear
    invalide = self.X1 * (self.Y2 - self.Y3) + self.X2 * (self.Y3 - self.Y1) + self.X3 * (self.Y1 - self.Y2)
    if (invalide == 0):
        return

    #get the coords of the circle's center
    s = (0.5 * ((self.X2 - self.X3)*(self.X1 - self.X3) - (self.Y2 - self.Y3) * (self.Y3 - self.Y1))) / invalide

    self.Xc = 0.5 * (self.X1 + self.X2) + s * (self.Y2 - self.Y1)
    self.Yc = 0.5 * (self.Y1 + self.Y2) + s * (self.X1 - self.X2)

    #get the radius
    self.R = math.sqrt(math.pow(self.Xc - self.X1, 2) + math.pow(self.Yc - self.Y1, 2))

Until here everything seems to work, now what would be the next steps to get F1 and F2 ?

© Stack Overflow or respective owner

Related posts about math

Related posts about geometry