mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
fix typo, add $slop support to robertson recess
This commit is contained in:
parent
03e4491e72
commit
774b5c6b54
2 changed files with 16 additions and 7 deletions
16
linalg.scad
16
linalg.scad
|
@ -416,14 +416,19 @@ function block_matrix(M) =
|
||||||
|
|
||||||
// Function: linear_solve()
|
// Function: linear_solve()
|
||||||
// Usage:
|
// Usage:
|
||||||
// solv = linear_solve(A,b)
|
// solv = linear_solve(A,b,[pivot])
|
||||||
// Description:
|
// Description:
|
||||||
// Solves the linear system Ax=b. If `A` is square and non-singular the unique solution is returned. If `A` is overdetermined
|
// Solves the linear system Ax=b. If `A` is square and non-singular the unique solution is returned. If `A` is overdetermined
|
||||||
// the least squares solution is returned. If `A` is underdetermined, the minimal norm solution is returned.
|
// the least squares solution is returned. If `A` is underdetermined, the minimal norm solution is returned.
|
||||||
// If `A` is rank deficient or singular then linear_solve returns `[]`. If `b` is a matrix that is compatible with `A`
|
// If `A` is rank deficient or singular then linear_solve returns `[]`. If `b` is a matrix that is compatible with `A`
|
||||||
// then the problem is solved for the matrix valued right hand side and a matrix is returned. Note that if you
|
// then the problem is solved for the matrix valued right hand side and a matrix is returned. Note that if you
|
||||||
// want to solve Ax=b1 and Ax=b2 that you need to form the matrix `transpose([b1,b2])` for the right hand side and then
|
// want to solve Ax=b1 and Ax=b2 that you need to form the matrix `transpose([b1,b2])` for the right hand side and then
|
||||||
// transpose the returned value.
|
// transpose the returned value. The solution is computed using QR factorization. If `pivot` is set to true (the default) then
|
||||||
|
// pivoting is used in the QR factorization, which is slower but expected to be more accurate.
|
||||||
|
// Usage:
|
||||||
|
// A = Matrix describing the linear system, which need not be square
|
||||||
|
// b = right hand side for linear system, which can be a matrix to solve several cases simultaneously. Must be consistent with A.
|
||||||
|
// pivot = if true use pivoting when computing the QR factorization. Default: true
|
||||||
function linear_solve(A,b,pivot=true) =
|
function linear_solve(A,b,pivot=true) =
|
||||||
assert(is_matrix(A), "Input should be a matrix.")
|
assert(is_matrix(A), "Input should be a matrix.")
|
||||||
let(
|
let(
|
||||||
|
@ -448,11 +453,14 @@ function linear_solve(A,b,pivot=true) =
|
||||||
// Function: linear_solve3()
|
// Function: linear_solve3()
|
||||||
// Usage:
|
// Usage:
|
||||||
// x = linear_solve3(A,b)
|
// x = linear_solve3(A,b)
|
||||||
// Desription:
|
// Description:
|
||||||
// Fast solution to a 3x3 linear system using Cramer's rule (which appears to be the fastest
|
// Fast solution to a 3x3 linear system using Cramer's rule (which appears to be the fastest
|
||||||
// method in OpenSCAD). The input `A` must be a 3x3 matrix. Returns undef if `A` is singular.
|
// method in OpenSCAD). The input `A` must be a 3x3 matrix. Returns undef if `A` is singular.
|
||||||
// The input `b` must be a 3-vector. Note that Cramer's rule is not a stable algorithm, so for
|
// The input `b` must be a 3-vector. Note that Cramer's rule is not a stable algorithm, so for
|
||||||
// the highest accuracy on ill-conditioned problems you may want to use the general solver, which is about ten times slower.
|
// the highest accuracy on ill-conditioned problems you may want to use the general solver, which is about ten times slower.
|
||||||
|
// Arguments:
|
||||||
|
// A = 3x3 matrix for linear system
|
||||||
|
// b = length 3 vector, right hand side of linear system
|
||||||
function linear_solve3(A,b) =
|
function linear_solve3(A,b) =
|
||||||
// Arg sanity checking adds 7% overhead
|
// Arg sanity checking adds 7% overhead
|
||||||
assert(b*0==[0,0,0], "Input b must be a 3-vector")
|
assert(b*0==[0,0,0], "Input b must be a 3-vector")
|
||||||
|
|
|
@ -353,12 +353,13 @@ module robertson_mask(size, extra=1) {
|
||||||
F = (Fmin + Fmax) / 2 * INCH;
|
F = (Fmin + Fmax) / 2 * INCH;
|
||||||
ang = 4;
|
ang = 4;
|
||||||
h = T + extra;
|
h = T + extra;
|
||||||
|
Mslop=M+2*$slop;
|
||||||
down(T) {
|
down(T) {
|
||||||
intersection(){
|
intersection(){
|
||||||
Mtop = M + 2*adj_ang_to_opp(F+extra,ang);
|
Mtop = Mslop + 2*adj_ang_to_opp(F+extra,ang);
|
||||||
Mbot = M - 2*adj_ang_to_opp(T-F,ang);
|
Mbot = Mslop - 2*adj_ang_to_opp(T-F,ang);
|
||||||
prismoid([Mbot,Mbot],[Mtop,Mtop],h=h,anchor=BOT);
|
prismoid([Mbot,Mbot],[Mtop,Mtop],h=h,anchor=BOT);
|
||||||
cyl(d1=0, d2=M/(T-F)*sqrt(2)*h, h=h, anchor=BOT);
|
cyl(d1=0, d2=Mslop/(T-F)*sqrt(2)*h, h=h, anchor=BOT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue