~kivy-team/kivy/master

« back to all changes in this revision

Viewing changes to kivy/vector.py

  • Committer: GitHub
  • Author(s): dessant
  • Date: 2016-12-14 17:50:19 UTC
  • mfrom: (3773.4.12)
  • Revision ID: git-v1:cc9c5f91b3adf70be9b92c2013ed330e9aec4d63
Merge pull request #4795 from kivy/pep8_fixes

[WIP] Pep8 fixes of the current master

Show diffs side-by-side

added added

removed removed

Lines of Context:
334
334
 
335
335
        For math see: http://en.wikipedia.org/wiki/Line-line_intersection
336
336
        '''
337
 
        #linear algebar sucks...seriously!!
 
337
        # linear algebar sucks...seriously!!
338
338
        x1, x2, x3, x4 = float(v1[0]), float(v2[0]), float(v3[0]), float(v4[0])
339
339
        y1, y2, y3, y4 = float(v1[1]), float(v2[1]), float(v3[1]), float(v4[1])
340
340
 
369
369
        >>> Vector.segment_intersection(a, b, c, d)
370
370
        [5, 5]
371
371
        '''
372
 
        #Yaaay! I love linear algebra applied within the realms of geometry.
 
372
        # Yaaay! I love linear algebra applied within the realms of geometry.
373
373
        x1, x2, x3, x4 = float(v1[0]), float(v2[0]), float(v3[0]), float(v4[0])
374
374
        y1, y2, y3, y4 = float(v1[1]), float(v2[1]), float(v3[1]), float(v4[1])
375
 
        #This is mostly the same as the line_intersection
 
375
        # This is mostly the same as the line_intersection
376
376
        u = (x1 * y2 - y1 * x2)
377
377
        v = (x3 * y4 - y3 * x4)
378
378
        denom = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)
381
381
 
382
382
        px = (u * (x3 - x4) - (x1 - x2) * v) / denom
383
383
        py = (u * (y3 - y4) - (y1 - y2) * v) / denom
384
 
        #Here are the new bits
 
384
        # Here are the new bits
385
385
        c1 = (x1 <= px <= x2) or (x2 <= px <= x1)
386
386
        c2 = (y1 <= py <= y2) or (y2 <= py <= y1)
387
387
        c3 = (x3 <= px <= x4) or (x4 <= px <= x3)