Experimental functionality
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
This commit is contained in:
parent
34fb5c964c
commit
549011c078
2 changed files with 101 additions and 0 deletions
53
unwrap.scad
Normal file
53
unwrap.scad
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
use <./vector.scad>
|
||||
|
||||
function _unwrap_x_half(original,unwrapped=[],offset=0)=
|
||||
let(length=len(original))
|
||||
let(half=(length-2)/2+1)
|
||||
let(i=len(unwrapped))
|
||||
let(prev=original[i-1])
|
||||
let(cur=original[i])
|
||||
let(dx=cur[0]-prev[0])
|
||||
let(dz=cur[2]-prev[2])
|
||||
let(new=[offset+sqrt(pow(dx,2)+pow(dz,2)),cur[1],0])
|
||||
|
||||
i < half ? _unwrap_x_half(original,concat(unwrapped,[new]),new[0]) : concat(unwrapped,[new]) ;
|
||||
|
||||
;
|
||||
|
||||
function _unwrap_x(p)=
|
||||
let(length=len(p))
|
||||
let(half=(length-2)/2+1)
|
||||
let(first=_unwrap_x_half(p,[[p[0][0],p[0][1],0]],p[0][0]))
|
||||
let(second=[
|
||||
for( i = [len(first):length-1])
|
||||
[p[length-i][0],p[i][1],0]
|
||||
])
|
||||
flatten_vec([first,second])
|
||||
;
|
||||
|
||||
|
||||
function _unwrap_y_half(original,unwrapped,offset,s)=
|
||||
let(length=len(original))
|
||||
let(half=(length-2)/2+1)
|
||||
let(i=len(unwrapped))
|
||||
let(prev=original[i-1])
|
||||
let(cur=original[i])
|
||||
let(dx=cur[0]-prev[0])
|
||||
let(dy=cur[1]-prev[1])
|
||||
let(dz=cur[2]-prev[2])
|
||||
let(new=[cur[0],offset+s*sqrt(pow(dy,2)+pow(dz,2)),0])
|
||||
|
||||
i < half ? _unwrap_y_half(original,concat(unwrapped,[new]),new[1],s) : concat(unwrapped,[new]) ;
|
||||
|
||||
;
|
||||
|
||||
function _unwrap_y(p,s=1)=
|
||||
let(length=len(p))
|
||||
let(half=(length-2)/2+1)
|
||||
let(first=_unwrap_y_half(p,[[p[0][0],p[0][1],0]],p[0][1],s))
|
||||
let(second=[
|
||||
for( i = [len(first):length-1])
|
||||
[p[i][0],first[length-i][1],0]
|
||||
])
|
||||
flatten_vec([first,second])
|
||||
;
|
||||
Loading…
Add table
Add a link
Reference in a new issue