mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-30 12:19:51 +02:00
normalized project_plane and lift_plane to match other transform
functions.
This commit is contained in:
@@ -83,15 +83,40 @@ test_xy_to_polar();
|
||||
|
||||
|
||||
module test_project_plane() {
|
||||
assert(approx(project_plane([-5,0,-5], [-10,0,-10], [0,0,0], [0,-10,-10]),[0,10*sqrt(2)/2]));
|
||||
assert(approx(project_plane([0,-5,-5], [-10,0,-10], [0,0,0], [0,-10,-10]),[6.12372, 10.6066],eps=1e-5));
|
||||
assert(approx(project_plane([[-10,0,-10], [0,0,0], [0,-10,-10]],[-5,0,-5]),[0,10*sqrt(2)/2]));
|
||||
assert(approx(project_plane([[-10,0,-10], [0,0,0], [0,-10,-10]],[0,-5,-5]),[6.12372, 10.6066],eps=1e-5));
|
||||
assert_approx(project_plane([[3,4,5],[1,3,9],[4,7,13]], [[3,4,5],[1,3,9],[5,3,2]]),[[0,0],[0,4.58257569496],[-0.911684611677,-3.27326835354]]);
|
||||
assert_approx(project_plane([[3,4,5],[1,3,9],[4,7,13]], [[3,4,5],[1,3,9],[4,7,13]]),[[0,0],[0,4.58257569496],[6.26783170528,5.89188303637]]);
|
||||
|
||||
assert_approx(project_plane([2,3,4,2], [4,2,3]),[2.33181857677,-0.502272134844]);
|
||||
assert_approx(project_plane([2,3,4,2], [[1,1,1],[0,0,0]]),[[0.430748825729,0.146123238594],[0,0]]);
|
||||
assert_approx(project_plane([2,3,4,2]),[[0.920855800833,-0.11871629875,-0.371390676354,0],[-0.11871629875,0.821925551875,-0.557086014531,-2.77555756156e-17],[0.371390676354,0.557086014531,0.742781352708,-0.371390676354],[0,0,0,1]]);
|
||||
assert_approx(project_plane([[1,1,1],[3,1,3],[1,1,4]]),[[-1/sqrt(2),1/sqrt(2),0,0],[0,0,1,-1],[1/sqrt(2),1/sqrt(2),0,-sqrt(2)],[0,0,0,1]]);
|
||||
}
|
||||
test_project_plane();
|
||||
|
||||
|
||||
module test_lift_plane() {
|
||||
assert(approx(lift_plane([0,10*sqrt(2)/2], [-10,0,-10], [0,0,0], [0,-10,-10]),[-5,0,-5]));
|
||||
assert(approx(lift_plane([6.12372, 10.6066], [-10,0,-10], [0,0,0], [0,-10,-10]),[0,-5,-5],eps=1e-5));
|
||||
assert(approx(lift_plane([[-10,0,-10], [0,0,0], [0,-10,-10]],[0,10*sqrt(2)/2]),[-5,0,-5]));
|
||||
assert(approx(lift_plane([[-10,0,-10], [0,0,0], [0,-10,-10]],[6.12372, 10.6066]),[0,-5,-5],eps=1e-5));
|
||||
|
||||
assert_approx(lift_plane([[3,4,5],[1,3,9],[4,7,13]], [[0,0],[0,4.58257569496],[6.26783170528,5.89188303637]]),[[3,4,5],[1,3,9],[4,7,13]]);
|
||||
|
||||
assert_approx(project_plane([2,3,4,2]),[[0.920855800833,-0.11871629875,-0.371390676354,0],[-0.11871629875,0.821925551875,-0.557086014531,-2.77555756156e-17],[0.371390676354,0.557086014531,0.742781352708,-0.371390676354],[0,0,0,1]]);
|
||||
assert_approx(project_plane([[1,1,1],[3,1,3],[1,1,4]]),[[-1/sqrt(2),1/sqrt(2),0,0],[0,0,1,-1],[1/sqrt(2),1/sqrt(2),0,-sqrt(2)],[0,0,0,1]]);
|
||||
|
||||
N=30;
|
||||
data2 = array_group(rands(0,10,3*N,seed=77),3);
|
||||
data3 = [for (d=data2) [d.x,d.y,d.x*3+d.y*5+2]];
|
||||
planept = select(data3,0,N-4);
|
||||
testpt = select(data3, N-3,-1);
|
||||
newdata = project_plane(planept,testpt);
|
||||
assert_approx( lift_plane(planept, newdata), testpt);
|
||||
assert_approx( lift_plane(planept, project_plane(planept, last(testpt))), last(testpt));
|
||||
assert_approx( lift_plane(planept) * project_plane(planept) , ident(4));
|
||||
assert_approx( lift_plane([1,2,3,4]) * project_plane([1,2,3,4]) , ident(4));
|
||||
assert_approx( lift_plane([[1,1,1],[3,1,3],[1,1,4]]) * project_plane([[1,1,1],[3,1,3],[1,1,4]]) , ident(4));
|
||||
|
||||
}
|
||||
test_lift_plane();
|
||||
|
||||
|
Reference in New Issue
Block a user