mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-26 00:43:43 +02:00
vmul() to v_mul(), etc.
This commit is contained in:
@@ -111,7 +111,7 @@ module test_scale() {
|
||||
for (val=vals) {
|
||||
assert_equal(scale(point2d(val)), [[val.x,0,0],[0,val.y,0],[0,0,1]]);
|
||||
assert_equal(scale(val), [[val.x,0,0,0],[0,val.y,0,0],[0,0,val.z,0],[0,0,0,1]]);
|
||||
assert_equal(scale(val, p=[1,2,3]), vmul([1,2,3], val));
|
||||
assert_equal(scale(val, p=[1,2,3]), v_mul([1,2,3], val));
|
||||
scale(val) nil();
|
||||
}
|
||||
assert_equal(scale(3), [[3,0,0,0],[0,3,0,0],[0,0,3,0],[0,0,0,1]]);
|
||||
@@ -122,7 +122,7 @@ module test_scale() {
|
||||
assert_equal(scale([2,3], p=square(1)), square([2,3]));
|
||||
assert_equal(scale([2,2], cp=[0.5,0.5], p=square(1)), move([-0.5,-0.5], p=square([2,2])));
|
||||
assert_equal(scale([2,3,4], p=cb), cube([2,3,4]));
|
||||
assert_equal(scale([-2,-3,-4], p=cb), [[for (p=cb[0]) vmul(p,[-2,-3,-4])], [for (f=cb[1]) reverse(f)]]);
|
||||
assert_equal(scale([-2,-3,-4], p=cb), [[for (p=cb[0]) v_mul(p,[-2,-3,-4])], [for (f=cb[1]) reverse(f)]]);
|
||||
// Verify that module at least doesn't crash.
|
||||
scale(-5) scale(5) nil();
|
||||
}
|
||||
@@ -289,7 +289,7 @@ module test_rot() {
|
||||
for (vec2 = vecs2d) {
|
||||
assert_equal(
|
||||
rot(from=vec1, to=vec2, p=pts2d, planar=true),
|
||||
apply(affine2d_zrot(vang(vec2)-vang(vec1)), pts2d),
|
||||
apply(affine2d_zrot(v_theta(vec2)-v_theta(vec1)), pts2d),
|
||||
info=str(
|
||||
"from = ", vec1, ", ",
|
||||
"to = ", vec2, ", ",
|
||||
|
@@ -32,66 +32,67 @@ module test_is_vector() {
|
||||
test_is_vector();
|
||||
|
||||
|
||||
module test_vfloor() {
|
||||
assert_equal(vfloor([2.0, 3.14, 18.9, 7]), [2,3,18,7]);
|
||||
assert_equal(vfloor([-2.0, -3.14, -18.9, -7]), [-2,-4,-19,-7]);
|
||||
module test_v_floor() {
|
||||
assert_equal(v_floor([2.0, 3.14, 18.9, 7]), [2,3,18,7]);
|
||||
assert_equal(v_floor([-2.0, -3.14, -18.9, -7]), [-2,-4,-19,-7]);
|
||||
}
|
||||
test_vfloor();
|
||||
test_v_floor();
|
||||
|
||||
|
||||
module test_vceil() {
|
||||
assert_equal(vceil([2.0, 3.14, 18.9, 7]), [2,4,19,7]);
|
||||
assert_equal(vceil([-2.0, -3.14, -18.9, -7]), [-2,-3,-18,-7]);
|
||||
module test_v_ceil() {
|
||||
assert_equal(v_ceil([2.0, 3.14, 18.9, 7]), [2,4,19,7]);
|
||||
assert_equal(v_ceil([-2.0, -3.14, -18.9, -7]), [-2,-3,-18,-7]);
|
||||
}
|
||||
test_vceil();
|
||||
test_v_ceil();
|
||||
|
||||
|
||||
module test_vmul() {
|
||||
assert_equal(vmul([3,4,5], [8,7,6]), [24,28,30]);
|
||||
assert_equal(vmul([1,2,3], [4,5,6]), [4,10,18]);
|
||||
assert_equal(vmul([[1,2,3],[4,5,6],[7,8,9]], [[4,5,6],[3,2,1],[5,9,3]]), [32,28,134]);
|
||||
module test_v_mul() {
|
||||
assert_equal(v_mul([3,4,5], [8,7,6]), [24,28,30]);
|
||||
assert_equal(v_mul([1,2,3], [4,5,6]), [4,10,18]);
|
||||
assert_equal(v_mul([[1,2,3],[4,5,6],[7,8,9]], [[4,5,6],[3,2,1],[5,9,3]]), [32,28,134]);
|
||||
}
|
||||
test_vmul();
|
||||
test_v_mul();
|
||||
|
||||
|
||||
module test_vdiv() {
|
||||
assert(vdiv([24,28,30], [8,7,6]) == [3, 4, 5]);
|
||||
module test_v_div() {
|
||||
assert(v_div([24,28,30], [8,7,6]) == [3, 4, 5]);
|
||||
}
|
||||
test_vdiv();
|
||||
test_v_div();
|
||||
|
||||
|
||||
module test_vabs() {
|
||||
assert(vabs([2,4,8]) == [2,4,8]);
|
||||
assert(vabs([-2,-4,-8]) == [2,4,8]);
|
||||
assert(vabs([-2,4,8]) == [2,4,8]);
|
||||
assert(vabs([2,-4,8]) == [2,4,8]);
|
||||
assert(vabs([2,4,-8]) == [2,4,8]);
|
||||
module test_v_abs() {
|
||||
assert(v_abs([2,4,8]) == [2,4,8]);
|
||||
assert(v_abs([-2,-4,-8]) == [2,4,8]);
|
||||
assert(v_abs([-2,4,8]) == [2,4,8]);
|
||||
assert(v_abs([2,-4,8]) == [2,4,8]);
|
||||
assert(v_abs([2,4,-8]) == [2,4,8]);
|
||||
}
|
||||
test_vabs();
|
||||
test_v_abs();
|
||||
|
||||
include <../strings.scad>
|
||||
module test_vang() {
|
||||
assert(vang([1,0])==0);
|
||||
assert(vang([0,1])==90);
|
||||
assert(vang([-1,0])==180);
|
||||
assert(vang([0,-1])==-90);
|
||||
assert(vang([1,1])==45);
|
||||
assert(vang([-1,1])==135);
|
||||
assert(vang([1,-1])==-45);
|
||||
assert(vang([-1,-1])==-135);
|
||||
assert(vang([0,0,1])==[0,90]);
|
||||
assert(vang([0,1,1])==[90,45]);
|
||||
assert(vang([0,1,-1])==[90,-45]);
|
||||
assert(vang([1,0,0])==[0,0]);
|
||||
assert(vang([0,1,0])==[90,0]);
|
||||
assert(vang([0,-1,0])==[-90,0]);
|
||||
assert(vang([-1,0,0])==[180,0]);
|
||||
assert(vang([1,0,1])==[0,45]);
|
||||
assert(vang([0,1,1])==[90,45]);
|
||||
assert(vang([0,-1,1])==[-90,45]);
|
||||
assert(approx(vang([1,1,1]),[45, 35.2643896828]));
|
||||
module test_v_theta() {
|
||||
assert_approx(v_theta([0,0]), 0);
|
||||
assert_approx(v_theta([1,0]), 0);
|
||||
assert_approx(v_theta([0,1]), 90);
|
||||
assert_approx(v_theta([-1,0]), 180);
|
||||
assert_approx(v_theta([0,-1]), -90);
|
||||
assert_approx(v_theta([1,1]), 45);
|
||||
assert_approx(v_theta([-1,1]), 135);
|
||||
assert_approx(v_theta([1,-1]), -45);
|
||||
assert_approx(v_theta([-1,-1]), -135);
|
||||
assert_approx(v_theta([0,0,1]), 0);
|
||||
assert_approx(v_theta([0,1,1]), 90);
|
||||
assert_approx(v_theta([0,1,-1]), 90);
|
||||
assert_approx(v_theta([1,0,0]), 0);
|
||||
assert_approx(v_theta([0,1,0]), 90);
|
||||
assert_approx(v_theta([0,-1,0]), -90);
|
||||
assert_approx(v_theta([-1,0,0]), 180);
|
||||
assert_approx(v_theta([1,0,1]), 0);
|
||||
assert_approx(v_theta([0,1,1]), 90);
|
||||
assert_approx(v_theta([0,-1,1]), -90);
|
||||
assert_approx(v_theta([1,1,1]), 45);
|
||||
}
|
||||
test_vang();
|
||||
test_v_theta();
|
||||
|
||||
|
||||
module test_unit() {
|
||||
|
Reference in New Issue
Block a user