All pastes #915340 Raw Edit

Anonymous

public python v1 · immutable
#915340 ·published 2008-02-23 18:50 UTC
rendered paste body
            dx = self.v[0] - r[0]            dy = self.v[1] - r[1]            da = self.cshape.end[0] - self.cshape.start[0]            db = self.cshape.end[1] - self.cshape.start[1]            if (da * dy) - (db * dx) != 0:                s = (dx * (self.cshape.start[1] - (self.pos[1] - r[1])) + dy * (self.pos[0] - r[0]) - self.cshape.start[0]) / (da * dy - db * dx)                t = (da * ((self.pos[1] - r[1]) - self.cshape.start[1]) + dy * (self.cshape.start[0] - (self.pos[0] - r[0]))) / (db * dx - da * dy)                if (s >= 0 and s <= 1 and t >= 0 and t <= 1):