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

19
LINES

< > BotCompany Repo | #1006795 // oneStepPt

JavaX fragment (include)

static int[] oneStepPt_l = {
  0, 1,
  1, 1,
  1, 0,
  1, -1,
  0, -1,
  -1, -1,
  -1, 0,
  -1, 1,
};

static Pt oneStepPt(Pt p, int baseX, int baseY) {
  ret oneStepPt(new Pt(p.x-baseX, p.y-baseY));
}

static Pt oneStepPt(Pt p) {
  int i = mod(iround(Math.atan2(p.x, p.y)*8/2/pi()), 8);
  ret new Pt(oneStepPt_l[i*2], oneStepPt_l[i*2+1]);
}

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: 370 / 419
Version history: 3 change(s)
Referenced in: [show references]