You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// See Also: move(), right(), fwd(), back(), down(), up()
@@ -173,7 +173,7 @@ function translate(v=[0,0,0], p=_NO_ARG) = move(v=v, p=p);
173
173
// mat = left(x);
174
174
//
175
175
// Description:
176
-
// Moves geometry or data to the left (in the X- direction) by the specified amount. (If `x` is negative motion will be to the right.)
176
+
// Moves geometry or data to the left (in the X- direction) by the specified amount. (If `x` is negative motion is to the right.)
177
177
// * If called as a module, moves all children left.
178
178
// * If called as a function with the `p` argument, returns the translated version of that `p` argument. The `p` argument can be a point, list of points, [bezier patch](beziers.scad) or [VNF structure](vnf.scad).
179
179
// * If called as a function without the `p` argument, returns a 4x4 transformation matrix.
@@ -206,7 +206,7 @@ function left(x=0, p=_NO_ARG) =
// See Also: move(), left(), fwd(), back(), down(), up()
@@ -219,7 +219,7 @@ function left(x=0, p=_NO_ARG) =
219
219
// mat = right(x);
220
220
//
221
221
// Description:
222
-
// Moves geometry or data to the right (in the X+ direction) by the specified amount. (If `x` is negative motion will be to the left.)
222
+
// Moves geometry or data to the right (in the X+ direction) by the specified amount. (If `x` is negative motion is to the left.)
223
223
// * If called as a module, moves all children right.
224
224
// * If called as a function with the `p` argument, returns the translated version of that `p` argument. The `p` argument can be a point, list of points, [bezier patch](beziers.scad) or [VNF structure](vnf.scad).
225
225
// * If called as a function without the `p` argument, returns a 4x4 tranformation matrix.
@@ -264,7 +264,7 @@ function xmove(x=0, p=_NO_ARG) =
// See Also: move(), left(), right(), back(), down(), up()
@@ -277,7 +277,7 @@ function xmove(x=0, p=_NO_ARG) =
277
277
// mat = fwd(y);
278
278
//
279
279
// Description:
280
-
// Moves geometry or data forward (in the Y- direction) by the specified amount. (If `y` is negative motion will be to the back.)
280
+
// Moves geometry or data forward (in the Y- direction) by the specified amount. (If `y` is negative motion is to the back.)
281
281
// * If called as a module, moves all children forward.
282
282
// * If called as a function with the `p` argument, returns the translated version of that `p` argument. The `p` argument can be a point, list of points, [bezier patch](beziers.scad) or [VNF structure](vnf.scad).
283
283
// * If called as a function without the `p` argument, returns a 4x4 transformation matrix.
@@ -309,7 +309,7 @@ function fwd(y=0, p=_NO_ARG) =
// See Also: move(), left(), right(), fwd(), down(), up()
@@ -322,7 +322,7 @@ function fwd(y=0, p=_NO_ARG) =
322
322
// mat = back(y);
323
323
//
324
324
// Description:
325
-
// Moves geometry or data forward (in the Y+ direction) by the specified amount. (If `y` is negative motion will be forward.)
325
+
// Moves geometry or data forward (in the Y+ direction) by the specified amount. (If `y` is negative motion is forward.)
326
326
// * If called as a module, moves all children forward.
327
327
// * If called as a function with the `p` argument, returns the translated version of that `p` argument. The `p` argument can be a point, list of points, [bezier patch](beziers.scad) or [VNF structure](vnf.scad).
328
328
// * If called as a function without the `p` argument, returns a 4x4 transformation matrix.
@@ -367,7 +367,7 @@ function ymove(y=0,p=_NO_ARG) =
// See Also: move(), left(), right(), fwd(), back(), up()
@@ -380,7 +380,7 @@ function ymove(y=0,p=_NO_ARG) =
380
380
// mat = down(z);
381
381
//
382
382
// Description:
383
-
// Moves geometry or data dwon (in the Z- direction) by the specified amount. (If `z` is negative motion will be upward.)
383
+
// Moves geometry or data dwon (in the Z- direction) by the specified amount. (If `z` is negative motion is upward.)
384
384
// * If called as a module, moves all children down.
385
385
// * If called as a function with the `p` argument, returns the translated version of that `p` argument. The `p` argument can be a point, list of points, [bezier patch](beziers.scad) or [VNF structure](vnf.scad).
386
386
// * If called as a function without the `p` argument, returns a 4x4 transformation matrix.
@@ -411,7 +411,7 @@ function down(z=0, p=_NO_ARG) =
// See Also: move(), left(), right(), fwd(), back(), down()
@@ -424,7 +424,7 @@ function down(z=0, p=_NO_ARG) =
424
424
// mat = up(z);
425
425
//
426
426
// Description:
427
-
// Moves geometry or data up (in the Z+ direction) by the specified amount. (If `z` is negative motion will be downward.)
427
+
// Moves geometry or data up (in the Z+ direction) by the specified amount. (If `z` is negative motion is downward.)
428
428
// * If called as a module, moves all children up
429
429
// * If called as a function with the `p` argument, returns the translated version of that `p` argument. The `p` argument can be a point, list of points, [bezier patch](beziers.scad) or [VNF structure](vnf.scad).
430
430
// * If called as a function without the `p` argument, returns a 4x4 transformation matrix.
@@ -496,7 +496,7 @@ function zmove(z=0, p=_NO_ARG) =
496
496
// M = rot(from=, to=, [a=], [reverse=]);
497
497
//
498
498
// Description:
499
-
// This is an expanded version of the built-in `rotate()`, which behaves identically to the built-in with the same arguments,
499
+
// This is an expanded version of the built-in `rotate()` that behaves identically to the built-in with the same arguments,
500
500
// but offers additional capabilities.
501
501
// You can specify the rotation to perform in one of several ways:
502
502
// * `rot(30)` or `rot(a=30)` rotates 30 degrees around the Z axis.
@@ -505,7 +505,7 @@ function zmove(z=0, p=_NO_ARG) =
505
505
// * `rot(from=[0,0,1], to=[1,0,0])` rotates the `from` vector to line up with the `to` vector, in this case the top to the right and hence equivalent to `rot(a=90,v=[0,1,0]`. The axis of rotation is perpendicular to the two given vectors.
506
506
// * `rot(from=[0,1,1], to=[1,1,0], a=45)` rotates 45 degrees around the `from` vector ([0,1,1]) and then rotates the `from` vector to align with the `to` vector. Equivalent to `rot(from=[0,1,1],to=[1,1,0]) rot(a=45,v=[0,1,1])`. You can also regard `a` as as post-rotation around the `to` vector. For this form, `a` must be a scalar.
507
507
// * If the `cp` centerpoint argument is given, then rotations are performed around that centerpoint. So `rot(args...,cp=[1,2,3])` is equivalent to `move(-[1,2,3])rot(args...)move([1,2,3])`.
508
-
// * If the `reverse` argument is true, then the rotations performed will be exactly reversed.
508
+
// * If the `reverse` argument is true, then the rotations performed is exactly reversed.
509
509
// .
510
510
// The behavior and return value varies depending on how `rot()` is called:
// This is shorthand for `rot(from=UP,to=x)` and operates similarly. It tilts that which is pointing UP until it is pointing at the given direction vector.
731
+
// This is shorthand for `rot(from=UP,to=x)` and operates similarly. It tilts things that point UP until they point in the direction of the given `to` vector.
732
732
// * If the `cp` centerpoint argument is given, then the tilt/rotation is performed around that centerpoint. So `tilt(...,cp=[1,2,3])` is equivalent to `move([1,2,3]) tilt(...) move([-1,-2,-3])`.
733
-
// * If the `reverse` argument is true, then the tilt/rotation will be reversed.
733
+
// * If the `reverse` argument is true, then the tilt/rotation is reversed.
734
734
// .
735
735
// The behavior and return value varies depending on how `tilt()` is called:
736
736
// * Ifc called as a module, tilts all children.
@@ -786,16 +786,19 @@ function tilt(to, p=_NO_ARG, cp, reverse=false) =
786
786
// scale(SCALAR) CHILDREN;
787
787
// scale([X,Y,Z]) CHILDREN;
788
788
// Usage: As module with center point (BOSL2 extension)
789
-
// scale(v, cp) CHILDREN;
789
+
// scale(v, cp=) CHILDREN;
790
+
// Usage: As module with with scaling direction vector (BOSL2 extension)
791
+
// scale(v, dir=, [cp=]) CHILDREN;
790
792
// Usage: Scale Points
791
-
// pts = scale(v, p, [cp=]);
793
+
// pts = scale(v, p, [cp=], [dir=]);
792
794
// Usage: Get Scaling Matrix
793
-
// mat = scale(v, [cp=]);
795
+
// mat = scale(v, [cp=], [dir=]);
794
796
//
795
797
// Description:
796
798
// Scales by the [X,Y,Z] scaling factors given in `v`. If `v` is given as a scalar number, all axes are scaled uniformly by that amount.
797
799
// If `v` has fewer than three dimensions, it is padded with 1 values, so scaling by [4] is the same as [4,1,1]. If you give `cp` a
798
-
// vector value then the scaling is done relative to that specified center point.
800
+
// vector value then the scaling is done relative to that specified center point. If you give the vector `dir` then the scale factor, `v`, must
801
+
// be a scalar and the scaling occurs along the direction of `dir`. (The sign and magnitude of `dir` don't matter.)
799
802
// * If called as the built-in module, scales all children.
800
803
// * If called as a function with the `p` argument, returns the scaled version of that `p` argument. The `p` argument can be a point, list of points, [bezier patch](beziers.scad) or [VNF structure](vnf.scad).
801
804
// * If called as a function without a `p` argument, returns a 4x4 transformation matrix.
@@ -805,6 +808,7 @@ function tilt(to, p=_NO_ARG, cp, reverse=false) =
805
808
// p = (function only) A point, list of points, Bezier patch or VNF to scale.
806
809
// ---
807
810
// cp = If given, centers the scaling on the point `cp`.
811
+
// dir = If given as a vector, scale along the direction of that vector.
808
812
//
809
813
// Example(NORENDER):
810
814
// pt1 = scale(3, [3,1,4]); // Returns: [9,3,12]
@@ -817,11 +821,17 @@ function tilt(to, p=_NO_ARG, cp, reverse=false) =
817
821
// path = circle(d=50,$fn=12);
818
822
// #stroke(path,closed=true);
819
823
// stroke(scale([1.5,3],path),closed=true);
820
-
functionscale(v=1, p=_NO_ARG, cp=[0,0,0]) =
824
+
functionscale(v=1, p=_NO_ARG, cp=[0,0,0],dir) =
821
825
assert(is_num(v) || is_vector(v),"Invalid scale")
822
826
assert(p==_NO_ARG || is_list(p),"Invalid point list")
827
+
assert(is_undef(dir) || is_vector(dir),"Invalid dir vector")
823
828
assert(is_vector(cp))
824
-
let(
829
+
is_def(dir)? assert(is_num(v),"v must be a scalar when dir is given")
830
+
assert(len(dir)<=3&& norm(dir)>0, "dir must be a nonzero vector with 3 or fewer entries")
831
+
rot(from=dir,to=RIGHT,reverse=true)
832
+
* xscale(v,p=p,cp=rot(from=dir,to=RIGHT,p=cp))
833
+
* rot(from=dir,to=RIGHT)
834
+
: let(
825
835
v = is_num(v)? [v,v,v] : v,
826
836
m = cp==[0,0,0]
827
837
? affine3d_scale(v)
@@ -1250,17 +1260,18 @@ function zflip(p=_NO_ARG, z=0) =
1250
1260
// Description:
1251
1261
// Maps one coordinate frame to another. You must specify two or
1252
1262
// three of `x`, `y`, and `z`. The specified axes are mapped to the vectors you supplied, so if you
1253
-
// specify x=[1,1] then the x axis will be mapped to the line y=x. If you
1263
+
// specify x=[1,1] then the x axis is mapped to the line y=x. If you
1254
1264
// give two inputs, the third vector is mapped to the appropriate normal to maintain a right hand
1255
-
// coordinate system. If the vectors you give are orthogonal the result will be a rotation and the
1256
-
// `reverse` parameter will supply the inverse map, which enables you to map two arbitrary
1265
+
// coordinate system. If the vectors you give are orthogonal the result is a rotation and the
1266
+
// `reverse` parameter supplies the inverse map, which enables you to map two arbitrary
1257
1267
// coordinate systems to each other by using the canonical coordinate system as an intermediary.
1258
1268
// You cannot use the `reverse` option with non-orthogonal inputs. Note that only the direction
1259
-
// of the specified vectors matters: the transformation will not apply scaling, though it can
1269
+
// of the specified vectors matters: the transformation does not apply scaling, though it can
1260
1270
// skew if your provide non-orthogonal axes.
1261
1271
// .
1262
-
// You can use `frame_map()` as a module, or as a function. In the functional form, you will usually
1263
-
// need to provide the points to be transformed with the `p=` named argument, unless you give all three of `x`, `y`, and `z`.
1272
+
// You can use `frame_map()` as a module, or as a function. In the functional form, you
1273
+
// need to provide the points to be transformed with the `p=` named argument (except in the
1274
+
// less common situation where you give all three of `x`, `y`, and `z`).
1264
1275
// The functional form with no `p=` argument returns a 4x4 transformation matrix.
// * If called as a function with the `p` argument, returns the skewed version of that `p` argument. The `p` argument can be a point, list of points, [bezier patch](beziers.scad) or [VNF structure](vnf.scad).
1354
1365
// * Called as a function without a `p` argument, returns the 4x4 transformation skew matrix.
1355
1366
// .
1356
-
// Each skew factor is a multiplier. For example, if `sxy=2`, then it will skew along the X axis by 2x the value of the Y axis.
1367
+
// Each skew factor is a multiplier. For example, if `sxy=2`, then it skews along the X axis by 2x the value of the Y axis.
1357
1368
// Arguments:
1358
1369
// p = (function only) The point, path, Bezier patch, or VNF to skew.
0 commit comments