mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-10 00:46:55 +02:00
Added vquant(), vquantup(), vquantdn()
This commit is contained in:
33
vectors.scad
33
vectors.scad
@@ -49,6 +49,39 @@ function vabs(v) = [for (x=v) abs(x)];
|
|||||||
function normalize(v) = v/norm(v);
|
function normalize(v) = v/norm(v);
|
||||||
|
|
||||||
|
|
||||||
|
// Function: vquant()
|
||||||
|
// Usage:
|
||||||
|
// vquant(v,m)
|
||||||
|
// Description:
|
||||||
|
// Quantizes each scalar in the vector `v` to an integer multiple of `m`, rounding to the nearest multiple.
|
||||||
|
// Arguments:
|
||||||
|
// v = The vector to quantize.
|
||||||
|
// m = The multiple to quantize to.
|
||||||
|
function vquant(v,m) = [for (x=v) quant(x,m)];
|
||||||
|
|
||||||
|
|
||||||
|
// Function: vquantdn()
|
||||||
|
// Usage:
|
||||||
|
// vquantdn(v,m)
|
||||||
|
// Description:
|
||||||
|
// Quantizes each scalar in the vector `v` to an integer multiple of `m`, rounding down to the nearest multiple.
|
||||||
|
// Arguments:
|
||||||
|
// v = The vector to quantize.
|
||||||
|
// m = The multiple to quantize to.
|
||||||
|
function vquantdn(v,m) = [for (x=v) quantdn(x,m)];
|
||||||
|
|
||||||
|
|
||||||
|
// Function: vquantup()
|
||||||
|
// Usage:
|
||||||
|
// vquantup(v,m)
|
||||||
|
// Description:
|
||||||
|
// Quantizes each scalar in the vector `v` to an integer multiple of `m`, rounding up to the nearest multiple.
|
||||||
|
// Arguments:
|
||||||
|
// v = The vector to quantize.
|
||||||
|
// m = The multiple to quantize to.
|
||||||
|
function vquantup(v,m) = [for (x=v) quantup(x,m)];
|
||||||
|
|
||||||
|
|
||||||
// Function: vector_angle()
|
// Function: vector_angle()
|
||||||
// Usage:
|
// Usage:
|
||||||
// vector_angle(v1,v2);
|
// vector_angle(v1,v2);
|
||||||
|
Reference in New Issue
Block a user