mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-17 06:03:59 +02:00
Merge branch 'BelfrySCAD:master' into anachronist_isosurface
This commit is contained in:
@@ -53,7 +53,7 @@ module cubetruss(extents=6, clips=[], bracing, size, strut, clipthick, anchor=CE
|
||||
w = extents[0];
|
||||
l = extents[1];
|
||||
h = extents[2];
|
||||
s = [cubetruss_dist(w,1), cubetruss_dist(l,1), cubetruss_dist(h,1)];
|
||||
s = [cubetruss_dist(w,1,size,strut), cubetruss_dist(l,1,size,strut), cubetruss_dist(h,1,size,strut)];
|
||||
attachable(anchor,spin,orient, size=s) {
|
||||
union() {
|
||||
for (zrow = [0:h-1]) {
|
||||
@@ -122,8 +122,8 @@ module cubetruss_corner(h=1, extents=[1,1,0,0,1], bracing, size, strut, clipthic
|
||||
clipthick = is_undef(clipthick)? $cubetruss_clip_thickness : clipthick;
|
||||
exts = is_vector(extents)? list_pad(extents,5,fill=0) : [extents, extents, 0, 0, extents];
|
||||
dummy = assert(len(exts)==5, "Input extents must be a scalar or vector with length 5 or less.");
|
||||
s = [cubetruss_dist(exts[0]+1+exts[2],1), cubetruss_dist(exts[1]+1+exts[3],1), cubetruss_dist(h+exts[4],1)];
|
||||
offset = [cubetruss_dist(exts[0]-exts[2],0), cubetruss_dist(exts[1]-exts[3],0), cubetruss_dist(h+exts[4]-1,0)]/2;
|
||||
s = [cubetruss_dist(exts[0]+1+exts[2],1,size,strut), cubetruss_dist(exts[1]+1+exts[3],1,size,strut), cubetruss_dist(h+exts[4],1,size,strut)];
|
||||
offset = [cubetruss_dist(exts[0]-exts[2],0,size,strut), cubetruss_dist(exts[1]-exts[3],0,size,strut), cubetruss_dist(h+exts[4]-1,0,size,strut)]/2;
|
||||
attachable(anchor,spin,orient, size=s, offset=offset) {
|
||||
union() {
|
||||
for (zcol = [0:h-1]) {
|
||||
@@ -341,7 +341,7 @@ module cubetruss_joiner(w=1, vert=true, size, strut, clipthick, anchor=CENTER, s
|
||||
strut = is_undef(strut)? $cubetruss_strut_size : strut;
|
||||
clipthick = is_undef(clipthick)? $cubetruss_clip_thickness : clipthick;
|
||||
clipsize = 0.5;
|
||||
s = [cubetruss_dist(w,1)+2*clipthick, cubetruss_dist(2,0)-0.1, strut+clipthick];
|
||||
s = [cubetruss_dist(w,1,size,strut)+2*clipthick, cubetruss_dist(2,0,size,strut)-0.1, strut+clipthick];
|
||||
attachable(anchor,spin,orient, size=s, offset=[0,0,-(clipthick-strut)/2]) {
|
||||
down(clipthick) {
|
||||
// Base
|
||||
|
27
math.scad
27
math.scad
@@ -576,7 +576,7 @@ function constrain(v, minval, maxval) =
|
||||
// Usage:
|
||||
// mod = posmod(x, m)
|
||||
// Description:
|
||||
// Returns the positive modulo `m` of `x`. Value returned will be in the range 0 ... `m`-1.
|
||||
// Returns the positive modulo `m` of `x`. Value returned will be satisfy `0 <= mod < m`.
|
||||
// Arguments:
|
||||
// x = The value to constrain.
|
||||
// m = Modulo value.
|
||||
@@ -613,6 +613,31 @@ function modang(x) =
|
||||
let(xx = posmod(x,360)) xx<180? xx : xx-360;
|
||||
|
||||
|
||||
// Function: mean_angle()
|
||||
// Synopsis: Returns the mean angle of two angles
|
||||
// Topics: Math
|
||||
// See Also: modang()
|
||||
// Usage:
|
||||
// half_ang = mean_angle(angle1,angle2);
|
||||
// Description:
|
||||
// Takes two angles (degrees) in any range and finds the angle halfway between
|
||||
// the given angles, where halfway is interpreted using the shorter direction.
|
||||
// In the case where the angles are exactly 180 degrees apart,
|
||||
// it will return `angle1+90`. The returned angle is always in the interval [0,360).
|
||||
// Arguments:
|
||||
// angle1 = first angle
|
||||
// angle2 = second angle
|
||||
function mean_angle(angle1,angle2) =
|
||||
assert(is_vector([angle1,angle2]), "Inputs must be finite numbers.")
|
||||
let(
|
||||
ang1 = posmod(angle1,360),
|
||||
ang2 = posmod(angle2,360)
|
||||
)
|
||||
approx(abs(ang1-ang2),180) ? posmod(angle1+90,360)
|
||||
: abs(ang1-ang2)<=180 ? (ang1+ang2)/2
|
||||
: posmod((ang1+ang2-360)/2,360);
|
||||
|
||||
|
||||
|
||||
// Section: Operations on Lists (Sums, Mean, Products)
|
||||
|
||||
|
Reference in New Issue
Block a user