mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2004
Posts: 7
K
km_ Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
K
Joined: Mar 2004
Posts: 7
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)

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
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.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Mar 2004
Posts: 7
K
km_ Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
K
Joined: Mar 2004
Posts: 7
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.



Joined: Feb 2003
Posts: 2,803
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,803
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


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Dec 2002
Posts: 329
Fjord artisan
Offline
Fjord artisan
Joined: Dec 2002
Posts: 329
Nice bug reports! This has been fixed in mIRC 6.15
39.Fixed $onpoly() not handling intersecting polygons of zero volume.


Link Copied to Clipboard