Ooops
October 17, 2021, 11:34:23

Author Topic: [bb] InsidePoly by skidracer [ 1+ years ago ]  (Read 577 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] InsidePoly by skidracer [ 1+ years ago ]
« on: June 29, 2017, 00:28:42 »
Title : InsidePoly
Author : skidracer
Posted : 1+ years ago

Description : check if a point is inside a polygon

Code :
Code: BlitzBasic
  1. Function dot(x0,y0,x1,y1,x2,y2)
  2.         Return (x1-x0)*(y2-y1)-(x2-x1)*(y1-y0)
  3. End Function
  4.  
  5. Function InsideQuad(px,py,x0,y0,x1,y1,x2,y2,x3,y3)
  6.         If dot(x0,y0,x1,y1,px,py)>0
  7.                 If dot(x1,y1,x2,y2,px,py)>0
  8.                         If dot(x2,y2,x3,y3,px,py)>0
  9.                                 If dot(x3,y3,x0,y0,px,py)>0
  10.                                         Return True
  11.                                 EndIf
  12.                         EndIf
  13.                 EndIf
  14.         EndIf
  15. End Function
  16.  


Comments :


Psilo(Posted 1+ years ago)

 Thanks for that :)


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal