mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-01 14:00:30 +02:00
Moved trig functions to trigonometry.scad
This commit is contained in:
@@ -19,19 +19,6 @@ test_line_intersection();
|
||||
test_line_closest_point();
|
||||
//test_ray_closest_point(); // should add this type of case
|
||||
test_line_from_points();
|
||||
test_tri_calc();
|
||||
//test_hyp_opp_to_adj();
|
||||
//test_hyp_ang_to_adj();
|
||||
//test_opp_ang_to_adj();
|
||||
//test_hyp_adj_to_opp();
|
||||
//test_hyp_ang_to_opp();
|
||||
//test_adj_ang_to_opp();
|
||||
//test_adj_opp_to_hyp();
|
||||
//test_adj_ang_to_hyp();
|
||||
//test_opp_ang_to_hyp();
|
||||
//test_hyp_adj_to_ang();
|
||||
//test_hyp_opp_to_ang();
|
||||
//test_adj_opp_to_ang();
|
||||
test_plane3pt();
|
||||
test_plane3pt_indexed();
|
||||
test_plane_from_normal();
|
||||
@@ -587,68 +574,6 @@ module test_circle_point_tangents() {
|
||||
*test_circle_point_tangents();
|
||||
|
||||
|
||||
module test_tri_calc() {
|
||||
sides = rands(1,100,100,seed_value=8888);
|
||||
for (p=pair(sides,true)) {
|
||||
opp = p[0];
|
||||
adj = p[1];
|
||||
hyp = norm([opp,adj]);
|
||||
ang = acos(adj/hyp);
|
||||
ang2 = 90-ang;
|
||||
expected = [adj, opp, hyp, ang, ang2];
|
||||
assert(approx(tri_calc(adj=adj, hyp=hyp), expected));
|
||||
assert(approx(tri_calc(opp=opp, hyp=hyp), expected));
|
||||
assert(approx(tri_calc(adj=adj, opp=opp), expected));
|
||||
assert(approx(tri_calc(adj=adj, ang=ang), expected));
|
||||
assert(approx(tri_calc(opp=opp, ang=ang), expected, eps=1e-8));
|
||||
assert(approx(tri_calc(hyp=hyp, ang=ang), expected));
|
||||
assert(approx(tri_calc(adj=adj, ang2=ang2), expected));
|
||||
assert(approx(tri_calc(opp=opp, ang2=ang2), expected, eps=1e-8));
|
||||
assert(approx(tri_calc(hyp=hyp, ang2=ang2), expected));
|
||||
}
|
||||
}
|
||||
*test_tri_calc();
|
||||
|
||||
|
||||
module test_tri_functions() {
|
||||
sides = rands(1,100,100,seed_value=8181);
|
||||
for (p = pair(sides,true)) {
|
||||
adj = p.x;
|
||||
opp = p.y;
|
||||
hyp = norm([opp,adj]);
|
||||
ang = atan2(opp,adj);
|
||||
assert_approx(hyp_opp_to_adj(hyp,opp), adj);
|
||||
assert_approx(hyp_ang_to_adj(hyp,ang), adj);
|
||||
assert_approx(opp_ang_to_adj(opp,ang), adj);
|
||||
assert_approx(hyp_adj_to_opp(hyp,adj), opp);
|
||||
assert_approx(hyp_ang_to_opp(hyp,ang), opp);
|
||||
assert_approx(adj_ang_to_opp(adj,ang), opp);
|
||||
assert_approx(adj_opp_to_hyp(adj,opp), hyp);
|
||||
assert_approx(adj_ang_to_hyp(adj,ang), hyp);
|
||||
assert_approx(opp_ang_to_hyp(opp,ang), hyp);
|
||||
assert_approx(hyp_adj_to_ang(hyp,adj), ang);
|
||||
assert_approx(hyp_opp_to_ang(hyp,opp), ang);
|
||||
assert_approx(adj_opp_to_ang(adj,opp), ang);
|
||||
}
|
||||
}
|
||||
*test_tri_functions();
|
||||
|
||||
|
||||
module test_hyp_opp_to_adj() nil(); // Covered in test_tri_functions()
|
||||
module test_hyp_ang_to_adj() nil(); // Covered in test_tri_functions()
|
||||
module test_opp_ang_to_adj() nil(); // Covered in test_tri_functions()
|
||||
module test_hyp_adj_to_opp() nil(); // Covered in test_tri_functions()
|
||||
module test_hyp_ang_to_opp() nil(); // Covered in test_tri_functions()
|
||||
module test_adj_ang_to_opp() nil(); // Covered in test_tri_functions()
|
||||
module test_adj_opp_to_hyp() nil(); // Covered in test_tri_functions()
|
||||
module test_adj_ang_to_hyp() nil(); // Covered in test_tri_functions()
|
||||
module test_opp_ang_to_hyp() nil(); // Covered in test_tri_functions()
|
||||
module test_hyp_adj_to_ang() nil(); // Covered in test_tri_functions()
|
||||
module test_hyp_opp_to_ang() nil(); // Covered in test_tri_functions()
|
||||
module test_adj_opp_to_ang() nil(); // Covered in test_tri_functions()
|
||||
|
||||
|
||||
|
||||
module test_plane3pt() {
|
||||
assert_approx(plane3pt([0,0,20], [0,10,10], [0,0,0]), [1,0,0,0]);
|
||||
assert_approx(plane3pt([2,0,20], [2,10,10], [2,0,0]), [1,0,0,2]);
|
||||
|
42
tests/test_trigonometry.scad
Normal file
42
tests/test_trigonometry.scad
Normal file
@@ -0,0 +1,42 @@
|
||||
include <../std.scad>
|
||||
|
||||
|
||||
module test_tri_functions() {
|
||||
sides = rands(1,100,100,seed_value=8181);
|
||||
for (p = pair(sides,true)) {
|
||||
adj = p.x;
|
||||
opp = p.y;
|
||||
hyp = norm([opp,adj]);
|
||||
ang = atan2(opp,adj);
|
||||
|
||||
assert_approx(hyp_ang_to_adj(hyp,ang), adj);
|
||||
assert_approx(opp_ang_to_adj(opp,ang), adj);
|
||||
assert_approx(hyp_adj_to_opp(hyp,adj), opp);
|
||||
assert_approx(hyp_ang_to_opp(hyp,ang), opp);
|
||||
assert_approx(adj_ang_to_opp(adj,ang), opp);
|
||||
assert_approx(adj_opp_to_hyp(adj,opp), hyp);
|
||||
assert_approx(adj_ang_to_hyp(adj,ang), hyp);
|
||||
assert_approx(opp_ang_to_hyp(opp,ang), hyp);
|
||||
assert_approx(hyp_adj_to_ang(hyp,adj), ang);
|
||||
assert_approx(hyp_opp_to_ang(hyp,opp), ang);
|
||||
assert_approx(adj_opp_to_ang(adj,opp), ang);
|
||||
}
|
||||
}
|
||||
*test_tri_functions();
|
||||
|
||||
|
||||
module test_hyp_opp_to_adj() nil(); // Covered in test_tri_functions()
|
||||
module test_hyp_ang_to_adj() nil(); // Covered in test_tri_functions()
|
||||
module test_opp_ang_to_adj() nil(); // Covered in test_tri_functions()
|
||||
module test_hyp_adj_to_opp() nil(); // Covered in test_tri_functions()
|
||||
module test_hyp_ang_to_opp() nil(); // Covered in test_tri_functions()
|
||||
module test_adj_ang_to_opp() nil(); // Covered in test_tri_functions()
|
||||
module test_adj_opp_to_hyp() nil(); // Covered in test_tri_functions()
|
||||
module test_adj_ang_to_hyp() nil(); // Covered in test_tri_functions()
|
||||
module test_opp_ang_to_hyp() nil(); // Covered in test_tri_functions()
|
||||
module test_hyp_adj_to_ang() nil(); // Covered in test_tri_functions()
|
||||
module test_hyp_opp_to_ang() nil(); // Covered in test_tri_functions()
|
||||
module test_adj_opp_to_ang() nil(); // Covered in test_tri_functions()
|
||||
|
||||
|
||||
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
Reference in New Issue
Block a user