mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-31 03:40:06 +02:00
Merge branch 'master' into master
This commit is contained in:
@@ -1264,4 +1264,36 @@ module test_poly_add(){
|
||||
}
|
||||
test_poly_add();
|
||||
|
||||
|
||||
module test_root_find(){
|
||||
flist = [
|
||||
function(x) x*x*x-2*x-5,
|
||||
function(x) 1-1/x/x,
|
||||
function(x) pow(x-3,3),
|
||||
function(x) pow(x-2,5),
|
||||
function(x) (let(xi=0.61489) -3062*(1-xi)*exp(-x)/(xi+(1-xi)*exp(-x)) -1013 + 1628/x),
|
||||
function(x) exp(x)-2-.01/x/x + .000002/x/x/x,
|
||||
];
|
||||
fint=[
|
||||
[0,4],
|
||||
[1e-4, 4],
|
||||
[0,6],
|
||||
[0,4],
|
||||
[1e-4,5],
|
||||
[-1,4]
|
||||
];
|
||||
answers = [2.094551481542328,
|
||||
1,
|
||||
3,
|
||||
2,
|
||||
1.037536033287040,
|
||||
0.7032048403631350
|
||||
];
|
||||
|
||||
roots = [for(i=idx(flist)) root_find(flist[i], fint[i][0], fint[i][1])];
|
||||
assert_approx(roots, answers, 1e-10);
|
||||
}
|
||||
test_root_find();
|
||||
|
||||
|
||||
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
||||
|
@@ -1,403 +1,384 @@
|
||||
include <../std.scad>
|
||||
include <../strings.scad>
|
||||
|
||||
|
||||
function rec_cmp(a,b,eps=1e-9) =
|
||||
typeof(a)!=typeof(b)? false :
|
||||
is_num(a)? approx(a,b,eps=eps) :
|
||||
is_list(a)? len(a)==len(b) && all([for (i=idx(a)) rec_cmp(a[i],b[i],eps=eps)]) :
|
||||
a == b;
|
||||
|
||||
function Qstandard(q) = sign([for(qi=q) if( ! approx(qi,0)) qi,0 ][0])*q;
|
||||
function _q_standard(q) = sign([for(qi=q) if( ! approx(qi,0)) qi,0 ][0])*q;
|
||||
|
||||
module verify_f(actual,expected) {
|
||||
if (!rec_cmp(actual,expected)) {
|
||||
echo(str("Expected: ",fmt_float(expected,10)));
|
||||
echo(str(" : ",expected));
|
||||
echo(str("Actual : ",fmt_float(actual,10)));
|
||||
echo(str(" : ",actual));
|
||||
echo(str("Delta : ",fmt_float(expected-actual,10)));
|
||||
echo(str(" : ",expected-actual));
|
||||
assert(approx(expected,actual));
|
||||
}
|
||||
|
||||
module test_is_quaternion() {
|
||||
assert_approx(is_quaternion([0]),false);
|
||||
assert_approx(is_quaternion([0,0,0,0]),false);
|
||||
assert_approx(is_quaternion([1,0,2,0]),true);
|
||||
assert_approx(is_quaternion([1,0,2,0,0]),false);
|
||||
}
|
||||
test_is_quaternion();
|
||||
|
||||
|
||||
module test_Q_is_quat() {
|
||||
verify_f(Q_is_quat([0]),false);
|
||||
verify_f(Q_is_quat([0,0,0,0]),false);
|
||||
verify_f(Q_is_quat([1,0,2,0]),true);
|
||||
verify_f(Q_is_quat([1,0,2,0,0]),false);
|
||||
module test_quat() {
|
||||
assert_approx(quat(UP,0),[0,0,0,1]);
|
||||
assert_approx(quat(FWD,0),[0,0,0,1]);
|
||||
assert_approx(quat(LEFT,0),[0,0,0,1]);
|
||||
assert_approx(quat(UP,45),[0,0,0.3826834324,0.9238795325]);
|
||||
assert_approx(quat(LEFT,45),[-0.3826834324, 0, 0, 0.9238795325]);
|
||||
assert_approx(quat(BACK,45),[0,0.3826834323,0,0.9238795325]);
|
||||
assert_approx(quat(FWD+RIGHT,30),[0.1830127019, -0.1830127019, 0, 0.9659258263]);
|
||||
}
|
||||
test_Q_is_quat();
|
||||
test_quat();
|
||||
|
||||
|
||||
module test_Quat() {
|
||||
verify_f(Quat(UP,0),[0,0,0,1]);
|
||||
verify_f(Quat(FWD,0),[0,0,0,1]);
|
||||
verify_f(Quat(LEFT,0),[0,0,0,1]);
|
||||
verify_f(Quat(UP,45),[0,0,0.3826834324,0.9238795325]);
|
||||
verify_f(Quat(LEFT,45),[-0.3826834324, 0, 0, 0.9238795325]);
|
||||
verify_f(Quat(BACK,45),[0,0.3826834323,0,0.9238795325]);
|
||||
verify_f(Quat(FWD+RIGHT,30),[0.1830127019, -0.1830127019, 0, 0.9659258263]);
|
||||
module test_quat_x() {
|
||||
assert_approx(quat_x(0),[0,0,0,1]);
|
||||
assert_approx(quat_x(35),[0.3007057995,0,0,0.9537169507]);
|
||||
assert_approx(quat_x(45),[0.3826834324,0,0,0.9238795325]);
|
||||
}
|
||||
test_Quat();
|
||||
test_quat_x();
|
||||
|
||||
|
||||
module test_QuatX() {
|
||||
verify_f(QuatX(0),[0,0,0,1]);
|
||||
verify_f(QuatX(35),[0.3007057995,0,0,0.9537169507]);
|
||||
verify_f(QuatX(45),[0.3826834324,0,0,0.9238795325]);
|
||||
module test_quat_y() {
|
||||
assert_approx(quat_y(0),[0,0,0,1]);
|
||||
assert_approx(quat_y(35),[0,0.3007057995,0,0.9537169507]);
|
||||
assert_approx(quat_y(45),[0,0.3826834323,0,0.9238795325]);
|
||||
}
|
||||
test_QuatX();
|
||||
test_quat_y();
|
||||
|
||||
|
||||
module test_QuatY() {
|
||||
verify_f(QuatY(0),[0,0,0,1]);
|
||||
verify_f(QuatY(35),[0,0.3007057995,0,0.9537169507]);
|
||||
verify_f(QuatY(45),[0,0.3826834323,0,0.9238795325]);
|
||||
module test_quat_z() {
|
||||
assert_approx(quat_z(0),[0,0,0,1]);
|
||||
assert_approx(quat_z(36),[0,0,0.3090169944,0.9510565163]);
|
||||
assert_approx(quat_z(45),[0,0,0.3826834324,0.9238795325]);
|
||||
}
|
||||
test_QuatY();
|
||||
test_quat_z();
|
||||
|
||||
|
||||
module test_QuatZ() {
|
||||
verify_f(QuatZ(0),[0,0,0,1]);
|
||||
verify_f(QuatZ(36),[0,0,0.3090169944,0.9510565163]);
|
||||
verify_f(QuatZ(45),[0,0,0.3826834324,0.9238795325]);
|
||||
module test_quat_xyz() {
|
||||
assert_approx(quat_xyz([0,0,0]), [0,0,0,1]);
|
||||
assert_approx(quat_xyz([30,0,0]), [0.2588190451, 0, 0, 0.9659258263]);
|
||||
assert_approx(quat_xyz([90,0,0]), [0.7071067812, 0, 0, 0.7071067812]);
|
||||
assert_approx(quat_xyz([-270,0,0]), [-0.7071067812, 0, 0, -0.7071067812]);
|
||||
assert_approx(quat_xyz([180,0,0]), [1,0,0,0]);
|
||||
assert_approx(quat_xyz([270,0,0]), [0.7071067812, 0, 0, -0.7071067812]);
|
||||
assert_approx(quat_xyz([-90,0,0]), [-0.7071067812, 0, 0, 0.7071067812]);
|
||||
assert_approx(quat_xyz([360,0,0]), [0,0,0,-1]);
|
||||
|
||||
assert_approx(quat_xyz([0,0,0]), [0,0,0,1]);
|
||||
assert_approx(quat_xyz([0,30,0]), [0, 0.2588190451, 0, 0.9659258263]);
|
||||
assert_approx(quat_xyz([0,90,0]), [0, 0.7071067812, 0, 0.7071067812]);
|
||||
assert_approx(quat_xyz([0,-270,0]), [0, -0.7071067812, 0, -0.7071067812]);
|
||||
assert_approx(quat_xyz([0,180,0]), [0,1,0,0]);
|
||||
assert_approx(quat_xyz([0,270,0]), [0, 0.7071067812, 0, -0.7071067812]);
|
||||
assert_approx(quat_xyz([0,-90,0]), [0, -0.7071067812, 0, 0.7071067812]);
|
||||
assert_approx(quat_xyz([0,360,0]), [0,0,0,-1]);
|
||||
|
||||
assert_approx(quat_xyz([0,0,0]), [0,0,0,1]);
|
||||
assert_approx(quat_xyz([0,0,30]), [0, 0, 0.2588190451, 0.9659258263]);
|
||||
assert_approx(quat_xyz([0,0,90]), [0, 0, 0.7071067812, 0.7071067812]);
|
||||
assert_approx(quat_xyz([0,0,-270]), [0, 0, -0.7071067812, -0.7071067812]);
|
||||
assert_approx(quat_xyz([0,0,180]), [0,0,1,0]);
|
||||
assert_approx(quat_xyz([0,0,270]), [0, 0, 0.7071067812, -0.7071067812]);
|
||||
assert_approx(quat_xyz([0,0,-90]), [0, 0, -0.7071067812, 0.7071067812]);
|
||||
assert_approx(quat_xyz([0,0,360]), [0,0,0,-1]);
|
||||
|
||||
assert_approx(quat_xyz([30,30,30]), [0.1767766953, 0.3061862178, 0.1767766953, 0.9185586535]);
|
||||
assert_approx(quat_xyz([12,34,56]), [-0.04824789229, 0.3036636044, 0.4195145429, 0.8540890495]);
|
||||
}
|
||||
test_QuatZ();
|
||||
test_quat_xyz();
|
||||
|
||||
|
||||
module test_QuatXYZ() {
|
||||
verify_f(QuatXYZ([0,0,0]), [0,0,0,1]);
|
||||
verify_f(QuatXYZ([30,0,0]), [0.2588190451, 0, 0, 0.9659258263]);
|
||||
verify_f(QuatXYZ([90,0,0]), [0.7071067812, 0, 0, 0.7071067812]);
|
||||
verify_f(QuatXYZ([-270,0,0]), [-0.7071067812, 0, 0, -0.7071067812]);
|
||||
verify_f(QuatXYZ([180,0,0]), [1,0,0,0]);
|
||||
verify_f(QuatXYZ([270,0,0]), [0.7071067812, 0, 0, -0.7071067812]);
|
||||
verify_f(QuatXYZ([-90,0,0]), [-0.7071067812, 0, 0, 0.7071067812]);
|
||||
verify_f(QuatXYZ([360,0,0]), [0,0,0,-1]);
|
||||
|
||||
verify_f(QuatXYZ([0,0,0]), [0,0,0,1]);
|
||||
verify_f(QuatXYZ([0,30,0]), [0, 0.2588190451, 0, 0.9659258263]);
|
||||
verify_f(QuatXYZ([0,90,0]), [0, 0.7071067812, 0, 0.7071067812]);
|
||||
verify_f(QuatXYZ([0,-270,0]), [0, -0.7071067812, 0, -0.7071067812]);
|
||||
verify_f(QuatXYZ([0,180,0]), [0,1,0,0]);
|
||||
verify_f(QuatXYZ([0,270,0]), [0, 0.7071067812, 0, -0.7071067812]);
|
||||
verify_f(QuatXYZ([0,-90,0]), [0, -0.7071067812, 0, 0.7071067812]);
|
||||
verify_f(QuatXYZ([0,360,0]), [0,0,0,-1]);
|
||||
|
||||
verify_f(QuatXYZ([0,0,0]), [0,0,0,1]);
|
||||
verify_f(QuatXYZ([0,0,30]), [0, 0, 0.2588190451, 0.9659258263]);
|
||||
verify_f(QuatXYZ([0,0,90]), [0, 0, 0.7071067812, 0.7071067812]);
|
||||
verify_f(QuatXYZ([0,0,-270]), [0, 0, -0.7071067812, -0.7071067812]);
|
||||
verify_f(QuatXYZ([0,0,180]), [0,0,1,0]);
|
||||
verify_f(QuatXYZ([0,0,270]), [0, 0, 0.7071067812, -0.7071067812]);
|
||||
verify_f(QuatXYZ([0,0,-90]), [0, 0, -0.7071067812, 0.7071067812]);
|
||||
verify_f(QuatXYZ([0,0,360]), [0,0,0,-1]);
|
||||
|
||||
verify_f(QuatXYZ([30,30,30]), [0.1767766953, 0.3061862178, 0.1767766953, 0.9185586535]);
|
||||
verify_f(QuatXYZ([12,34,56]), [-0.04824789229, 0.3036636044, 0.4195145429, 0.8540890495]);
|
||||
module test_q_from_to() {
|
||||
assert_approx(q_mul(q_from_to([1,2,3], [4,5,2]),q_from_to([4,5,2], [1,2,3])), q_ident());
|
||||
assert_approx(q_matrix4(q_from_to([1,2,3], [4,5,2])), rot(from=[1,2,3],to=[4,5,2]));
|
||||
assert_approx(q_rot(q_from_to([1,2,3], -[1,2,3]),[1,2,3]), -[1,2,3]);
|
||||
assert_approx(unit(q_rot(q_from_to([1,2,3], [4,5,2]),[1,2,3])), unit([4,5,2]));
|
||||
}
|
||||
test_QuatXYZ();
|
||||
test_q_from_to();
|
||||
|
||||
|
||||
module test_Q_From_to() {
|
||||
verify_f(Q_Mul(Q_From_to([1,2,3], [4,5,2]),Q_From_to([4,5,2], [1,2,3])), Q_Ident());
|
||||
verify_f(Q_Matrix4(Q_From_to([1,2,3], [4,5,2])), rot(from=[1,2,3],to=[4,5,2]));
|
||||
verify_f(Qrot(Q_From_to([1,2,3], -[1,2,3]),[1,2,3]), -[1,2,3]);
|
||||
verify_f(unit(Qrot(Q_From_to([1,2,3], [4,5,2]),[1,2,3])), unit([4,5,2]));
|
||||
module test_q_ident() {
|
||||
assert_approx(q_ident(), [0,0,0,1]);
|
||||
}
|
||||
test_Q_From_to();
|
||||
test_q_ident();
|
||||
|
||||
|
||||
module test_Q_Ident() {
|
||||
verify_f(Q_Ident(), [0,0,0,1]);
|
||||
module test_q_add_s() {
|
||||
assert_approx(q_add_s([0,0,0,1],3),[0,0,0,4]);
|
||||
assert_approx(q_add_s([0,0,1,0],3),[0,0,1,3]);
|
||||
assert_approx(q_add_s([0,1,0,0],3),[0,1,0,3]);
|
||||
assert_approx(q_add_s([1,0,0,0],3),[1,0,0,3]);
|
||||
assert_approx(q_add_s(quat(LEFT+FWD,23),1),[-0.1409744184, -0.1409744184, 0, 1.979924705]);
|
||||
}
|
||||
test_Q_Ident();
|
||||
test_q_add_s();
|
||||
|
||||
|
||||
module test_Q_Add_S() {
|
||||
verify_f(Q_Add_S([0,0,0,1],3),[0,0,0,4]);
|
||||
verify_f(Q_Add_S([0,0,1,0],3),[0,0,1,3]);
|
||||
verify_f(Q_Add_S([0,1,0,0],3),[0,1,0,3]);
|
||||
verify_f(Q_Add_S([1,0,0,0],3),[1,0,0,3]);
|
||||
verify_f(Q_Add_S(Quat(LEFT+FWD,23),1),[-0.1409744184, -0.1409744184, 0, 1.979924705]);
|
||||
module test_q_sub_s() {
|
||||
assert_approx(q_sub_s([0,0,0,1],3),[0,0,0,-2]);
|
||||
assert_approx(q_sub_s([0,0,1,0],3),[0,0,1,-3]);
|
||||
assert_approx(q_sub_s([0,1,0,0],3),[0,1,0,-3]);
|
||||
assert_approx(q_sub_s([1,0,0,0],3),[1,0,0,-3]);
|
||||
assert_approx(q_sub_s(quat(LEFT+FWD,23),1),[-0.1409744184, -0.1409744184, 0, -0.02007529538]);
|
||||
}
|
||||
test_Q_Add_S();
|
||||
test_q_sub_s();
|
||||
|
||||
|
||||
module test_Q_Sub_S() {
|
||||
verify_f(Q_Sub_S([0,0,0,1],3),[0,0,0,-2]);
|
||||
verify_f(Q_Sub_S([0,0,1,0],3),[0,0,1,-3]);
|
||||
verify_f(Q_Sub_S([0,1,0,0],3),[0,1,0,-3]);
|
||||
verify_f(Q_Sub_S([1,0,0,0],3),[1,0,0,-3]);
|
||||
verify_f(Q_Sub_S(Quat(LEFT+FWD,23),1),[-0.1409744184, -0.1409744184, 0, -0.02007529538]);
|
||||
module test_q_mul_s() {
|
||||
assert_approx(q_mul_s([0,0,0,1],3),[0,0,0,3]);
|
||||
assert_approx(q_mul_s([0,0,1,0],3),[0,0,3,0]);
|
||||
assert_approx(q_mul_s([0,1,0,0],3),[0,3,0,0]);
|
||||
assert_approx(q_mul_s([1,0,0,0],3),[3,0,0,0]);
|
||||
assert_approx(q_mul_s([1,0,0,1],3),[3,0,0,3]);
|
||||
assert_approx(q_mul_s(quat(LEFT+FWD,23),4),[-0.5638976735, -0.5638976735, 0, 3.919698818]);
|
||||
}
|
||||
test_Q_Sub_S();
|
||||
test_q_mul_s();
|
||||
|
||||
|
||||
module test_Q_Mul_S() {
|
||||
verify_f(Q_Mul_S([0,0,0,1],3),[0,0,0,3]);
|
||||
verify_f(Q_Mul_S([0,0,1,0],3),[0,0,3,0]);
|
||||
verify_f(Q_Mul_S([0,1,0,0],3),[0,3,0,0]);
|
||||
verify_f(Q_Mul_S([1,0,0,0],3),[3,0,0,0]);
|
||||
verify_f(Q_Mul_S([1,0,0,1],3),[3,0,0,3]);
|
||||
verify_f(Q_Mul_S(Quat(LEFT+FWD,23),4),[-0.5638976735, -0.5638976735, 0, 3.919698818]);
|
||||
|
||||
module test_q_div_s() {
|
||||
assert_approx(q_div_s([0,0,0,1],3),[0,0,0,1/3]);
|
||||
assert_approx(q_div_s([0,0,1,0],3),[0,0,1/3,0]);
|
||||
assert_approx(q_div_s([0,1,0,0],3),[0,1/3,0,0]);
|
||||
assert_approx(q_div_s([1,0,0,0],3),[1/3,0,0,0]);
|
||||
assert_approx(q_div_s([1,0,0,1],3),[1/3,0,0,1/3]);
|
||||
assert_approx(q_div_s(quat(LEFT+FWD,23),4),[-0.03524360459, -0.03524360459, 0, 0.2449811762]);
|
||||
}
|
||||
test_Q_Mul_S();
|
||||
test_q_div_s();
|
||||
|
||||
|
||||
|
||||
module test_Q_Div_S() {
|
||||
verify_f(Q_Div_S([0,0,0,1],3),[0,0,0,1/3]);
|
||||
verify_f(Q_Div_S([0,0,1,0],3),[0,0,1/3,0]);
|
||||
verify_f(Q_Div_S([0,1,0,0],3),[0,1/3,0,0]);
|
||||
verify_f(Q_Div_S([1,0,0,0],3),[1/3,0,0,0]);
|
||||
verify_f(Q_Div_S([1,0,0,1],3),[1/3,0,0,1/3]);
|
||||
verify_f(Q_Div_S(Quat(LEFT+FWD,23),4),[-0.03524360459, -0.03524360459, 0, 0.2449811762]);
|
||||
module test_q_add() {
|
||||
assert_approx(q_add([2,3,4,5],[-1,-1,-1,-1]),[1,2,3,4]);
|
||||
assert_approx(q_add([2,3,4,5],[-3,-3,-3,-3]),[-1,0,1,2]);
|
||||
assert_approx(q_add([2,3,4,5],[0,0,0,0]),[2,3,4,5]);
|
||||
assert_approx(q_add([2,3,4,5],[1,1,1,1]),[3,4,5,6]);
|
||||
assert_approx(q_add([2,3,4,5],[1,0,0,0]),[3,3,4,5]);
|
||||
assert_approx(q_add([2,3,4,5],[0,1,0,0]),[2,4,4,5]);
|
||||
assert_approx(q_add([2,3,4,5],[0,0,1,0]),[2,3,5,5]);
|
||||
assert_approx(q_add([2,3,4,5],[0,0,0,1]),[2,3,4,6]);
|
||||
assert_approx(q_add([2,3,4,5],[2,1,2,1]),[4,4,6,6]);
|
||||
assert_approx(q_add([2,3,4,5],[1,2,1,2]),[3,5,5,7]);
|
||||
}
|
||||
test_Q_Div_S();
|
||||
test_q_add();
|
||||
|
||||
|
||||
module test_Q_Add() {
|
||||
verify_f(Q_Add([2,3,4,5],[-1,-1,-1,-1]),[1,2,3,4]);
|
||||
verify_f(Q_Add([2,3,4,5],[-3,-3,-3,-3]),[-1,0,1,2]);
|
||||
verify_f(Q_Add([2,3,4,5],[0,0,0,0]),[2,3,4,5]);
|
||||
verify_f(Q_Add([2,3,4,5],[1,1,1,1]),[3,4,5,6]);
|
||||
verify_f(Q_Add([2,3,4,5],[1,0,0,0]),[3,3,4,5]);
|
||||
verify_f(Q_Add([2,3,4,5],[0,1,0,0]),[2,4,4,5]);
|
||||
verify_f(Q_Add([2,3,4,5],[0,0,1,0]),[2,3,5,5]);
|
||||
verify_f(Q_Add([2,3,4,5],[0,0,0,1]),[2,3,4,6]);
|
||||
verify_f(Q_Add([2,3,4,5],[2,1,2,1]),[4,4,6,6]);
|
||||
verify_f(Q_Add([2,3,4,5],[1,2,1,2]),[3,5,5,7]);
|
||||
module test_q_sub() {
|
||||
assert_approx(q_sub([2,3,4,5],[-1,-1,-1,-1]),[3,4,5,6]);
|
||||
assert_approx(q_sub([2,3,4,5],[-3,-3,-3,-3]),[5,6,7,8]);
|
||||
assert_approx(q_sub([2,3,4,5],[0,0,0,0]),[2,3,4,5]);
|
||||
assert_approx(q_sub([2,3,4,5],[1,1,1,1]),[1,2,3,4]);
|
||||
assert_approx(q_sub([2,3,4,5],[1,0,0,0]),[1,3,4,5]);
|
||||
assert_approx(q_sub([2,3,4,5],[0,1,0,0]),[2,2,4,5]);
|
||||
assert_approx(q_sub([2,3,4,5],[0,0,1,0]),[2,3,3,5]);
|
||||
assert_approx(q_sub([2,3,4,5],[0,0,0,1]),[2,3,4,4]);
|
||||
assert_approx(q_sub([2,3,4,5],[2,1,2,1]),[0,2,2,4]);
|
||||
assert_approx(q_sub([2,3,4,5],[1,2,1,2]),[1,1,3,3]);
|
||||
}
|
||||
test_Q_Add();
|
||||
test_q_sub();
|
||||
|
||||
|
||||
module test_Q_Sub() {
|
||||
verify_f(Q_Sub([2,3,4,5],[-1,-1,-1,-1]),[3,4,5,6]);
|
||||
verify_f(Q_Sub([2,3,4,5],[-3,-3,-3,-3]),[5,6,7,8]);
|
||||
verify_f(Q_Sub([2,3,4,5],[0,0,0,0]),[2,3,4,5]);
|
||||
verify_f(Q_Sub([2,3,4,5],[1,1,1,1]),[1,2,3,4]);
|
||||
verify_f(Q_Sub([2,3,4,5],[1,0,0,0]),[1,3,4,5]);
|
||||
verify_f(Q_Sub([2,3,4,5],[0,1,0,0]),[2,2,4,5]);
|
||||
verify_f(Q_Sub([2,3,4,5],[0,0,1,0]),[2,3,3,5]);
|
||||
verify_f(Q_Sub([2,3,4,5],[0,0,0,1]),[2,3,4,4]);
|
||||
verify_f(Q_Sub([2,3,4,5],[2,1,2,1]),[0,2,2,4]);
|
||||
verify_f(Q_Sub([2,3,4,5],[1,2,1,2]),[1,1,3,3]);
|
||||
module test_q_mul() {
|
||||
assert_approx(q_mul(quat_z(30),quat_x(57)),[0.4608999698, 0.1234977747, 0.2274546059, 0.8488721457]);
|
||||
assert_approx(q_mul(quat_y(30),quat_z(23)),[0.05160021841, 0.2536231763, 0.1925746368, 0.94653458]);
|
||||
}
|
||||
test_Q_Sub();
|
||||
test_q_mul();
|
||||
|
||||
|
||||
module test_Q_Mul() {
|
||||
verify_f(Q_Mul(QuatZ(30),QuatX(57)),[0.4608999698, 0.1234977747, 0.2274546059, 0.8488721457]);
|
||||
verify_f(Q_Mul(QuatY(30),QuatZ(23)),[0.05160021841, 0.2536231763, 0.1925746368, 0.94653458]);
|
||||
module test_q_cumulative() {
|
||||
assert_approx(q_cumulative([quat_z(30),quat_x(57),quat_y(18)]),[[0, 0, 0.2588190451, 0.9659258263], [0.4608999698, -0.1234977747, 0.2274546059, 0.8488721457], [0.4908072659, 0.01081554785, 0.1525536221, 0.8577404293]]);
|
||||
}
|
||||
test_Q_Mul();
|
||||
test_q_cumulative();
|
||||
|
||||
|
||||
module test_Q_Cumulative() {
|
||||
verify_f(Q_Cumulative([QuatZ(30),QuatX(57),QuatY(18)]),[[0, 0, 0.2588190451, 0.9659258263], [0.4608999698, -0.1234977747, 0.2274546059, 0.8488721457], [0.4908072659, 0.01081554785, 0.1525536221, 0.8577404293]]);
|
||||
module test_q_dot() {
|
||||
assert_approx(q_dot(quat_z(30),quat_x(57)),0.8488721457);
|
||||
assert_approx(q_dot(quat_y(30),quat_z(23)),0.94653458);
|
||||
}
|
||||
test_Q_Cumulative();
|
||||
test_q_dot();
|
||||
|
||||
|
||||
module test_Q_Dot() {
|
||||
verify_f(Q_Dot(QuatZ(30),QuatX(57)),0.8488721457);
|
||||
verify_f(Q_Dot(QuatY(30),QuatZ(23)),0.94653458);
|
||||
module test_q_neg() {
|
||||
assert_approx(q_neg([1,0,0,1]),[-1,0,0,-1]);
|
||||
assert_approx(q_neg([0,1,1,0]),[0,-1,-1,0]);
|
||||
assert_approx(q_neg(quat_xyz([23,45,67])),[0.0533818345,-0.4143703268,-0.4360652669,-0.7970537592]);
|
||||
}
|
||||
test_Q_Dot();
|
||||
test_q_neg();
|
||||
|
||||
|
||||
module test_Q_Neg() {
|
||||
verify_f(Q_Neg([1,0,0,1]),[-1,0,0,-1]);
|
||||
verify_f(Q_Neg([0,1,1,0]),[0,-1,-1,0]);
|
||||
verify_f(Q_Neg(QuatXYZ([23,45,67])),[0.0533818345,-0.4143703268,-0.4360652669,-0.7970537592]);
|
||||
module test_q_conj() {
|
||||
assert_approx(q_conj([1,0,0,1]),[-1,0,0,1]);
|
||||
assert_approx(q_conj([0,1,1,0]),[0,-1,-1,0]);
|
||||
assert_approx(q_conj(quat_xyz([23,45,67])),[0.0533818345, -0.4143703268, -0.4360652669, 0.7970537592]);
|
||||
}
|
||||
test_Q_Neg();
|
||||
test_q_conj();
|
||||
|
||||
|
||||
module test_Q_Conj() {
|
||||
verify_f(Q_Conj([1,0,0,1]),[-1,0,0,1]);
|
||||
verify_f(Q_Conj([0,1,1,0]),[0,-1,-1,0]);
|
||||
verify_f(Q_Conj(QuatXYZ([23,45,67])),[0.0533818345, -0.4143703268, -0.4360652669, 0.7970537592]);
|
||||
module test_q_inverse() {
|
||||
|
||||
assert_approx(q_inverse([1,0,0,1]),[-1,0,0,1]/sqrt(2));
|
||||
assert_approx(q_inverse([0,1,1,0]),[0,-1,-1,0]/sqrt(2));
|
||||
assert_approx(q_inverse(quat_xyz([23,45,67])),q_conj(quat_xyz([23,45,67])));
|
||||
assert_approx(q_mul(q_inverse(quat_xyz([23,45,67])),quat_xyz([23,45,67])),q_ident());
|
||||
}
|
||||
test_Q_Conj();
|
||||
test_q_inverse();
|
||||
|
||||
|
||||
module test_Q_Inverse() {
|
||||
|
||||
verify_f(Q_Inverse([1,0,0,1]),[-1,0,0,1]/sqrt(2));
|
||||
verify_f(Q_Inverse([0,1,1,0]),[0,-1,-1,0]/sqrt(2));
|
||||
verify_f(Q_Inverse(QuatXYZ([23,45,67])),Q_Conj(QuatXYZ([23,45,67])));
|
||||
verify_f(Q_Mul(Q_Inverse(QuatXYZ([23,45,67])),QuatXYZ([23,45,67])),Q_Ident());
|
||||
module test_q_Norm() {
|
||||
assert_approx(q_norm([1,0,0,1]),1.414213562);
|
||||
assert_approx(q_norm([0,1,1,0]),1.414213562);
|
||||
assert_approx(q_norm(quat_xyz([23,45,67])),1);
|
||||
}
|
||||
test_Q_Inverse();
|
||||
test_q_Norm();
|
||||
|
||||
|
||||
module test_Q_Norm() {
|
||||
verify_f(Q_Norm([1,0,0,1]),1.414213562);
|
||||
verify_f(Q_Norm([0,1,1,0]),1.414213562);
|
||||
verify_f(Q_Norm(QuatXYZ([23,45,67])),1);
|
||||
module test_q_normalize() {
|
||||
assert_approx(q_normalize([1,0,0,1]),[0.7071067812, 0, 0, 0.7071067812]);
|
||||
assert_approx(q_normalize([0,1,1,0]),[0, 0.7071067812, 0.7071067812, 0]);
|
||||
assert_approx(q_normalize(quat_xyz([23,45,67])),[-0.0533818345, 0.4143703268, 0.4360652669, 0.7970537592]);
|
||||
}
|
||||
test_Q_Norm();
|
||||
test_q_normalize();
|
||||
|
||||
|
||||
module test_Q_Normalize() {
|
||||
verify_f(Q_Normalize([1,0,0,1]),[0.7071067812, 0, 0, 0.7071067812]);
|
||||
verify_f(Q_Normalize([0,1,1,0]),[0, 0.7071067812, 0.7071067812, 0]);
|
||||
verify_f(Q_Normalize(QuatXYZ([23,45,67])),[-0.0533818345, 0.4143703268, 0.4360652669, 0.7970537592]);
|
||||
module test_q_dist() {
|
||||
assert_approx(q_dist(quat_xyz([23,45,67]),quat_xyz([23,45,67])),0);
|
||||
assert_approx(q_dist(quat_xyz([23,45,67]),quat_xyz([12,34,56])),0.1257349854);
|
||||
}
|
||||
test_Q_Normalize();
|
||||
test_q_dist();
|
||||
|
||||
|
||||
module test_Q_Dist() {
|
||||
verify_f(Q_Dist(QuatXYZ([23,45,67]),QuatXYZ([23,45,67])),0);
|
||||
verify_f(Q_Dist(QuatXYZ([23,45,67]),QuatXYZ([12,34,56])),0.1257349854);
|
||||
module test_q_slerp() {
|
||||
assert_approx(q_slerp(quat_x(45),quat_y(30),0.0),quat_x(45));
|
||||
assert_approx(q_slerp(quat_x(45),quat_y(30),0.5),[0.1967063121, 0.1330377423, 0, 0.9713946602]);
|
||||
assert_approx(q_slerp(quat_x(45),quat_y(30),1.0),quat_y(30));
|
||||
}
|
||||
test_Q_Dist();
|
||||
test_q_slerp();
|
||||
|
||||
|
||||
module test_Q_Slerp() {
|
||||
verify_f(Q_Slerp(QuatX(45),QuatY(30),0.0),QuatX(45));
|
||||
verify_f(Q_Slerp(QuatX(45),QuatY(30),0.5),[0.1967063121, 0.1330377423, 0, 0.9713946602]);
|
||||
verify_f(Q_Slerp(QuatX(45),QuatY(30),1.0),QuatY(30));
|
||||
module test_q_matrix3() {
|
||||
assert_approx(q_matrix3(quat_z(37)),rot(37,planar=true));
|
||||
assert_approx(q_matrix3(quat_z(-49)),rot(-49,planar=true));
|
||||
}
|
||||
test_Q_Slerp();
|
||||
test_q_matrix3();
|
||||
|
||||
|
||||
module test_Q_Matrix3() {
|
||||
verify_f(Q_Matrix3(QuatZ(37)),rot(37,planar=true));
|
||||
verify_f(Q_Matrix3(QuatZ(-49)),rot(-49,planar=true));
|
||||
module test_q_matrix4() {
|
||||
assert_approx(q_matrix4(quat_z(37)),rot(37));
|
||||
assert_approx(q_matrix4(quat_z(-49)),rot(-49));
|
||||
assert_approx(q_matrix4(quat_x(37)),rot([37,0,0]));
|
||||
assert_approx(q_matrix4(quat_y(37)),rot([0,37,0]));
|
||||
assert_approx(q_matrix4(quat_xyz([12,34,56])),rot([12,34,56]));
|
||||
}
|
||||
test_Q_Matrix3();
|
||||
test_q_matrix4();
|
||||
|
||||
|
||||
module test_Q_Matrix4() {
|
||||
verify_f(Q_Matrix4(QuatZ(37)),rot(37));
|
||||
verify_f(Q_Matrix4(QuatZ(-49)),rot(-49));
|
||||
verify_f(Q_Matrix4(QuatX(37)),rot([37,0,0]));
|
||||
verify_f(Q_Matrix4(QuatY(37)),rot([0,37,0]));
|
||||
verify_f(Q_Matrix4(QuatXYZ([12,34,56])),rot([12,34,56]));
|
||||
module test_q_axis() {
|
||||
assert_approx(q_axis(quat_x(37)),RIGHT);
|
||||
assert_approx(q_axis(quat_x(-37)),LEFT);
|
||||
assert_approx(q_axis(quat_y(37)),BACK);
|
||||
assert_approx(q_axis(quat_y(-37)),FWD);
|
||||
assert_approx(q_axis(quat_z(37)),UP);
|
||||
assert_approx(q_axis(quat_z(-37)),DOWN);
|
||||
}
|
||||
test_Q_Matrix4();
|
||||
test_q_axis();
|
||||
|
||||
|
||||
module test_Q_Axis() {
|
||||
verify_f(Q_Axis(QuatX(37)),RIGHT);
|
||||
verify_f(Q_Axis(QuatX(-37)),LEFT);
|
||||
verify_f(Q_Axis(QuatY(37)),BACK);
|
||||
verify_f(Q_Axis(QuatY(-37)),FWD);
|
||||
verify_f(Q_Axis(QuatZ(37)),UP);
|
||||
verify_f(Q_Axis(QuatZ(-37)),DOWN);
|
||||
module test_q_angle() {
|
||||
assert_approx(q_angle(quat_x(0)),0);
|
||||
assert_approx(q_angle(quat_y(0)),0);
|
||||
assert_approx(q_angle(quat_z(0)),0);
|
||||
assert_approx(q_angle(quat_x(37)),37);
|
||||
assert_approx(q_angle(quat_x(-37)),37);
|
||||
assert_approx(q_angle(quat_y(37)),37);
|
||||
assert_approx(q_angle(quat_y(-37)),37);
|
||||
assert_approx(q_angle(quat_z(37)),37);
|
||||
assert_approx(q_angle(quat_z(-37)),37);
|
||||
|
||||
assert_approx(q_angle(quat_z(-37),quat_z(-37)), 0);
|
||||
assert_approx(q_angle(quat_z( 37.123),quat_z(-37.123)), 74.246);
|
||||
assert_approx(q_angle(quat_x( 37),quat_y(-37)), 51.86293283);
|
||||
}
|
||||
test_Q_Axis();
|
||||
test_q_angle();
|
||||
|
||||
|
||||
module test_Q_Angle() {
|
||||
verify_f(Q_Angle(QuatX(0)),0);
|
||||
verify_f(Q_Angle(QuatY(0)),0);
|
||||
verify_f(Q_Angle(QuatZ(0)),0);
|
||||
verify_f(Q_Angle(QuatX(37)),37);
|
||||
verify_f(Q_Angle(QuatX(-37)),37);
|
||||
verify_f(Q_Angle(QuatY(37)),37);
|
||||
verify_f(Q_Angle(QuatY(-37)),37);
|
||||
verify_f(Q_Angle(QuatZ(37)),37);
|
||||
verify_f(Q_Angle(QuatZ(-37)),37);
|
||||
|
||||
verify_f(Q_Angle(QuatZ(-37),QuatZ(-37)), 0);
|
||||
verify_f(Q_Angle(QuatZ( 37.123),QuatZ(-37.123)), 74.246);
|
||||
verify_f(Q_Angle(QuatX( 37),QuatY(-37)), 51.86293283);
|
||||
module test_q_rot() {
|
||||
assert_approx(q_rot(quat_xyz([12,34,56])),rot([12,34,56]));
|
||||
assert_approx(q_rot(quat_xyz([12,34,56]),p=[2,3,4]),rot([12,34,56],p=[2,3,4]));
|
||||
assert_approx(q_rot(quat_xyz([12,34,56]),p=[[2,3,4],[4,9,6]]),rot([12,34,56],p=[[2,3,4],[4,9,6]]));
|
||||
}
|
||||
test_Q_Angle();
|
||||
test_q_rot();
|
||||
|
||||
|
||||
module test_Qrot() {
|
||||
verify_f(Qrot(QuatXYZ([12,34,56])),rot([12,34,56]));
|
||||
verify_f(Qrot(QuatXYZ([12,34,56]),p=[2,3,4]),rot([12,34,56],p=[2,3,4]));
|
||||
verify_f(Qrot(QuatXYZ([12,34,56]),p=[[2,3,4],[4,9,6]]),rot([12,34,56],p=[[2,3,4],[4,9,6]]));
|
||||
module test_q_rotation() {
|
||||
assert_approx(_q_standard(q_rotation(q_matrix3(quat([12,34,56],33)))),_q_standard(quat([12,34,56],33)));
|
||||
assert_approx(q_matrix3(q_rotation(q_matrix3(quat_xyz([12,34,56])))),
|
||||
q_matrix3(quat_xyz([12,34,56])));
|
||||
}
|
||||
test_Qrot();
|
||||
test_q_rotation();
|
||||
|
||||
|
||||
module test_Q_Rotation() {
|
||||
verify_f(Qstandard(Q_Rotation(Q_Matrix3(Quat([12,34,56],33)))),Qstandard(Quat([12,34,56],33)));
|
||||
verify_f(Q_Matrix3(Q_Rotation(Q_Matrix3(QuatXYZ([12,34,56])))),
|
||||
Q_Matrix3(QuatXYZ([12,34,56])));
|
||||
}
|
||||
test_Q_Rotation();
|
||||
module test_q_rotation_path() {
|
||||
assert_approx(q_rotation_path(quat_x(135), 5, quat_y(13.5))[0] , q_matrix4(quat_x(135)));
|
||||
assert_approx(q_rotation_path(quat_x(135), 11, quat_y(13.5))[11] , yrot(13.5));
|
||||
assert_approx(q_rotation_path(quat_x(135), 16, quat_y(13.5))[8] , q_rotation_path(quat_x(135), 8, quat_y(13.5))[4]);
|
||||
assert_approx(q_rotation_path(quat_x(135), 16, quat_y(13.5))[7] ,
|
||||
q_rotation_path(quat_y(13.5),16, quat_x(135))[9]);
|
||||
|
||||
|
||||
module test_Q_Rotation_path() {
|
||||
|
||||
verify_f(Q_Rotation_path(QuatX(135), 5, QuatY(13.5))[0] , Q_Matrix4(QuatX(135)));
|
||||
verify_f(Q_Rotation_path(QuatX(135), 11, QuatY(13.5))[11] , yrot(13.5));
|
||||
verify_f(Q_Rotation_path(QuatX(135), 16, QuatY(13.5))[8] , Q_Rotation_path(QuatX(135), 8, QuatY(13.5))[4]);
|
||||
verify_f(Q_Rotation_path(QuatX(135), 16, QuatY(13.5))[7] ,
|
||||
Q_Rotation_path(QuatY(13.5),16, QuatX(135))[9]);
|
||||
|
||||
verify_f(Q_Rotation_path(QuatX(11), 5)[0] , xrot(11));
|
||||
verify_f(Q_Rotation_path(QuatX(11), 5)[4] , xrot(55));
|
||||
assert_approx(q_rotation_path(quat_x(11), 5)[0] , xrot(11));
|
||||
assert_approx(q_rotation_path(quat_x(11), 5)[4] , xrot(55));
|
||||
|
||||
}
|
||||
test_Q_Rotation_path();
|
||||
test_q_rotation_path();
|
||||
|
||||
|
||||
module test_Q_Nlerp() {
|
||||
verify_f(Q_Nlerp(QuatX(45),QuatY(30),0.0),QuatX(45));
|
||||
verify_f(Q_Nlerp(QuatX(45),QuatY(30),0.5),[0.1967063121, 0.1330377423, 0, 0.9713946602]);
|
||||
verify_f(Q_Rotation_path(QuatX(135), 16, QuatY(13.5))[8] , Q_Matrix4(Q_Nlerp(QuatX(135), QuatY(13.5),0.5)));
|
||||
verify_f(Q_Nlerp(QuatX(45),QuatY(30),1.0),QuatY(30));
|
||||
module test_q_nlerp() {
|
||||
assert_approx(q_nlerp(quat_x(45),quat_y(30),0.0),quat_x(45));
|
||||
assert_approx(q_nlerp(quat_x(45),quat_y(30),0.5),[0.1967063121, 0.1330377423, 0, 0.9713946602]);
|
||||
assert_approx(q_rotation_path(quat_x(135), 16, quat_y(13.5))[8] , q_matrix4(q_nlerp(quat_x(135), quat_y(13.5),0.5)));
|
||||
assert_approx(q_nlerp(quat_x(45),quat_y(30),1.0),quat_y(30));
|
||||
}
|
||||
test_Q_Nlerp();
|
||||
test_q_nlerp();
|
||||
|
||||
|
||||
module test_Q_Squad() {
|
||||
verify_f(Q_Squad(QuatX(45),QuatZ(30),QuatX(90),QuatY(30),0.0),QuatX(45));
|
||||
verify_f(Q_Squad(QuatX(45),QuatZ(30),QuatX(90),QuatY(30),1.0),QuatY(30));
|
||||
verify_f(Q_Squad(QuatX(0),QuatX(30),QuatX(90),QuatX(120),0.5),
|
||||
Q_Slerp(QuatX(0),QuatX(120),0.5));
|
||||
verify_f(Q_Squad(QuatY(0),QuatY(0),QuatX(120),QuatX(120),0.3),
|
||||
Q_Slerp(QuatY(0),QuatX(120),0.3));
|
||||
module test_q_squad() {
|
||||
assert_approx(q_squad(quat_x(45),quat_z(30),quat_x(90),quat_y(30),0.0),quat_x(45));
|
||||
assert_approx(q_squad(quat_x(45),quat_z(30),quat_x(90),quat_y(30),1.0),quat_y(30));
|
||||
assert_approx(q_squad(quat_x(0),quat_x(30),quat_x(90),quat_x(120),0.5),
|
||||
q_slerp(quat_x(0),quat_x(120),0.5));
|
||||
assert_approx(q_squad(quat_y(0),quat_y(0),quat_x(120),quat_x(120),0.3),
|
||||
q_slerp(quat_y(0),quat_x(120),0.3));
|
||||
}
|
||||
test_Q_Squad();
|
||||
test_q_squad();
|
||||
|
||||
|
||||
module test_Q_exp() {
|
||||
verify_f(Q_exp(Q_Ident()), exp(1)*Q_Ident());
|
||||
verify_f(Q_exp([0,0,0,33.7]), exp(33.7)*Q_Ident());
|
||||
verify_f(Q_exp(Q_ln(Q_Ident())), Q_Ident());
|
||||
verify_f(Q_exp(Q_ln([1,2,3,0])), [1,2,3,0]);
|
||||
verify_f(Q_exp(Q_ln(QuatXYZ([31,27,34]))), QuatXYZ([31,27,34]));
|
||||
let(q=QuatXYZ([12,23,34]))
|
||||
verify_f(Q_exp(q+Q_Inverse(q)),Q_Mul(Q_exp(q),Q_exp(Q_Inverse(q))));
|
||||
module test_q_exp() {
|
||||
assert_approx(q_exp(q_ident()), exp(1)*q_ident());
|
||||
assert_approx(q_exp([0,0,0,33.7]), exp(33.7)*q_ident());
|
||||
assert_approx(q_exp(q_ln(q_ident())), q_ident());
|
||||
assert_approx(q_exp(q_ln([1,2,3,0])), [1,2,3,0]);
|
||||
assert_approx(q_exp(q_ln(quat_xyz([31,27,34]))), quat_xyz([31,27,34]));
|
||||
let(q=quat_xyz([12,23,34]))
|
||||
assert_approx(q_exp(q+q_inverse(q)),q_mul(q_exp(q),q_exp(q_inverse(q))));
|
||||
|
||||
}
|
||||
test_Q_exp();
|
||||
test_q_exp();
|
||||
|
||||
|
||||
module test_Q_ln() {
|
||||
verify_f(Q_ln([1,2,3,0]), [24.0535117721, 48.1070235442, 72.1605353164, 1.31952866481]);
|
||||
verify_f(Q_ln(Q_Ident()), [0,0,0,0]);
|
||||
verify_f(Q_ln(5.5*Q_Ident()), [0,0,0,ln(5.5)]);
|
||||
verify_f(Q_ln(Q_exp(QuatXYZ([13,37,43]))), QuatXYZ([13,37,43]));
|
||||
verify_f(Q_ln(QuatXYZ([12,23,34]))+Q_ln(Q_Inverse(QuatXYZ([12,23,34]))), [0,0,0,0]);
|
||||
module test_q_ln() {
|
||||
assert_approx(q_ln([1,2,3,0]), [24.0535117721, 48.1070235442, 72.1605353164, 1.31952866481]);
|
||||
assert_approx(q_ln(q_ident()), [0,0,0,0]);
|
||||
assert_approx(q_ln(5.5*q_ident()), [0,0,0,ln(5.5)]);
|
||||
assert_approx(q_ln(q_exp(quat_xyz([13,37,43]))), quat_xyz([13,37,43]));
|
||||
assert_approx(q_ln(quat_xyz([12,23,34]))+q_ln(q_inverse(quat_xyz([12,23,34]))), [0,0,0,0]);
|
||||
}
|
||||
test_Q_ln();
|
||||
test_q_ln();
|
||||
|
||||
|
||||
module test_Q_pow() {
|
||||
q = Quat([1,2,3],77);
|
||||
verify_f(Q_pow(q,1), q);
|
||||
verify_f(Q_pow(q,0), Q_Ident());
|
||||
verify_f(Q_pow(q,-1), Q_Inverse(q));
|
||||
verify_f(Q_pow(q,2), Q_Mul(q,q));
|
||||
verify_f(Q_pow(q,3), Q_Mul(q,Q_pow(q,2)));
|
||||
verify_f(Q_Mul(Q_pow(q,0.456),Q_pow(q,0.544)), q);
|
||||
verify_f(Q_Mul(Q_pow(q,0.335),Q_Mul(Q_pow(q,.552),Q_pow(q,.113))), q);
|
||||
module test_q_pow() {
|
||||
q = quat([1,2,3],77);
|
||||
assert_approx(q_pow(q,1), q);
|
||||
assert_approx(q_pow(q,0), q_ident());
|
||||
assert_approx(q_pow(q,-1), q_inverse(q));
|
||||
assert_approx(q_pow(q,2), q_mul(q,q));
|
||||
assert_approx(q_pow(q,3), q_mul(q,q_pow(q,2)));
|
||||
assert_approx(q_mul(q_pow(q,0.456),q_pow(q,0.544)), q);
|
||||
assert_approx(q_mul(q_pow(q,0.335),q_mul(q_pow(q,.552),q_pow(q,.113))), q);
|
||||
}
|
||||
test_Q_pow();
|
||||
test_q_pow();
|
||||
|
||||
|
||||
|
||||
|
@@ -9,17 +9,17 @@ module test_prismoid() {
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,anchor=BOT), [[[20,25,50],[20,-25,50],[-20,-25,50],[-20,25,50],[50,40,0],[50,-40,0],[-50,-40,0],[-50,40,0]],[[0,1,2],[0,2,3],[0,4,5],[0,5,1],[1,5,6],[1,6,2],[2,6,7],[2,7,3],[3,7,4],[3,4,0],[4,7,6],[4,6,5]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,anchor=TOP+RIGHT), [[[0,25,0],[0,-25,0],[-40,-25,0],[-40,25,0],[30,40,-50],[30,-40,-50],[-70,-40,-50],[-70,40,-50]],[[0,1,2],[0,2,3],[0,4,5],[0,5,1],[1,5,6],[1,6,2],[2,6,7],[2,7,3],[3,7,4],[3,4,0],[4,7,6],[4,6,5]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5]), [[[30,30,50],[30,-20,50],[-10,-20,50],[-10,30,50],[50,40,0],[50,-40,0],[-50,-40,0],[-50,40,0]],[[0,1,2],[0,2,3],[0,4,5],[0,5,1],[1,5,6],[1,6,2],[2,6,7],[2,7,3],[3,7,4],[3,4,0],[4,7,6],[4,6,5]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],chamfer=5), [[[50,-35,0],[45,-40,0],[-45,-40,0],[-50,-35,0],[-50,35,0],[-45,40,0],[45,40,0],[50,35,0],[30,-15,50],[25,-20,50],[-5,-20,50],[-10,-15,50],[-10,25,50],[-5,30,50],[25,30,50],[30,25,50]],[[4,1,0],[1,4,2],[2,4,3],[4,0,5],[14,5,6],[5,0,6],[14,6,7],[6,0,7],[0,1,8],[7,0,8],[1,2,9],[8,1,9],[14,8,9],[2,3,10],[9,2,10],[14,9,10],[14,10,11],[3,4,11],[10,3,11],[4,5,12],[14,11,12],[11,4,12],[5,14,13],[14,12,13],[12,5,13],[14,7,15],[7,8,15],[8,14,15]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],chamfer1=5),[[[50,-35,0],[45,-40,0],[-45,-40,0],[-50,-35,0],[-50,35,0],[-45,40,0],[45,40,0],[50,35,0],[30,-20,50],[-10,-20,50],[-10,30,50],[30,30,50]],[[4,1,0],[1,4,2],[2,4,3],[4,0,5],[11,5,6],[5,0,6],[0,11,7],[11,6,7],[6,0,7],[11,0,8],[0,1,8],[1,2,8],[3,4,9],[2,3,9],[8,2,9],[11,8,9],[4,5,10],[5,11,10],[11,9,10],[9,4,10]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],chamfer2=5), [[[50,-40,0],[-50,-40,0],[-50,40,0],[50,40,0],[30,-15,50],[25,-20,50],[-5,-20,50],[-10,-15,50],[-10,25,50],[-5,30,50],[25,30,50],[30,25,50]],[[2,1,0],[10,2,3],[2,0,3],[3,0,4],[10,4,5],[0,1,5],[4,0,5],[10,5,6],[5,1,6],[1,2,7],[6,1,7],[10,6,7],[10,7,8],[7,2,8],[2,10,9],[10,8,9],[8,2,9],[10,3,11],[3,4,11],[4,10,11]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],chamfer1=5,chamfer2=10), [[[50,-35,0],[45,-40,0],[-45,-40,0],[-50,-35,0],[-50,35,0],[-45,40,0],[45,40,0],[50,35,0],[30,-10,50],[20,-20,50],[0,-20,50],[-10,-10,50],[-10,20,50],[0,30,50],[20,30,50],[30,20,50]],[[4,1,0],[1,4,2],[2,4,3],[4,0,5],[14,5,6],[5,0,6],[14,6,7],[6,0,7],[0,1,8],[7,0,8],[1,2,9],[8,1,9],[14,8,9],[2,3,10],[9,2,10],[14,9,10],[14,10,11],[3,4,11],[10,3,11],[4,5,12],[14,11,12],[11,4,12],[5,14,13],[14,12,13],[12,5,13],[14,7,15],[7,8,15],[8,14,15]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],rounding=5), [[[50,-35,0],[49.8296291314,-36.2940952255,0],[49.3301270189,-37.5,0],[48.5355339059,-38.5355339059,0],[47.5,-39.3301270189,0],[46.2940952255,-39.8296291314,0],[45,-40,0],[-45,-40,0],[-46.2940952255,-39.8296291314,0],[-47.5,-39.3301270189,0],[-48.5355339059,-38.5355339059,0],[-49.3301270189,-37.5,0],[-49.8296291314,-36.2940952255,0],[-50,-35,0],[-50,35,0],[-49.8296291314,36.2940952255,0],[-49.3301270189,37.5,0],[-48.5355339059,38.5355339059,0],[-47.5,39.3301270189,0],[-46.2940952255,39.8296291314,0],[-45,40,0],[45,40,0],[46.2940952255,39.8296291314,0],[47.5,39.3301270189,0],[48.5355339059,38.5355339059,0],[49.3301270189,37.5,0],[49.8296291314,36.2940952255,0],[50,35,0],[30,-15,50],[29.8296291314,-16.2940952255,50],[29.3301270189,-17.5,50],[28.5355339059,-18.5355339059,50],[27.5,-19.3301270189,50],[26.2940952255,-19.8296291314,50],[25,-20,50],[-5,-20,50],[-6.29409522551,-19.8296291314,50],[-7.5,-19.3301270189,50],[-8.53553390593,-18.5355339059,50],[-9.33012701892,-17.5,50],[-9.82962913145,-16.2940952255,50],[-10,-15,50],[-10,25,50],[-9.82962913145,26.2940952255,50],[-9.33012701892,27.5,50],[-8.53553390593,28.5355339059,50],[-7.5,29.3301270189,50],[-6.29409522551,29.8296291314,50],[-5,30,50],[25,30,50],[26.2940952255,29.8296291314,50],[27.5,29.3301270189,50],[28.5355339059,28.5355339059,50],[29.3301270189,27.5,50],[29.8296291314,26.2940952255,50],[30,25,50]],[[16,1,0],[1,16,2],[2,16,3],[3,16,4],[4,16,5],[5,16,6],[6,16,7],[7,16,8],[8,16,9],[9,16,10],[10,16,11],[11,16,12],[12,16,13],[13,16,14],[14,16,15],[16,0,17],[17,0,18],[18,0,19],[19,0,20],[20,0,21],[21,0,22],[51,22,23],[22,0,23],[51,23,24],[23,0,24],[24,0,25],[25,0,26],[26,0,27],[0,1,28],[27,0,28],[1,2,29],[28,1,29],[51,28,29],[2,3,30],[29,2,30],[51,29,30],[3,4,31],[30,3,31],[51,30,31],[4,5,32],[31,4,32],[51,31,32],[5,6,33],[32,5,33],[51,32,33],[51,33,34],[6,7,34],[33,6,34],[51,34,35],[7,8,35],[34,7,35],[51,35,36],[8,9,36],[35,8,36],[51,36,37],[9,10,37],[36,9,37],[51,37,38],[10,11,38],[37,10,38],[51,38,39],[11,12,39],[38,11,39],[51,39,40],[12,13,40],[39,12,40],[51,40,41],[13,14,41],[40,13,41],[51,41,42],[14,15,42],[41,14,42],[51,42,43],[15,16,43],[42,15,43],[51,43,44],[16,17,44],[43,16,44],[17,18,45],[44,17,45],[51,44,45],[18,19,46],[45,18,46],[51,45,46],[19,20,47],[46,19,47],[51,46,47],[20,21,48],[47,20,48],[51,47,48],[21,22,49],[51,48,49],[48,21,49],[22,51,50],[51,49,50],[49,22,50],[51,24,52],[24,25,52],[28,51,52],[25,26,53],[52,25,53],[28,52,53],[26,27,54],[53,26,54],[28,53,54],[27,28,55],[28,54,55],[54,27,55]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],rounding1=5), [[[50,-35,0],[49.8296291314,-36.2940952255,0],[49.3301270189,-37.5,0],[48.5355339059,-38.5355339059,0],[47.5,-39.3301270189,0],[46.2940952255,-39.8296291314,0],[45,-40,0],[-45,-40,0],[-46.2940952255,-39.8296291314,0],[-47.5,-39.3301270189,0],[-48.5355339059,-38.5355339059,0],[-49.3301270189,-37.5,0],[-49.8296291314,-36.2940952255,0],[-50,-35,0],[-50,35,0],[-49.8296291314,36.2940952255,0],[-49.3301270189,37.5,0],[-48.5355339059,38.5355339059,0],[-47.5,39.3301270189,0],[-46.2940952255,39.8296291314,0],[-45,40,0],[45,40,0],[46.2940952255,39.8296291314,0],[47.5,39.3301270189,0],[48.5355339059,38.5355339059,0],[49.3301270189,37.5,0],[49.8296291314,36.2940952255,0],[50,35,0],[30,-20,50],[-10,-20,50],[-10,30,50],[30,30,50]],[[16,1,0],[1,16,2],[2,16,3],[3,16,4],[4,16,5],[5,16,6],[6,16,7],[7,16,8],[8,16,9],[9,16,10],[10,16,11],[11,16,12],[12,16,13],[13,16,14],[14,16,15],[16,0,17],[17,0,18],[18,0,19],[19,0,20],[31,20,21],[20,0,21],[31,21,22],[21,0,22],[31,22,23],[22,0,23],[31,23,24],[23,0,24],[31,24,25],[24,0,25],[31,25,26],[25,0,26],[0,31,27],[31,26,27],[26,0,27],[31,0,28],[0,1,28],[1,2,28],[2,3,28],[3,4,28],[4,5,28],[5,6,28],[6,7,28],[13,14,29],[7,8,29],[28,7,29],[8,9,29],[9,10,29],[10,11,29],[11,12,29],[12,13,29],[31,28,29],[17,18,30],[18,19,30],[19,20,30],[20,31,30],[15,16,30],[14,15,30],[29,14,30],[16,17,30],[31,29,30]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],rounding2=5), [[[50,-40,0],[-50,-40,0],[-50,40,0],[50,40,0],[30,-15,50],[29.8296291314,-16.2940952255,50],[29.3301270189,-17.5,50],[28.5355339059,-18.5355339059,50],[27.5,-19.3301270189,50],[26.2940952255,-19.8296291314,50],[25,-20,50],[-5,-20,50],[-6.29409522551,-19.8296291314,50],[-7.5,-19.3301270189,50],[-8.53553390593,-18.5355339059,50],[-9.33012701892,-17.5,50],[-9.82962913145,-16.2940952255,50],[-10,-15,50],[-10,25,50],[-9.82962913145,26.2940952255,50],[-9.33012701892,27.5,50],[-8.53553390593,28.5355339059,50],[-7.5,29.3301270189,50],[-6.29409522551,29.8296291314,50],[-5,30,50],[25,30,50],[26.2940952255,29.8296291314,50],[27.5,29.3301270189,50],[28.5355339059,28.5355339059,50],[29.3301270189,27.5,50],[29.8296291314,26.2940952255,50],[30,25,50]],[[2,1,0],[2,0,3],[3,0,4],[28,4,5],[4,0,5],[28,5,6],[5,0,6],[28,6,7],[6,0,7],[28,7,8],[7,0,8],[28,8,9],[8,0,9],[28,9,10],[0,1,10],[9,0,10],[10,1,11],[28,10,11],[11,1,12],[28,11,12],[12,1,13],[28,12,13],[13,1,14],[28,13,14],[14,1,15],[28,14,15],[15,1,16],[28,15,16],[1,2,17],[16,1,17],[28,16,17],[28,17,18],[17,2,18],[28,18,19],[18,2,19],[28,19,20],[19,2,20],[28,20,21],[20,2,21],[28,21,22],[21,2,22],[22,2,23],[28,22,23],[2,3,24],[23,2,24],[28,23,24],[28,24,25],[24,3,25],[28,25,26],[25,3,26],[3,28,27],[28,26,27],[26,3,27],[28,3,29],[4,28,29],[4,29,30],[29,3,30],[3,4,31],[4,30,31],[30,3,31]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],rounding1=5,rounding2=10), [[[50,-35,0],[49.8296291314,-36.2940952255,0],[49.3301270189,-37.5,0],[48.5355339059,-38.5355339059,0],[47.5,-39.3301270189,0],[46.2940952255,-39.8296291314,0],[45,-40,0],[-45,-40,0],[-46.2940952255,-39.8296291314,0],[-47.5,-39.3301270189,0],[-48.5355339059,-38.5355339059,0],[-49.3301270189,-37.5,0],[-49.8296291314,-36.2940952255,0],[-50,-35,0],[-50,35,0],[-49.8296291314,36.2940952255,0],[-49.3301270189,37.5,0],[-48.5355339059,38.5355339059,0],[-47.5,39.3301270189,0],[-46.2940952255,39.8296291314,0],[-45,40,0],[45,40,0],[46.2940952255,39.8296291314,0],[47.5,39.3301270189,0],[48.5355339059,38.5355339059,0],[49.3301270189,37.5,0],[49.8296291314,36.2940952255,0],[50,35,0],[30,-10,50],[29.6592582629,-12.588190451,50],[28.6602540378,-15,50],[27.0710678119,-17.0710678119,50],[25,-18.6602540378,50],[22.588190451,-19.6592582629,50],[20,-20,50],[0,-20,50],[-2.58819045103,-19.6592582629,50],[-5,-18.6602540378,50],[-7.07106781187,-17.0710678119,50],[-8.66025403784,-15,50],[-9.65925826289,-12.588190451,50],[-10,-10,50],[-10,20,50],[-9.65925826289,22.588190451,50],[-8.66025403784,25,50],[-7.07106781187,27.0710678119,50],[-5,28.6602540378,50],[-2.58819045103,29.6592582629,50],[0,30,50],[20,30,50],[22.588190451,29.6592582629,50],[25,28.6602540378,50],[27.0710678119,27.0710678119,50],[28.6602540378,25,50],[29.6592582629,22.588190451,50],[30,20,50]],[[16,1,0],[1,16,2],[2,16,3],[3,16,4],[4,16,5],[5,16,6],[6,16,7],[7,16,8],[8,16,9],[9,16,10],[10,16,11],[11,16,12],[12,16,13],[13,16,14],[14,16,15],[16,0,17],[17,0,18],[18,0,19],[19,0,20],[20,0,21],[21,0,22],[51,22,23],[22,0,23],[51,23,24],[23,0,24],[24,0,25],[25,0,26],[26,0,27],[0,1,28],[27,0,28],[1,2,29],[28,1,29],[51,28,29],[2,3,30],[29,2,30],[51,29,30],[3,4,31],[30,3,31],[51,30,31],[4,5,32],[31,4,32],[51,31,32],[5,6,33],[32,5,33],[51,32,33],[51,33,34],[6,7,34],[33,6,34],[51,34,35],[7,8,35],[34,7,35],[51,35,36],[8,9,36],[35,8,36],[51,36,37],[9,10,37],[36,9,37],[51,37,38],[10,11,38],[37,10,38],[51,38,39],[11,12,39],[38,11,39],[51,39,40],[12,13,40],[39,12,40],[51,40,41],[13,14,41],[40,13,41],[51,41,42],[14,15,42],[41,14,42],[51,42,43],[15,16,43],[42,15,43],[51,43,44],[16,17,44],[43,16,44],[51,44,45],[17,18,45],[44,17,45],[51,45,46],[18,19,46],[45,18,46],[19,20,47],[46,19,47],[51,46,47],[20,21,48],[47,20,48],[51,47,48],[21,22,49],[51,48,49],[48,21,49],[22,51,50],[51,49,50],[49,22,50],[51,24,52],[24,25,52],[28,51,52],[25,26,53],[52,25,53],[28,52,53],[26,27,54],[53,26,54],[28,53,54],[27,28,55],[28,54,55],[54,27,55]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],rounding1=5,chamfer2=10), [[[50,-35,0],[49.8296291314,-36.2940952255,0],[49.3301270189,-37.5,0],[48.5355339059,-38.5355339059,0],[47.5,-39.3301270189,0],[46.2940952255,-39.8296291314,0],[45,-40,0],[-45,-40,0],[-46.2940952255,-39.8296291314,0],[-47.5,-39.3301270189,0],[-48.5355339059,-38.5355339059,0],[-49.3301270189,-37.5,0],[-49.8296291314,-36.2940952255,0],[-50,-35,0],[-50,35,0],[-49.8296291314,36.2940952255,0],[-49.3301270189,37.5,0],[-48.5355339059,38.5355339059,0],[-47.5,39.3301270189,0],[-46.2940952255,39.8296291314,0],[-45,40,0],[45,40,0],[46.2940952255,39.8296291314,0],[47.5,39.3301270189,0],[48.5355339059,38.5355339059,0],[49.3301270189,37.5,0],[49.8296291314,36.2940952255,0],[50,35,0],[30,-10,50],[20,-20,50],[0,-20,50],[-10,-10,50],[-10,20,50],[0,30,50],[20,30,50],[30,20,50]],[[0,16,9],[28,0,1],[0,9,1],[28,1,2],[1,9,2],[28,2,3],[2,9,3],[3,9,4],[4,9,5],[5,9,6],[6,9,7],[7,9,8],[9,16,10],[10,16,11],[11,16,12],[12,16,13],[13,16,14],[14,16,15],[16,0,17],[17,0,18],[18,0,19],[19,0,20],[20,0,21],[21,0,22],[22,0,23],[23,0,24],[24,0,25],[25,0,26],[0,28,27],[26,0,27],[28,3,29],[3,4,29],[4,5,29],[5,6,29],[6,7,29],[8,9,30],[7,8,30],[29,7,30],[9,10,30],[28,29,30],[28,30,31],[10,11,31],[30,10,31],[11,12,31],[12,13,31],[13,14,31],[28,31,32],[15,16,32],[14,15,32],[31,14,32],[16,17,32],[20,21,33],[28,32,33],[19,20,33],[17,18,33],[32,17,33],[18,19,33],[23,24,34],[28,33,34],[21,22,34],[33,21,34],[22,23,34],[26,27,35],[27,28,35],[25,26,35],[28,34,35],[24,25,35],[34,24,35]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],chamfer=[0,5,10,15]), [[[50,-25,0],[35,-40,0],[-40,-40,0],[-50,-30,0],[-50,35,0],[-45,40,0],[50,40,0],[30,-5,50],[15,-20,50],[0,-20,50],[-10,-10,50],[-10,25,50],[-5,30,50],[30,30,50]],[[4,1,0],[1,4,2],[2,4,3],[4,0,5],[0,13,6],[13,5,6],[5,0,6],[13,0,7],[0,1,7],[1,2,8],[7,1,8],[13,7,8],[13,8,9],[2,3,9],[8,2,9],[13,9,10],[3,4,10],[9,3,10],[4,5,11],[13,10,11],[10,4,11],[5,13,12],[13,11,12],[11,5,12]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],chamfer1=[15,10,5,0], rounding2=[0,5,10,15]), [[[50,-40,0],[-45,-40,0],[-50,-35,0],[-50,30,0],[-40,40,0],[35,40,0],[50,25,0],[30,-5,50],[29.4888873943,-8.88228567654,50],[27.9903810568,-12.5,50],[25.6066017178,-15.6066017178,50],[22.5,-17.9903810568,50],[18.8822856765,-19.4888873943,50],[15,-20,50],[0,-20,50],[-2.58819045103,-19.6592582629,50],[-5,-18.6602540378,50],[-7.07106781187,-17.0710678119,50],[-8.66025403784,-15,50],[-9.65925826289,-12.588190451,50],[-10,-10,50],[-10,25,50],[-9.82962913145,26.2940952255,50],[-9.33012701892,27.5,50],[-8.53553390593,28.5355339059,50],[-7.5,29.3301270189,50],[-6.29409522551,29.8296291314,50],[-5,30,50],[30,30,50]],[[3,1,0],[1,3,2],[3,0,4],[28,4,5],[4,0,5],[0,28,6],[28,5,6],[5,0,6],[28,0,7],[7,0,8],[28,7,8],[28,8,9],[8,0,9],[28,9,10],[9,0,10],[28,10,11],[10,0,11],[28,11,12],[11,0,12],[28,12,13],[0,1,13],[12,0,13],[28,13,14],[13,1,14],[28,14,15],[14,1,15],[28,15,16],[15,1,16],[28,16,17],[1,2,17],[16,1,17],[28,17,18],[17,2,18],[28,18,19],[18,2,19],[28,19,20],[2,3,20],[19,2,20],[28,20,21],[20,3,21],[21,3,22],[28,21,22],[22,3,23],[28,22,23],[3,4,24],[23,3,24],[28,23,24],[28,24,25],[24,4,25],[28,25,26],[25,4,26],[4,28,27],[28,26,27],[26,4,27]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],chamfer=5), [[[50,-35,0],[45,-40,0],[-45,-40,0],[-50,-35,0],[-50,35,0],[-45,40,0],[45,40,0],[50,35,0],[30,-15,50],[25,-20,50],[-5,-20,50],[-10,-15,50],[-10,25,50],[-5,30,50],[25,30,50],[30,25,50]],[[14,7,15],[7,8,15],[8,14,15],[5,14,13],[14,12,13],[12,5,13],[14,11,12],[11,4,12],[4,5,12],[14,10,11],[3,4,11],[10,3,11],[2,3,10],[9,2,10],[14,9,10],[14,8,9],[1,2,9],[8,1,9],[7,0,8],[0,1,8],[14,6,7],[6,0,7],[14,5,6],[5,0,6],[4,0,5],[2,4,3],[1,4,2],[4,1,0]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],chamfer1=5), [[[50,-35,0],[45,-40,0],[-45,-40,0],[-50,-35,0],[-50,35,0],[-45,40,0],[45,40,0],[50,35,0],[30,-20,50],[-10,-20,50],[-10,30,50],[30,30,50]],[[11,9,10],[9,4,10],[4,5,10],[5,11,10],[2,3,9],[8,2,9],[11,8,9],[3,4,9],[1,2,8],[11,0,8],[0,1,8],[0,11,7],[11,6,7],[6,0,7],[11,5,6],[5,0,6],[4,0,5],[2,4,3],[1,4,2],[4,1,0]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],chamfer2=5), [[[50,-40,0],[-50,-40,0],[-50,40,0],[50,40,0],[30,-15,50],[25,-20,50],[-5,-20,50],[-10,-15,50],[-10,25,50],[-5,30,50],[25,30,50],[30,25,50]],[[10,3,11],[3,4,11],[4,10,11],[2,10,9],[10,8,9],[8,2,9],[10,7,8],[7,2,8],[1,2,7],[6,1,7],[10,6,7],[10,5,6],[5,1,6],[10,4,5],[0,1,5],[4,0,5],[3,0,4],[10,2,3],[2,0,3],[2,1,0]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],chamfer1=5,chamfer2=10), [[[50,-35,0],[45,-40,0],[-45,-40,0],[-50,-35,0],[-50,35,0],[-45,40,0],[45,40,0],[50,35,0],[30,-10,50],[20,-20,50],[0,-20,50],[-10,-10,50],[-10,20,50],[0,30,50],[20,30,50],[30,20,50]],[[14,7,15],[7,8,15],[8,14,15],[5,14,13],[14,12,13],[12,5,13],[14,11,12],[11,4,12],[4,5,12],[14,10,11],[3,4,11],[10,3,11],[2,3,10],[9,2,10],[14,9,10],[14,8,9],[1,2,9],[8,1,9],[7,0,8],[0,1,8],[14,6,7],[6,0,7],[14,5,6],[5,0,6],[4,0,5],[2,4,3],[1,4,2],[4,1,0]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],rounding=5), [[[50,-35,0],[49.8296291314,-36.2940952255,0],[49.3301270189,-37.5,0],[48.5355339059,-38.5355339059,0],[47.5,-39.3301270189,0],[46.2940952255,-39.8296291314,0],[45,-40,0],[-45,-40,0],[-46.2940952255,-39.8296291314,0],[-47.5,-39.3301270189,0],[-48.5355339059,-38.5355339059,0],[-49.3301270189,-37.5,0],[-49.8296291314,-36.2940952255,0],[-50,-35,0],[-50,35,0],[-49.8296291314,36.2940952255,0],[-49.3301270189,37.5,0],[-48.5355339059,38.5355339059,0],[-47.5,39.3301270189,0],[-46.2940952255,39.8296291314,0],[-45,40,0],[45,40,0],[46.2940952255,39.8296291314,0],[47.5,39.3301270189,0],[48.5355339059,38.5355339059,0],[49.3301270189,37.5,0],[49.8296291314,36.2940952255,0],[50,35,0],[30,-15,50],[29.8296291314,-16.2940952255,50],[29.3301270189,-17.5,50],[28.5355339059,-18.5355339059,50],[27.5,-19.3301270189,50],[26.2940952255,-19.8296291314,50],[25,-20,50],[-5,-20,50],[-6.29409522551,-19.8296291314,50],[-7.5,-19.3301270189,50],[-8.53553390593,-18.5355339059,50],[-9.33012701892,-17.5,50],[-9.82962913145,-16.2940952255,50],[-10,-15,50],[-10,25,50],[-9.82962913145,26.2940952255,50],[-9.33012701892,27.5,50],[-8.53553390593,28.5355339059,50],[-7.5,29.3301270189,50],[-6.29409522551,29.8296291314,50],[-5,30,50],[25,30,50],[26.2940952255,29.8296291314,50],[27.5,29.3301270189,50],[28.5355339059,28.5355339059,50],[29.3301270189,27.5,50],[29.8296291314,26.2940952255,50],[30,25,50]],[[27,28,55],[28,54,55],[54,27,55],[28,53,54],[26,27,54],[53,26,54],[28,52,53],[25,26,53],[52,25,53],[28,51,52],[51,24,52],[24,25,52],[22,51,50],[51,49,50],[49,22,50],[51,48,49],[48,21,49],[21,22,49],[20,21,48],[47,20,48],[51,47,48],[19,20,47],[46,19,47],[51,46,47],[51,45,46],[18,19,46],[45,18,46],[51,44,45],[17,18,45],[44,17,45],[16,17,44],[43,16,44],[51,43,44],[15,16,43],[42,15,43],[51,42,43],[14,15,42],[41,14,42],[51,41,42],[13,14,41],[40,13,41],[51,40,41],[12,13,40],[39,12,40],[51,39,40],[11,12,39],[38,11,39],[51,38,39],[10,11,38],[37,10,38],[51,37,38],[9,10,37],[36,9,37],[51,36,37],[8,9,36],[35,8,36],[51,35,36],[7,8,35],[34,7,35],[51,34,35],[6,7,34],[33,6,34],[51,33,34],[51,32,33],[5,6,33],[32,5,33],[51,31,32],[4,5,32],[31,4,32],[51,30,31],[3,4,31],[30,3,31],[51,29,30],[2,3,30],[29,2,30],[51,28,29],[1,2,29],[28,1,29],[27,0,28],[0,1,28],[26,0,27],[25,0,26],[24,0,25],[51,23,24],[23,0,24],[51,22,23],[22,0,23],[21,0,22],[20,0,21],[19,0,20],[18,0,19],[17,0,18],[16,0,17],[14,16,15],[13,16,14],[12,16,13],[11,16,12],[10,16,11],[9,16,10],[8,16,9],[7,16,8],[6,16,7],[5,16,6],[4,16,5],[3,16,4],[2,16,3],[1,16,2],[16,1,0]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],rounding1=5), [[[50,-35,0],[49.8296291314,-36.2940952255,0],[49.3301270189,-37.5,0],[48.5355339059,-38.5355339059,0],[47.5,-39.3301270189,0],[46.2940952255,-39.8296291314,0],[45,-40,0],[-45,-40,0],[-46.2940952255,-39.8296291314,0],[-47.5,-39.3301270189,0],[-48.5355339059,-38.5355339059,0],[-49.3301270189,-37.5,0],[-49.8296291314,-36.2940952255,0],[-50,-35,0],[-50,35,0],[-49.8296291314,36.2940952255,0],[-49.3301270189,37.5,0],[-48.5355339059,38.5355339059,0],[-47.5,39.3301270189,0],[-46.2940952255,39.8296291314,0],[-45,40,0],[45,40,0],[46.2940952255,39.8296291314,0],[47.5,39.3301270189,0],[48.5355339059,38.5355339059,0],[49.3301270189,37.5,0],[49.8296291314,36.2940952255,0],[50,35,0],[30,-20,50],[-10,-20,50],[-10,30,50],[30,30,50]],[[16,17,30],[31,29,30],[15,16,30],[14,15,30],[29,14,30],[19,20,30],[20,31,30],[18,19,30],[17,18,30],[12,13,29],[31,28,29],[11,12,29],[10,11,29],[9,10,29],[8,9,29],[7,8,29],[28,7,29],[13,14,29],[6,7,28],[5,6,28],[4,5,28],[3,4,28],[2,3,28],[1,2,28],[31,0,28],[0,1,28],[0,31,27],[31,26,27],[26,0,27],[31,25,26],[25,0,26],[31,24,25],[24,0,25],[31,23,24],[23,0,24],[31,22,23],[22,0,23],[31,21,22],[21,0,22],[31,20,21],[20,0,21],[19,0,20],[18,0,19],[17,0,18],[16,0,17],[14,16,15],[13,16,14],[12,16,13],[11,16,12],[10,16,11],[9,16,10],[8,16,9],[7,16,8],[6,16,7],[5,16,6],[4,16,5],[3,16,4],[2,16,3],[1,16,2],[16,1,0]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],rounding2=5), [[[50,-40,0],[-50,-40,0],[-50,40,0],[50,40,0],[30,-15,50],[29.8296291314,-16.2940952255,50],[29.3301270189,-17.5,50],[28.5355339059,-18.5355339059,50],[27.5,-19.3301270189,50],[26.2940952255,-19.8296291314,50],[25,-20,50],[-5,-20,50],[-6.29409522551,-19.8296291314,50],[-7.5,-19.3301270189,50],[-8.53553390593,-18.5355339059,50],[-9.33012701892,-17.5,50],[-9.82962913145,-16.2940952255,50],[-10,-15,50],[-10,25,50],[-9.82962913145,26.2940952255,50],[-9.33012701892,27.5,50],[-8.53553390593,28.5355339059,50],[-7.5,29.3301270189,50],[-6.29409522551,29.8296291314,50],[-5,30,50],[25,30,50],[26.2940952255,29.8296291314,50],[27.5,29.3301270189,50],[28.5355339059,28.5355339059,50],[29.3301270189,27.5,50],[29.8296291314,26.2940952255,50],[30,25,50]],[[3,4,31],[4,30,31],[30,3,31],[4,29,30],[29,3,30],[28,3,29],[4,28,29],[3,28,27],[28,26,27],[26,3,27],[28,25,26],[25,3,26],[28,24,25],[24,3,25],[2,3,24],[23,2,24],[28,23,24],[22,2,23],[28,22,23],[28,21,22],[21,2,22],[28,20,21],[20,2,21],[28,19,20],[19,2,20],[28,18,19],[18,2,19],[28,17,18],[17,2,18],[1,2,17],[16,1,17],[28,16,17],[15,1,16],[28,15,16],[14,1,15],[28,14,15],[13,1,14],[28,13,14],[12,1,13],[28,12,13],[11,1,12],[28,11,12],[10,1,11],[28,10,11],[0,1,10],[9,0,10],[28,9,10],[8,0,9],[28,8,9],[28,7,8],[7,0,8],[28,6,7],[6,0,7],[28,5,6],[5,0,6],[28,4,5],[4,0,5],[3,0,4],[2,0,3],[2,1,0]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],rounding1=5,rounding2=10), [[[50,-35,0],[49.8296291314,-36.2940952255,0],[49.3301270189,-37.5,0],[48.5355339059,-38.5355339059,0],[47.5,-39.3301270189,0],[46.2940952255,-39.8296291314,0],[45,-40,0],[-45,-40,0],[-46.2940952255,-39.8296291314,0],[-47.5,-39.3301270189,0],[-48.5355339059,-38.5355339059,0],[-49.3301270189,-37.5,0],[-49.8296291314,-36.2940952255,0],[-50,-35,0],[-50,35,0],[-49.8296291314,36.2940952255,0],[-49.3301270189,37.5,0],[-48.5355339059,38.5355339059,0],[-47.5,39.3301270189,0],[-46.2940952255,39.8296291314,0],[-45,40,0],[45,40,0],[46.2940952255,39.8296291314,0],[47.5,39.3301270189,0],[48.5355339059,38.5355339059,0],[49.3301270189,37.5,0],[49.8296291314,36.2940952255,0],[50,35,0],[30,-10,50],[29.6592582629,-12.588190451,50],[28.6602540378,-15,50],[27.0710678119,-17.0710678119,50],[25,-18.6602540378,50],[22.588190451,-19.6592582629,50],[20,-20,50],[0,-20,50],[-2.58819045103,-19.6592582629,50],[-5,-18.6602540378,50],[-7.07106781187,-17.0710678119,50],[-8.66025403784,-15,50],[-9.65925826289,-12.588190451,50],[-10,-10,50],[-10,20,50],[-9.65925826289,22.588190451,50],[-8.66025403784,25,50],[-7.07106781187,27.0710678119,50],[-5,28.6602540378,50],[-2.58819045103,29.6592582629,50],[0,30,50],[20,30,50],[22.588190451,29.6592582629,50],[25,28.6602540378,50],[27.0710678119,27.0710678119,50],[28.6602540378,25,50],[29.6592582629,22.588190451,50],[30,20,50]],[[27,28,55],[28,54,55],[54,27,55],[28,53,54],[26,27,54],[53,26,54],[28,52,53],[25,26,53],[52,25,53],[28,51,52],[51,24,52],[24,25,52],[22,51,50],[51,49,50],[49,22,50],[51,48,49],[48,21,49],[21,22,49],[20,21,48],[47,20,48],[51,47,48],[19,20,47],[46,19,47],[51,46,47],[18,19,46],[45,18,46],[51,45,46],[17,18,45],[44,17,45],[51,44,45],[16,17,44],[43,16,44],[51,43,44],[15,16,43],[42,15,43],[51,42,43],[14,15,42],[41,14,42],[51,41,42],[13,14,41],[40,13,41],[51,40,41],[12,13,40],[39,12,40],[51,39,40],[11,12,39],[38,11,39],[51,38,39],[10,11,38],[37,10,38],[51,37,38],[9,10,37],[36,9,37],[51,36,37],[8,9,36],[35,8,36],[51,35,36],[7,8,35],[34,7,35],[51,34,35],[6,7,34],[33,6,34],[51,33,34],[51,32,33],[5,6,33],[32,5,33],[51,31,32],[4,5,32],[31,4,32],[51,30,31],[3,4,31],[30,3,31],[51,29,30],[2,3,30],[29,2,30],[51,28,29],[1,2,29],[28,1,29],[27,0,28],[0,1,28],[26,0,27],[25,0,26],[24,0,25],[51,23,24],[23,0,24],[51,22,23],[22,0,23],[21,0,22],[20,0,21],[19,0,20],[18,0,19],[17,0,18],[16,0,17],[14,16,15],[13,16,14],[12,16,13],[11,16,12],[10,16,11],[9,16,10],[8,16,9],[7,16,8],[6,16,7],[5,16,6],[4,16,5],[3,16,4],[2,16,3],[1,16,2],[16,1,0]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],rounding1=5,chamfer2=10), [[[50,-35,0],[49.8296291314,-36.2940952255,0],[49.3301270189,-37.5,0],[48.5355339059,-38.5355339059,0],[47.5,-39.3301270189,0],[46.2940952255,-39.8296291314,0],[45,-40,0],[-45,-40,0],[-46.2940952255,-39.8296291314,0],[-47.5,-39.3301270189,0],[-48.5355339059,-38.5355339059,0],[-49.3301270189,-37.5,0],[-49.8296291314,-36.2940952255,0],[-50,-35,0],[-50,35,0],[-49.8296291314,36.2940952255,0],[-49.3301270189,37.5,0],[-48.5355339059,38.5355339059,0],[-47.5,39.3301270189,0],[-46.2940952255,39.8296291314,0],[-45,40,0],[45,40,0],[46.2940952255,39.8296291314,0],[47.5,39.3301270189,0],[48.5355339059,38.5355339059,0],[49.3301270189,37.5,0],[49.8296291314,36.2940952255,0],[50,35,0],[30,-10,50],[20,-20,50],[0,-20,50],[-10,-10,50],[-10,20,50],[0,30,50],[20,30,50],[30,20,50]],[[24,25,35],[34,24,35],[25,26,35],[28,34,35],[26,27,35],[27,28,35],[22,23,34],[21,22,34],[33,21,34],[28,33,34],[23,24,34],[18,19,33],[17,18,33],[32,17,33],[19,20,33],[28,32,33],[20,21,33],[16,17,32],[15,16,32],[14,15,32],[31,14,32],[28,31,32],[13,14,31],[12,13,31],[11,12,31],[10,11,31],[30,10,31],[28,30,31],[28,29,30],[9,10,30],[8,9,30],[7,8,30],[29,7,30],[6,7,29],[5,6,29],[4,5,29],[28,3,29],[3,4,29],[0,28,27],[26,0,27],[25,0,26],[24,0,25],[23,0,24],[22,0,23],[21,0,22],[20,0,21],[19,0,20],[18,0,19],[17,0,18],[16,0,17],[14,16,15],[13,16,14],[12,16,13],[11,16,12],[10,16,11],[9,16,10],[7,9,8],[6,9,7],[5,9,6],[4,9,5],[3,9,4],[28,2,3],[2,9,3],[28,1,2],[1,9,2],[28,0,1],[0,9,1],[0,16,9]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],chamfer=[0,5,10,15]), [[[50,-25,0],[35,-40,0],[-40,-40,0],[-50,-30,0],[-50,35,0],[-45,40,0],[50,40,0],[30,-5,50],[15,-20,50],[0,-20,50],[-10,-10,50],[-10,25,50],[-5,30,50],[30,30,50]],[[5,13,12],[13,11,12],[11,5,12],[13,10,11],[10,4,11],[4,5,11],[13,9,10],[3,4,10],[9,3,10],[2,3,9],[8,2,9],[13,8,9],[13,7,8],[1,2,8],[7,1,8],[13,0,7],[0,1,7],[0,13,6],[13,5,6],[5,0,6],[4,0,5],[2,4,3],[1,4,2],[4,1,0]]]);
|
||||
assert_approx(prismoid([100,80],[40,50],h=50,shift=[10,5],chamfer1=[15,10,5,0], rounding2=[0,5,10,15]), [[[50,-40,0],[-45,-40,0],[-50,-35,0],[-50,30,0],[-40,40,0],[35,40,0],[50,25,0],[30,-5,50],[29.4888873943,-8.88228567654,50],[27.9903810568,-12.5,50],[25.6066017178,-15.6066017178,50],[22.5,-17.9903810568,50],[18.8822856765,-19.4888873943,50],[15,-20,50],[0,-20,50],[-2.58819045103,-19.6592582629,50],[-5,-18.6602540378,50],[-7.07106781187,-17.0710678119,50],[-8.66025403784,-15,50],[-9.65925826289,-12.588190451,50],[-10,-10,50],[-10,25,50],[-9.82962913145,26.2940952255,50],[-9.33012701892,27.5,50],[-8.53553390593,28.5355339059,50],[-7.5,29.3301270189,50],[-6.29409522551,29.8296291314,50],[-5,30,50],[30,30,50]],[[4,28,27],[28,26,27],[26,4,27],[28,25,26],[25,4,26],[28,24,25],[24,4,25],[3,4,24],[23,3,24],[28,23,24],[22,3,23],[28,22,23],[21,3,22],[28,21,22],[28,20,21],[20,3,21],[28,19,20],[2,3,20],[19,2,20],[28,18,19],[18,2,19],[28,17,18],[17,2,18],[1,2,17],[16,1,17],[28,16,17],[15,1,16],[28,15,16],[14,1,15],[28,14,15],[13,1,14],[28,13,14],[0,1,13],[12,0,13],[28,12,13],[11,0,12],[28,11,12],[10,0,11],[28,10,11],[9,0,10],[28,9,10],[8,0,9],[28,8,9],[28,7,8],[7,0,8],[28,0,7],[0,28,6],[28,5,6],[5,0,6],[28,4,5],[4,0,5],[3,0,4],[1,3,2],[3,1,0]]]);
|
||||
}
|
||||
test_prismoid();
|
||||
|
||||
|
@@ -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