mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Removed affine2d_apply() and affine3d_apply()
This commit is contained in:
parent
93cdbf091d
commit
265db9fe5d
7 changed files with 17 additions and 62 deletions
45
affine.scad
45
affine.scad
|
@ -118,28 +118,6 @@ function affine2d_chain(affines, _m=undef, _i=0) =
|
|||
affine2d_chain(affines, _m=(is_undef(_m)? affines[_i] : affines[_i] * _m), _i=_i+1);
|
||||
|
||||
|
||||
// Function: affine2d_apply()
|
||||
// Usage:
|
||||
// affine2d_apply(pts, affines)
|
||||
// Description:
|
||||
// Given a list of 3x3 affine2d transformation matrices, applies them in order to the points in the point list.
|
||||
// Arguments:
|
||||
// pts = A list of 2D points to transform.
|
||||
// affines = A list of 3x3 affine2d matrices to apply, in order.
|
||||
// Example:
|
||||
// npts = affine2d_apply(
|
||||
// pts = [for (x=[0:3]) [5*x,0]],
|
||||
// affines =[
|
||||
// affine2d_scale([3,1]),
|
||||
// affine2d_rot(90),
|
||||
// affine2d_translate([5,5])
|
||||
// ]
|
||||
// ); // Returns [[5,5], [5,20], [5,35], [5,50]]
|
||||
function affine2d_apply(pts, affines) =
|
||||
let(m = affine2d_chain(affines))
|
||||
[for (p = pts) point2d(m * concat(point2d(p),[1]))];
|
||||
|
||||
|
||||
|
||||
// Section: Affine3d 4x4 Transformation Matrices
|
||||
|
||||
|
@ -399,29 +377,6 @@ function affine3d_chain(affines, _m=undef, _i=0) =
|
|||
affine3d_chain(affines, _m=(is_undef(_m)? affines[_i] : affines[_i] * _m), _i=_i+1);
|
||||
|
||||
|
||||
// Function: affine3d_apply()
|
||||
// Usage:
|
||||
// affine3d_apply(pts, affines)
|
||||
// Description:
|
||||
// Given a list of affine3d transformation matrices, applies them in order to the points in the point list.
|
||||
// Arguments:
|
||||
// pts = A list of 3D points to transform.
|
||||
// affines = A list of 4x4 matrices to apply, in order.
|
||||
// Example:
|
||||
// npts = affine3d_apply(
|
||||
// pts = [for (x=[0:3]) [5*x,0,0]],
|
||||
// affines =[
|
||||
// affine3d_scale([2,1,1]),
|
||||
// affine3d_zrot(90),
|
||||
// affine3d_translate([5,5,10])
|
||||
// ]
|
||||
// ); // Returns [[5,5,10], [5,15,10], [5,25,10], [5,35,10]]
|
||||
function affine3d_apply(pts, affines) =
|
||||
let(m = affine3d_chain(affines))
|
||||
[for (p = pts) point3d(m * concat(point3d(p),[1]))];
|
||||
|
||||
|
||||
|
||||
// Function: apply()
|
||||
// Usage: apply(transform, points)
|
||||
// Description:
|
||||
|
|
|
@ -516,7 +516,7 @@ module bevel_gear(
|
|||
),
|
||||
pp = rot(theta, cp=spiral_cp, p=[0,Rm,0]),
|
||||
ang = atan2(pp.y,pp.x)-90,
|
||||
pts = affine3d_apply(pts=profile, affines=[
|
||||
pts = apply_list(profile, [
|
||||
move([0,-p,0]),
|
||||
rot([0,ang,0]),
|
||||
rot([bevelang,0,0]),
|
||||
|
|
|
@ -772,7 +772,7 @@ module spiral_sweep(polyline, h, r, twist=360, center, anchor, spin=0, orient=UP
|
|||
dx = r*cos(a),
|
||||
dy = r*sin(a),
|
||||
dz = h * (p/steps),
|
||||
pts = affine3d_apply(
|
||||
pts = apply_list(
|
||||
polyline, [
|
||||
affine3d_xrot(90),
|
||||
affine3d_zrot(a),
|
||||
|
|
|
@ -289,7 +289,7 @@ module Qrot(q) {
|
|||
function Qrot(q,p) =
|
||||
is_undef(p)? Q_Matrix4(q) :
|
||||
is_vector(p)? Qrot(q,[p])[0] :
|
||||
affine3d_apply(p,[Q_Matrix4(q)]);
|
||||
apply(Q_Matrix4(q), p);
|
||||
|
||||
|
||||
// Module: Qrot_copies()
|
||||
|
|
|
@ -285,7 +285,7 @@ function region_faces(region, transform, reverse=false, vnf=EMPTY_VNF) =
|
|||
if (vnf != EMPTY_VNF) vnf,
|
||||
for (rgn = regions) let(
|
||||
cleaved = _cleave_simple_region(rgn),
|
||||
face = is_undef(transform)? cleaved : affine3d_apply(cleaved,[transform]),
|
||||
face = is_undef(transform)? cleaved : apply(transform,cleaved),
|
||||
faceidxs = reverse? [for (i=[len(face)-1:-1:0]) i] : [for (i=[0:1:len(face)-1]) i]
|
||||
) [face, [faceidxs]]
|
||||
],
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
BOSL_VERSION = [2,0,192];
|
||||
BOSL_VERSION = [2,0,193];
|
||||
|
||||
|
||||
// Section: BOSL Library Version Functions
|
||||
|
|
24
vnf.scad
24
vnf.scad
|
@ -197,9 +197,9 @@ function vnf_triangulate(vnf) =
|
|||
// vnf = vnf_vertex_array(
|
||||
// points=[
|
||||
// for (a=[0:5:360-EPSILON])
|
||||
// affine3d_apply(
|
||||
// circle(d=20),
|
||||
// [xrot(90), right(30), zrot(a)]
|
||||
// apply(
|
||||
// zrot(a) * right(30) * xrot(90),
|
||||
// circle(d=20)
|
||||
// )
|
||||
// ],
|
||||
// col_wrap=true, row_wrap=true, reverse=true
|
||||
|
@ -208,9 +208,9 @@ function vnf_triangulate(vnf) =
|
|||
// Example(3D): Möbius Strip. Note that `row_wrap` is not used, and the first and last profile copies are the same.
|
||||
// vnf = vnf_vertex_array(
|
||||
// points=[
|
||||
// for (a=[0:5:360]) affine3d_apply(
|
||||
// square([1,10], center=true),
|
||||
// [zrot(a/2+60), xrot(90), right(30), zrot(a)]
|
||||
// for (a=[0:5:360]) apply(
|
||||
// zrot(a) * right(30) * xrot(90) * zrot(a/2+60),
|
||||
// square([1,10], center=true)
|
||||
// )
|
||||
// ],
|
||||
// col_wrap=true, reverse=true
|
||||
|
@ -218,15 +218,15 @@ function vnf_triangulate(vnf) =
|
|||
// vnf_polyhedron(vnf);
|
||||
// Example(3D): Assembling a Polyhedron from Multiple Parts
|
||||
// wall_points = [
|
||||
// for (a = [-90:2:90]) affine3d_apply(
|
||||
// circle(d=100),
|
||||
// [scale([1-0.1*cos(a*6), 1-0.1*cos((a+90)*6), 1]), up(a)]
|
||||
// for (a = [-90:2:90]) apply(
|
||||
// up(a) * scale([1-0.1*cos(a*6),1-0.1*cos((a+90)*6),1]),
|
||||
// circle(d=100)
|
||||
// )
|
||||
// ];
|
||||
// cap = [
|
||||
// for (a = [0:0.01:1+EPSILON]) affine3d_apply(
|
||||
// wall_points[0],
|
||||
// [scale([a,a,1]), up(90-5*sin(a*360*2))]
|
||||
// for (a = [0:0.01:1+EPSILON]) apply(
|
||||
// up(90-5*sin(a*360*2)) * scale([a,a,1]),
|
||||
// wall_points[0]
|
||||
// )
|
||||
// ];
|
||||
// cap1 = [for (p=cap) down(90, p=zscale(-1, p=p))];
|
||||
|
|
Loading…
Reference in a new issue