Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

19
LINES

< > BotCompany Repo | #1006795 // oneStepPt

JavaX fragment (include)

1  
static int[] oneStepPt_l = {
2  
  0, 1,
3  
  1, 1,
4  
  1, 0,
5  
  1, -1,
6  
  0, -1,
7  
  -1, -1,
8  
  -1, 0,
9  
  -1, 1,
10  
};
11  
12  
static Pt oneStepPt(Pt p, int baseX, int baseY) {
13  
  ret oneStepPt(new Pt(p.x-baseX, p.y-baseY));
14  
}
15  
16  
static Pt oneStepPt(Pt p) {
17  
  int i = mod(iround(Math.atan2(p.x, p.y)*8/2/pi()), 8);
18  
  ret new Pt(oneStepPt_l[i*2], oneStepPt_l[i*2+1]);
19  
}

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: #1006795
Snippet name: oneStepPt
Eternal ID of this version: #1006795/4
Text MD5: 6ef34475cb3c255e0f85bd78a23d351f
Author: stefan
Category: javax / maths
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-02-04 05:37:52
Source code size: 359 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 375 / 423
Version history: 3 change(s)
Referenced in: [show references]