mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
Function name change
plane_projection >> projection_on_plane
This commit is contained in:
parent
288f203bb6
commit
2efd0ca5d0
2 changed files with 17 additions and 17 deletions
|
@ -965,9 +965,9 @@ function plane_transform(plane) =
|
||||||
rot(from=n, to=UP) * move(-cp);
|
rot(from=n, to=UP) * move(-cp);
|
||||||
|
|
||||||
|
|
||||||
// Function: plane_projection()
|
// Function: projection_on_plane()
|
||||||
// Usage:
|
// Usage:
|
||||||
// plane_projection(points);
|
// projection_on_plane(points);
|
||||||
// Description:
|
// 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
|
// 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.
|
// of the points on the plane.
|
||||||
|
@ -977,8 +977,8 @@ function plane_transform(plane) =
|
||||||
// Example(3D):
|
// Example(3D):
|
||||||
// points = move([10,20,30], p=yrot(25, p=path3d(circle(d=100))));
|
// points = move([10,20,30], p=yrot(25, p=path3d(circle(d=100))));
|
||||||
// plane = plane3pt([1,0,0],[0,1,0],[0,0,1]);
|
// plane = plane3pt([1,0,0],[0,1,0],[0,0,1]);
|
||||||
// proj = plane_projection(plane,points);
|
// proj = projection_on_plane(plane,points);
|
||||||
function plane_projection(plane, points) =
|
function projection_on_plane(plane, points) =
|
||||||
assert( _valid_plane(plane), "Invalid plane." )
|
assert( _valid_plane(plane), "Invalid plane." )
|
||||||
assert( is_path(points), "Invalid list of points or dimension." )
|
assert( is_path(points), "Invalid list of points or dimension." )
|
||||||
let(
|
let(
|
||||||
|
|
|
@ -41,7 +41,7 @@ test_plane_from_points();
|
||||||
test_plane_normal();
|
test_plane_normal();
|
||||||
//test_plane_offset();
|
//test_plane_offset();
|
||||||
//test_plane_transform();
|
//test_plane_transform();
|
||||||
test_plane_projection();
|
test_projection_on_plane();
|
||||||
//test_plane_point_nearest_origin();
|
//test_plane_point_nearest_origin();
|
||||||
test_distance_from_plane();
|
test_distance_from_plane();
|
||||||
|
|
||||||
|
@ -105,13 +105,13 @@ module test_points_on_plane() {
|
||||||
ang = rands(0,360,1)[0];
|
ang = rands(0,360,1)[0];
|
||||||
normal = rot(a=ang,p=normal0);
|
normal = rot(a=ang,p=normal0);
|
||||||
plane = [each normal, normal*dir];
|
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(prj_pts,plane));
|
||||||
assert(!points_on_plane(concat(pts,[normal-dir]),plane));
|
assert(!points_on_plane(concat(pts,[normal-dir]),plane));
|
||||||
}
|
}
|
||||||
*test_points_on_plane();
|
*test_points_on_plane();
|
||||||
|
|
||||||
module test_plane_projection(){
|
module test_projection_on_plane(){
|
||||||
ang = rands(0,360,1)[0];
|
ang = rands(0,360,1)[0];
|
||||||
dir = rands(-10,10,3);
|
dir = rands(-10,10,3);
|
||||||
normal0 = unit([1,2,3]);
|
normal0 = unit([1,2,3]);
|
||||||
|
@ -120,16 +120,16 @@ module test_plane_projection(){
|
||||||
plane = [each normal, 0];
|
plane = [each normal, 0];
|
||||||
planem = [each normal, normal*dir];
|
planem = [each normal, normal*dir];
|
||||||
pts = [for(i=[1:10]) rands(-1,1,3)];
|
pts = [for(i=[1:10]) rands(-1,1,3)];
|
||||||
assert_approx( plane_projection(plane,pts),
|
assert_approx( projection_on_plane(plane,pts),
|
||||||
plane_projection(plane,plane_projection(plane,pts)));
|
projection_on_plane(plane,projection_on_plane(plane,pts)));
|
||||||
assert_approx( plane_projection(plane,pts),
|
assert_approx( projection_on_plane(plane,pts),
|
||||||
rot(a=ang,p=plane_projection(plane0,rot(a=-ang,p=pts))));
|
rot(a=ang,p=projection_on_plane(plane0,rot(a=-ang,p=pts))));
|
||||||
assert_approx( move((-normal*dir)*normal,p=plane_projection(planem,pts)),
|
assert_approx( move((-normal*dir)*normal,p=projection_on_plane(planem,pts)),
|
||||||
plane_projection(plane,pts));
|
projection_on_plane(plane,pts));
|
||||||
assert_approx( move((normal*dir)*normal,p=plane_projection(plane,pts)),
|
assert_approx( move((normal*dir)*normal,p=projection_on_plane(plane,pts)),
|
||||||
plane_projection(planem,pts));
|
projection_on_plane(planem,pts));
|
||||||
}
|
}
|
||||||
*test_plane_projection();
|
*test_projection_on_plane();
|
||||||
|
|
||||||
module test_line_from_points() {
|
module test_line_from_points() {
|
||||||
assert_approx(line_from_points([[1,0],[0,0],[-1,0]]),[[-1,0],[1,0]]);
|
assert_approx(line_from_points([[1,0],[0,0],[-1,0]]),[[-1,0],[1,0]]);
|
||||||
|
|
Loading…
Reference in a new issue