1 | static double rectDistance(Rect r1, Rect r2) { |
2 | double x1, x2, y1, y2; |
3 | double w, h; |
4 | if (r1.x > r2.x) { |
5 | x1 = r2.x; w = r2.w; x2 = r1.x; |
6 | } else { |
7 | x1 = r1.x; w = r1.w; x2 = r2.x; |
8 | } |
9 | if (r1.y > r2.y) { |
10 | y1 = r2.y; h = r2.h; y2 = r1.y; |
11 | } else { |
12 | y1 = r1.y; h = r1.h; y2 = r2.y; |
13 | } |
14 | double a = Math.max(0, x2 - x1 - w); |
15 | double b = Math.max(0, y2 - y1 - h); |
16 | return Math.sqrt(a*a+b*b); |
17 | } |
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: | 384 / 410 |
Version history: | 2 change(s) |
Referenced in: | [show references] |