regular_prism() sizing bugfixes

This commit is contained in:
Adrian Mariano 2024-09-01 15:08:53 -04:00
parent 6d9d5a8e5a
commit d897c42a3c

View file

@ -1012,20 +1012,21 @@ function regular_prism(n,
tex_depth = default(tex_depth,1),
height = one_defined([l, h, length, height],"l,h,length,height",dflt=1),
sc = 1/cos(180/n),
ir = u_mul(ir,sc),
ir1 = u_mul(first_defined([ir1,ir,r]), sc),
ir2 = u_mul(first_defined([ir2,ir,r]), sc),
id1 = u_mul(first_defined([id1,id,d]), sc),
id2 = u_mul(first_defined([id2,id,d]), sc),
ir1 = u_mul(default(ir1,ir), sc),
ir2 = u_mul(default(ir2,ir), sc),
id1 = u_mul(default(id1,id), sc),
id2 = u_mul(default(id2,id), sc),
od1 = default(od1,od),
od2 = default(od2,od),
or1 = default(or1,or),
or2 = default(or2,or),
d1 = default(d1,d),
d2 = default(d2,d),
side = is_finite(side)? side/2/sin(180/n) : undef,
side1 = is_finite(side1)? side1/2/sin(180/n) : side,
side2 = is_finite(side2)? side2/2/sin(180/n) : side,
r1 = get_radius(r1=ir1,r2=or1,r=r1,d=d1,d1=id1,d2=od1,dflt=side1),
r2 = get_radius(r1=ir2,r2=or2,r=r2,d=d2,d1=id2,d2=od2,dflt=side2),
r1 = get_radius(r1=ir1,r2=or1,r=default(r1,r),d=d1,d1=id1,d2=od1,dflt=side1),
r2 = get_radius(r1=ir2,r2=or2,r=default(r2,r),d=d2,d1=id2,d2=od2,dflt=side2),
anchor = get_anchor(anchor,center,BOT,CENTER)
)
assert(num_defined([side,od,id,or,ir])<=1, "Can only define one of side, id, od, ir, and or")