Fixed edge case orient_and_align() with 0 height.

This commit is contained in:
Revar Desmera 2019-06-23 17:42:57 -07:00
parent 10f7d5118f
commit 6180771cf1
2 changed files with 7 additions and 1 deletions

View file

@ -153,7 +153,9 @@ function find_anchor(anchor, h, size, size2=undef, shift=[0,0], anchors=[], geom
botpt = point3d(vmul(size/2,xyal))+DOWN*h/2,
toppt = point3d(vmul(size2/2,xyal)+shift)+UP*h/2,
pos = lerp(botpt, toppt, (anchor.z+1)/2),
sidevec = two_d? point3d(xyal) : rotate_points3d([point3d(xyal)], from=UP, to=toppt-botpt)[0],
sidevec = two_d? point3d(xyal) :
approx(norm(xyal),0)? [0,0,0] :
rotate_points3d([point3d(xyal)], from=UP, to=toppt-botpt)[0],
vec = (
two_d? sidevec :
anchor==CENTER? UP :

View file

@ -135,6 +135,8 @@ function rotate_points3d(pts, a=0, v=undef, cp=[0,0,0], from=undef, to=undef, re
let (
mrot = reverse? (
!is_undef(from)? (
assert(norm(from)>0, "The from argument cannot equal [0,0] or [0,0,0]")
assert(norm(to)>0, "The to argument cannot equal [0,0] or [0,0,0]")
let (
ang = vector_angle(from, to),
v = vector_axis(from, to)
@ -149,6 +151,8 @@ function rotate_points3d(pts, a=0, v=undef, cp=[0,0,0], from=undef, to=undef, re
)
) : (
!is_undef(from)? (
assert(norm(from)>0, "The from argument cannot equal [0,0] or [0,0,0]")
assert(norm(to)>0, "The to argument cannot equal [0,0] or [0,0,0]")
let (
from = from / norm(from),
to = to / norm(from),