static double rectDistance(Rect r1, Rect r2) { double x1, x2, y1, y2; double w, h; if (r1.x > r2.x) { x1 = r2.x; w = r2.w; x2 = r1.x; } else { x1 = r1.x; w = r1.w; x2 = r2.x; } if (r1.y > r2.y) { y1 = r2.y; h = r2.h; y2 = r1.y; } else { y1 = r1.y; h = r1.h; y2 = r2.y; } double a = Math.max(0, x2 - x1 - w); double b = Math.max(0, y2 - y1 - h); return Math.sqrt(a*a+b*b); }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1016040 |
Snippet name: | rectDistance - distance of closest corners |
Eternal ID of this version: | #1016040/3 |
Text MD5: | d5ea7ec1ade88566d44906b876ce0ec3 |
Author: | stefan |
Category: | javax / maths |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-02-26 15:04:41 |
Source code size: | 431 bytes / 17 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 382 / 407 |
Version history: | 2 change(s) |
Referenced in: | [show references] |