mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +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
|
@ -825,7 +825,7 @@ function plane3pt(p1, p2, p3) =
|
|||
// i3 = The index into `points` of the third point on the plane.
|
||||
function plane3pt_indexed(points, i1, i2, i3) =
|
||||
assert( is_vector([i1,i2,i3]) && min(i1,i2,i3)>=0 && is_list(points) && max(i1,i2,i3)<len(points),
|
||||
"Invalid or out of range indices." )
|
||||
"Invalid or out of range indices." )
|
||||
assert( is_path([points[i1], points[i2], points[i3]],dim=3),
|
||||
"Improper points or improper dimensions." )
|
||||
let(
|
||||
|
@ -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(
|
||||
|
|
|
@ -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]]);
|
||||
|
|
Loading…
Reference in a new issue