Function name change

plane_projection >> projection_on_plane
This commit is contained in:
RonaldoCMP 2020-08-16 23:54:00 +01:00
parent 288f203bb6
commit 2efd0ca5d0
2 changed files with 17 additions and 17 deletions

View file

@ -965,9 +965,9 @@ function plane_transform(plane) =
rot(from=n, to=UP) * move(-cp);
// Function: plane_projection()
// Function: projection_on_plane()
// Usage:
// plane_projection(points);
// projection_on_plane(points);
// Description:
// Given a plane definition `[A,B,C,D]`, where `Ax+By+Cz=D`, and a list of 2d or 3d points, return the projection
// of the points on the plane.
@ -977,8 +977,8 @@ function plane_transform(plane) =
// Example(3D):
// points = move([10,20,30], p=yrot(25, p=path3d(circle(d=100))));
// plane = plane3pt([1,0,0],[0,1,0],[0,0,1]);
// proj = plane_projection(plane,points);
function plane_projection(plane, points) =
// proj = projection_on_plane(plane,points);
function projection_on_plane(plane, points) =
assert( _valid_plane(plane), "Invalid plane." )
assert( is_path(points), "Invalid list of points or dimension." )
let(

View file

@ -41,7 +41,7 @@ test_plane_from_points();
test_plane_normal();
//test_plane_offset();
//test_plane_transform();
test_plane_projection();
test_projection_on_plane();
//test_plane_point_nearest_origin();
test_distance_from_plane();
@ -105,13 +105,13 @@ module test_points_on_plane() {
ang = rands(0,360,1)[0];
normal = rot(a=ang,p=normal0);
plane = [each normal, normal*dir];
prj_pts = plane_projection(plane,pts);
prj_pts = projection_on_plane(plane,pts);
assert(points_on_plane(prj_pts,plane));
assert(!points_on_plane(concat(pts,[normal-dir]),plane));
}
*test_points_on_plane();
module test_plane_projection(){
module test_projection_on_plane(){
ang = rands(0,360,1)[0];
dir = rands(-10,10,3);
normal0 = unit([1,2,3]);
@ -120,16 +120,16 @@ module test_plane_projection(){
plane = [each normal, 0];
planem = [each normal, normal*dir];
pts = [for(i=[1:10]) rands(-1,1,3)];
assert_approx( plane_projection(plane,pts),
plane_projection(plane,plane_projection(plane,pts)));
assert_approx( plane_projection(plane,pts),
rot(a=ang,p=plane_projection(plane0,rot(a=-ang,p=pts))));
assert_approx( move((-normal*dir)*normal,p=plane_projection(planem,pts)),
plane_projection(plane,pts));
assert_approx( move((normal*dir)*normal,p=plane_projection(plane,pts)),
plane_projection(planem,pts));
assert_approx( projection_on_plane(plane,pts),
projection_on_plane(plane,projection_on_plane(plane,pts)));
assert_approx( projection_on_plane(plane,pts),
rot(a=ang,p=projection_on_plane(plane0,rot(a=-ang,p=pts))));
assert_approx( move((-normal*dir)*normal,p=projection_on_plane(planem,pts)),
projection_on_plane(plane,pts));
assert_approx( move((normal*dir)*normal,p=projection_on_plane(plane,pts)),
projection_on_plane(planem,pts));
}
*test_plane_projection();
*test_projection_on_plane();
module test_line_from_points() {
assert_approx(line_from_points([[1,0],[0,0],[-1,0]]),[[-1,0],[1,0]]);