mIRC Homepage
Posted By: km_ $onpoly can't deal with lines ? - 26/03/04 11:14 PM
Why does:
//echo -a $onpoly( 2 , 2 , 100 ,100 ,200 , 100 , 150 , 50 , 150 , 150 )
return $false ?

A line is also a polygon. And the 2 lines are crossing each other.

Is this a Bug or did i do anything wrong?

If the $onploly can't check if 2 lines are crossing how can i check this then (in one line without a while loop or long calculations)
Posted By: qwerty Re: $onpoly can't deal with lines ? - 27/03/04 06:35 AM
I tried various combinations and apparently $onpoly refuses to view lines as polygons (not sure if it's right or not). I don't know if the following alias is short/fast enough for you, but it does the job:
Code:
cross {
  tokenize 32 $1-
  var %a1 = $calc(($4 - $2) / ($3 - $1)), %a2 = $calc(($8 - $6) / ($7 - $5))
  if %a1 && %a1 == %a2 { return $false }
  var %b1 = $calc($2 - %a1 * $1), %b2 = $calc($6 - %a2 * $5), %x = $calc((%b2 - %b1) / (%a1 - %a2))
  if $2 == $4 || $6 == $8 || (%x isnum $sorttok($+($1,-,$3),45,n) && $&
    %x isnum $sorttok($+($5,-,$7),45,n)) && $calc(%a1 * %x + %b1) isnum $sorttok($+($2,-,$4),45,n) $& 
    && $ifmatch isnum $sorttok($+($6,-,$8),45,n) { return $true }
  return $false
}
Example usage: $cross(x1 y1 x2 y2,X1 Y1 X2 Y2)
x1,y1,x2,y2 are for the first line (exactly as used in /drawline), their uppercase counterparts are for the second line.
Posted By: km_ Re: $onpoly can't deal with lines ? - 27/03/04 08:59 AM
Wow thanks for the alias!
I'll check it out (but i think it will be fast enough)

I mainly asked because a Line is a special case of a Polynom and when they cross then there is only one point part of both lines.

So i thought this is some kind of Bug maybe.


Posted By: Raccoon Re: $onpoly can't deal with lines ? - 28/03/04 03:07 AM
Just wanted to confirm this bug.
It appears to fail on any polygon that has zero area, even with 3 or more points.



Figure A is an example of two crossing 2-point line segments.
Figure B is an example of two crossing 3-point polygons with zero area.
Figure C is an example of two crossing 4-point polygons with area.

- Raccoon
Posted By: Krejt Re: $onpoly can't deal with lines ? - 04/06/04 08:09 AM
Nice bug reports! This has been fixed in mIRC 6.15
39.Fixed $onpoly() not handling intersecting polygons of zero volume.
© mIRC Discussion Forums