discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Full frontal scale markers invisible; any work around?

T
Terry
Mon, Oct 18, 2021 10:34 AM

My screenshot shows an example of a problem I frequently encounter. When I want
to visually check some distance and select Right or Left, Orthogonal views, the
Axes and Scale Markers are not displayed. Presumably because they are being
'viewed' head on. Is there any no-brainer work around please?

Image attached or here:
https://www.dropbox.com/s/7rkt7jgmjahcxc1/MissingScale.jpg?raw=1

Terry

My screenshot shows an example of a problem I frequently encounter. When I want to visually check some distance and select Right or Left, Orthogonal views, the Axes and Scale Markers are not displayed. Presumably because they are being 'viewed' head on. Is there any no-brainer work around please? Image attached or here: https://www.dropbox.com/s/7rkt7jgmjahcxc1/MissingScale.jpg?raw=1 Terry
JB
Jordan Brown
Mon, Oct 18, 2021 4:05 PM

On 10/18/2021 3:34 AM, Terry wrote:

My screenshot shows an example of a problem I frequently encounter. When I want
to visually check some distance and select Right or Left, Orthogonal views, the
Axes and Scale Markers are not displayed. Presumably because they are being
'viewed' head on. Is there any no-brainer work around please?

You could model in your own ruler.  Use % so that it's not part of the
final model.

It might be an interesting enhancement to have options for what
orientation to draw the axis markers in.  There's no intrinsic reason
why X-axis markers need to be drawn in the XY plane; they could equally
well be drawn in the XZ plane, or at an angle not aligned with either
the Y or Z axes.

One could also imagine an automatic mechanism that would rotate the
markers based on the view direction.

Similarly, there's no intrinsic reason why the markers need to be
"above" the axis; they could equally well be below it, and that would
make sense if you had a model that was predominantly on one side of the
axis.  It's hard to see how a simple automatic mechanism could work.

An automatic mechanism could probably also mirror the markers so that
you are never looking at their back side, so that they are still
readable when the X and Y axis markers are viewed from -Z, or when the Z
axis markers are viewed from -X.

On 10/18/2021 3:34 AM, Terry wrote: > My screenshot shows an example of a problem I frequently encounter. When I want > to visually check some distance and select Right or Left, Orthogonal views, the > Axes and Scale Markers are not displayed. Presumably because they are being > 'viewed' head on. Is there any no-brainer work around please? You could model in your own ruler.  Use % so that it's not part of the final model. It might be an interesting enhancement to have options for what orientation to draw the axis markers in.  There's no intrinsic reason why X-axis markers need to be drawn in the XY plane; they could equally well be drawn in the XZ plane, or at an angle not aligned with either the Y or Z axes. One could also imagine an automatic mechanism that would rotate the markers based on the view direction. Similarly, there's no intrinsic reason why the markers need to be "above" the axis; they could equally well be below it, and that would make sense if you had a model that was predominantly on one side of the axis.  It's hard to see how a simple automatic mechanism could work. An automatic mechanism could probably also mirror the markers so that you are never looking at their back side, so that they are still readable when the X and Y axis markers are viewed from -Z, or when the Z axis markers are viewed from -X.
L
larry
Mon, Oct 18, 2021 7:22 PM

On Mon, 2021-10-18 at 11:34 +0100, Terry wrote:

My screenshot shows an example of a problem I frequently encounter.
When I want to visually check some distance and select Right or Left,
Orthogonal views, the Axes and Scale Markers are not displayed.
Presumably because they are being 'viewed' head on. Is there any no-
brainer work around please?
Image attached or here:
https://www.dropbox.com/s/7rkt7jgmjahcxc1/MissingScale.jpg?raw=1

My no-brainer workaround is to left-click and rotate the view slightly.

On Mon, 2021-10-18 at 11:34 +0100, Terry wrote: > My screenshot shows an example of a problem I frequently encounter. > When I want to visually check some distance and select Right or Left, > Orthogonal views, the Axes and Scale Markers are not displayed. > Presumably because they are being 'viewed' head on. Is there any no- > brainer work around please? > Image attached or here: > https://www.dropbox.com/s/7rkt7jgmjahcxc1/MissingScale.jpg?raw=1 My no-brainer workaround is to left-click and rotate the view slightly.
RW
Rogier Wolff
Tue, Oct 19, 2021 6:22 AM

On Mon, Oct 18, 2021 at 04:05:48PM +0000, Jordan Brown wrote:

An automatic mechanism could probably also mirror the markers so that
you are never looking at their back side, so that they are still
readable when the X and Y axis markers are viewed from -Z, or when the Z
axis markers are viewed from -X.

Currently the markers are "in object space". Don't do that. Tranform
the origin to screenspace, translate axis direction to screen
space. Intersect with screen boundaries, if there are intersections,
draw the line in screen space and add tickmarks and labels in
screenspace.

This gives the impression of an overlay that always faces the viewer.

If there are no intersections with the screen, consider that the Y
axis is just x=0, z=0. Suppose I zoom in on x=105, z=10 so that x=0 is
no longer on the screen... Why not draw the x=100, z=0 line with
annotation that it's not the x=0, z=0 line?

Roger. 

--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.

On Mon, Oct 18, 2021 at 04:05:48PM +0000, Jordan Brown wrote: > An automatic mechanism could probably also mirror the markers so that > you are never looking at their back side, so that they are still > readable when the X and Y axis markers are viewed from -Z, or when the Z > axis markers are viewed from -X. Currently the markers are "in object space". Don't do that. Tranform the origin to screenspace, translate axis direction to screen space. Intersect with screen boundaries, if there are intersections, draw the line in screen space and add tickmarks and labels in screenspace. This gives the impression of an overlay that always faces the viewer. If there are no intersections with the screen, consider that the Y axis is just x=0, z=0. Suppose I zoom in on x=105, z=10 so that x=0 is no longer on the screen... Why not draw the x=100, z=0 line with annotation that it's not the x=0, z=0 line? Roger. -- ** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 ** ** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 ** f equals m times a. When your f is steady, and your m is going down your a is going up. -- Chris Hadfield about flying up the space shuttle.
JB
Jordan Brown
Tue, Oct 19, 2021 4:37 PM

I've added some of these comments to issue #3872
https://github.com/openscad/openscad/issues/3872.  Additional ideas
should probably go there.

I've added some of these comments to issue #3872 <https://github.com/openscad/openscad/issues/3872>.  Additional ideas should probably go there.
T
Terry
Wed, Oct 20, 2021 8:27 AM

On Mon, 18 Oct 2021 13:22:24 -0600, you wrote:

On Mon, 2021-10-18 at 11:34 +0100, Terry wrote:

My screenshot shows an example of a problem I frequently encounter.
When I want to visually check some distance and select Right or Left,
Orthogonal views, the Axes and Scale Markers are not displayed.
Presumably because they are being 'viewed' head on. Is there any no-
brainer work around please?
Image attached or here:
https://www.dropbox.com/s/7rkt7jgmjahcxc1/MissingScale.jpg?raw=1

My no-brainer workaround is to left-click and rotate the view slightly.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I can't get any such small rotation to display a readable scale. Could you show
me a screenshot please?

Code attached, or here:
https://www.dropbox.com/s/ohatuqot75zz8dp/TrayForCanon-HobbyServoMount-Minimal.scad?raw=1

Terry

On Mon, 18 Oct 2021 13:22:24 -0600, you wrote: >On Mon, 2021-10-18 at 11:34 +0100, Terry wrote: >> My screenshot shows an example of a problem I frequently encounter. >> When I want to visually check some distance and select Right or Left, >> Orthogonal views, the Axes and Scale Markers are not displayed. >> Presumably because they are being 'viewed' head on. Is there any no- >> brainer work around please? >> Image attached or here: >> https://www.dropbox.com/s/7rkt7jgmjahcxc1/MissingScale.jpg?raw=1 > >My no-brainer workaround is to left-click and rotate the view slightly. > >_______________________________________________ >OpenSCAD mailing list >To unsubscribe send an email to discuss-leave@lists.openscad.org I can't get any such small rotation to display a readable scale. Could you show me a screenshot please? Code attached, or here: https://www.dropbox.com/s/ohatuqot75zz8dp/TrayForCanon-HobbyServoMount-Minimal.scad?raw=1 Terry
TP
Terry Pinnell
Wed, Oct 20, 2021 8:39 AM

Just rememebered that code can simply be pasted:

difference(){
translate([0,10,0])
cube([55.5, 22, 2]);
// Two 3mm mounting holes
translate([4, 14, -1])
cylinder($fn = 64, h=4, d=3, center = false);

translate([51, 27, -1])
cylinder($fn = 64, h=4, d=3, center = false);
}

// Servo #1 right pillar, total height = 28 (1.0 inside slab)
// Translate calc: 55.5-10.0-6.0 = 39.5
translate([39.5, 10, 1])
#cube([6, 12, 28-1]);

// Identical servo #1 left pillar
// Translate calc as delta = 39.5-22.5-6.0 = 11.0
translate([11, 10, 1])
cube([6, 12, 28-1]);

// Right 'overhang' of 6.0 (incl 1.0 embed); (Must add support!)
translate([39.5, 12-1+10, 28-6])
cube([6, 5+1, 6]);

// Overhang support, servo #1 LEFT
translate([17, 27, 16])
rotate([0, 0, 180]){
intersection()
{
translate([0, 6, 0])
rotate([45, 0, 0])
cube([sqrt(72), sqrt(72), 12]);
cube([6, 7-1, 6]);
}
}

// Overhang support, servo #1 RIGHT
translate([45.5, 27, 16])
rotate([0, 0, 180]){
intersection()
{
translate([0, 6, 0])
rotate([45, 0, 0])
cube([sqrt(72), sqrt(72), 12]);
cube([6, 7-1, 6]);
}
}

// Left 'overhang' of 6.0 (incl 1.0 embed); (Must add support!)
translate([11, 12-1+10, 28-6])
cube([6, 5+1, 6]);

// Servo #2 single taller pillar; hoping this will be firm enough
// Proving difficult to get dimensions
translate([-6, 31-12, 0])
cube([6+1, 11, 70+1]);

On Wed, 20 Oct 2021 at 09:27, Terry terrypingm@gmail.com wrote:

On Mon, 18 Oct 2021 13:22:24 -0600, you wrote:

On Mon, 2021-10-18 at 11:34 +0100, Terry wrote:

My screenshot shows an example of a problem I frequently encounter.
When I want to visually check some distance and select Right or Left,
Orthogonal views, the Axes and Scale Markers are not displayed.
Presumably because they are being 'viewed' head on. Is there any no-
brainer work around please?
Image attached or here:
https://www.dropbox.com/s/7rkt7jgmjahcxc1/MissingScale.jpg?raw=1

My no-brainer workaround is to left-click and rotate the view slightly.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I can't get any such small rotation to display a readable scale. Could you
show
me a screenshot please?

Code attached, or here:

https://www.dropbox.com/s/ohatuqot75zz8dp/TrayForCanon-HobbyServoMount-Minimal.scad?raw=1

Terry

--
LargePrefPlaceholder-XKUz1MEJBwkOM

Just rememebered that code can simply be pasted: ==================== difference(){ translate([0,10,0]) cube([55.5, 22, 2]); // Two 3mm mounting holes translate([4, 14, -1]) cylinder($fn = 64, h=4, d=3, center = false); translate([51, 27, -1]) cylinder($fn = 64, h=4, d=3, center = false); } // Servo #1 right pillar, total height = 28 (1.0 inside slab) // Translate calc: 55.5-10.0-6.0 = 39.5 translate([39.5, 10, 1]) #cube([6, 12, 28-1]); // Identical servo #1 left pillar // Translate calc as delta = 39.5-22.5-6.0 = 11.0 translate([11, 10, 1]) cube([6, 12, 28-1]); // Right 'overhang' of 6.0 (incl 1.0 embed); (Must add support!) translate([39.5, 12-1+10, 28-6]) cube([6, 5+1, 6]); // Overhang support, servo #1 LEFT translate([17, 27, 16]) rotate([0, 0, 180]){ intersection() { translate([0, 6, 0]) rotate([45, 0, 0]) cube([sqrt(72), sqrt(72), 12]); cube([6, 7-1, 6]); } } // Overhang support, servo #1 RIGHT translate([45.5, 27, 16]) rotate([0, 0, 180]){ intersection() { translate([0, 6, 0]) rotate([45, 0, 0]) cube([sqrt(72), sqrt(72), 12]); cube([6, 7-1, 6]); } } // Left 'overhang' of 6.0 (incl 1.0 embed); (Must add support!) translate([11, 12-1+10, 28-6]) cube([6, 5+1, 6]); // Servo #2 single taller pillar; hoping this will be firm enough // Proving difficult to get dimensions translate([-6, 31-12, 0]) cube([6+1, 11, 70+1]); On Wed, 20 Oct 2021 at 09:27, Terry <terrypingm@gmail.com> wrote: > On Mon, 18 Oct 2021 13:22:24 -0600, you wrote: > > >On Mon, 2021-10-18 at 11:34 +0100, Terry wrote: > >> My screenshot shows an example of a problem I frequently encounter. > >> When I want to visually check some distance and select Right or Left, > >> Orthogonal views, the Axes and Scale Markers are not displayed. > >> Presumably because they are being 'viewed' head on. Is there any no- > >> brainer work around please? > >> Image attached or here: > >> https://www.dropbox.com/s/7rkt7jgmjahcxc1/MissingScale.jpg?raw=1 > > > >My no-brainer workaround is to left-click and rotate the view slightly. > > > >_______________________________________________ > >OpenSCAD mailing list > >To unsubscribe send an email to discuss-leave@lists.openscad.org > > I can't get any such small rotation to display a readable scale. Could you > show > me a screenshot please? > > Code attached, or here: > > https://www.dropbox.com/s/ohatuqot75zz8dp/TrayForCanon-HobbyServoMount-Minimal.scad?raw=1 > > Terry > > -- LargePrefPlaceholder-XKUz1MEJBwkOM
L
larry
Wed, Oct 20, 2021 5:53 PM

On Wed, 2021-10-20 at 09:27 +0100, Terry wrote:

On Mon, 18 Oct 2021 13:22:24 -0600, you wrote:

My no-brainer workaround is to left-click and rotate the view
slightly.

I can't get any such small rotation to display a readable scale.
Could you show
me a screenshot please?

I see your particular object is positioned in such a way as to make it
difficult to use the scale markers at all, except for the Y markers,
and that, only for the tall vertical piece. All other parts are not
near any of the scale markers.

Sorry, but when I said it was easy, I was assuming that the object
would have several parts of interest at the origin lines, and that you
wanted to find measurements of an STL that you had not coded yourself.

So what I did, to place things next to scale markers:

Exported the object as an STL
ran a python script called stlplace on the STL, available at
https://github.com/lar3ry/OpenSCAD---Move-STL-to-origin/blob/master/stlplace.py

This will give you translate() statements to position the object at
various places:
Positions: NE, NW, SW, SE, Centre XY, Centre All

Making it a lot easier to see the markers.

I then copied the NE translate, and added lines at the beginning and
end of your code:

translate([ 6.0 , -10.0 , -0.0 ]) {
<your code>
}

See the attached for a picture.

From there, simply use one of the other positions from stlplace or
adjust the translate to bring objects of interest into the appropriate
place.

Once you have something against the appropriate markers, it's easy to
see.

One caveat; if you zoom in, at some point, the scale markers will not
be numbered unless thay are multiples of 10, but you can look at the
bigger picture before zooming.

A mmore accurate way is to create an object and place it over the part
you want to measure, and adjust it so it creates 'Z-fighting". Use the

for the object.

On Wed, 2021-10-20 at 09:27 +0100, Terry wrote: > On Mon, 18 Oct 2021 13:22:24 -0600, you wrote: > > My no-brainer workaround is to left-click and rotate the view > > slightly. > I can't get any such small rotation to display a readable scale. > Could you show > me a screenshot please? I see your particular object is positioned in such a way as to make it difficult to use the scale markers at all, except for the Y markers, and that, only for the tall vertical piece. All other parts are not near any of the scale markers. Sorry, but when I said it was easy, I was assuming that the object would have several parts of interest at the origin lines, and that you wanted to find measurements of an STL that you had not coded yourself. So what I did, to place things next to scale markers: Exported the object as an STL ran a python script called stlplace on the STL, available at https://github.com/lar3ry/OpenSCAD---Move-STL-to-origin/blob/master/stlplace.py This will give you translate() statements to position the object at various places: Positions: NE, NW, SW, SE, Centre XY, Centre All Making it a lot easier to see the markers. I then copied the NE translate, and added lines at the beginning and end of your code: translate([ 6.0 , -10.0 , -0.0 ]) { <your code> } See the attached for a picture. From there, simply use one of the other positions from stlplace or adjust the translate to bring objects of interest into the appropriate place. Once you have something against the appropriate markers, it's easy to see. One caveat; if you zoom in, at some point, the scale markers will not be numbered unless thay are multiples of 10, but you can look at the bigger picture before zooming. A mmore accurate way is to create an object and place it over the part you want to measure, and adjust it so it creates 'Z-fighting". Use the # for the object.
MM
Michael Möller
Wed, Oct 20, 2021 7:45 PM

In theory you do not need to measure or eyeball things, you know from the
code you wrote where you placed it.

In practice, you want to make sure your code is correct, and does what was
intended.

I am no exception. After I code the translate, rotate, sin(dist), a>b?1:0
and so on - was my thinking correct? My tool for measuring is to export the
STL and use an STL viewer, which has the facility to measure the
distance (and angle or radius) between any points, lines or surfaces ->
www.3d-tool.de (use the free version). It does slow down the loop: code,
render, export STL, import, do measurement, and then go back and iterate,
but that is my encouragement to think more and experiment less :-)

(Sorry, the original OpenSCAD code has aged out of my mailwastebaset, but
here is a screenshot of something similar with a measurement
[image: image.png]
Note it has "found" the centre of the circle even though it is in midair.)

On Wed, 20 Oct 2021 at 19:53, larry lar3ry@sasktel.net wrote:

On Wed, 2021-10-20 at 09:27 +0100, Terry wrote:

On Mon, 18 Oct 2021 13:22:24 -0600, you wrote:

My no-brainer workaround is to left-click and rotate the view
slightly.

I can't get any such small rotation to display a readable scale.
Could you show
me a screenshot please?

I see your particular object is positioned in such a way as to make it
difficult to use the scale markers at all, except for the Y markers,
and that, only for the tall vertical piece. All other parts are not
near any of the scale markers.

Sorry, but when I said it was easy, I was assuming that the object
would have several parts of interest at the origin lines, and that you
wanted to find measurements of an STL that you had not coded yourself.

So what I did, to place things next to scale markers:

Exported the object as an STL
ran a python script called stlplace on the STL, available at

https://github.com/lar3ry/OpenSCAD---Move-STL-to-origin/blob/master/stlplace.py

This will give you translate() statements to position the object at
various places:
Positions: NE, NW, SW, SE, Centre XY, Centre All

Making it a lot easier to see the markers.

I then copied the NE translate, and added lines at the beginning and
end of your code:

translate([ 6.0 , -10.0 , -0.0 ]) {
<your code>
}

See the attached for a picture.

From there, simply use one of the other positions from stlplace or
adjust the translate to bring objects of interest into the appropriate
place.

Once you have something against the appropriate markers, it's easy to
see.

One caveat; if you zoom in, at some point, the scale markers will not
be numbered unless thay are multiples of 10, but you can look at the
bigger picture before zooming.

A mmore accurate way is to create an object and place it over the part
you want to measure, and adjust it so it creates 'Z-fighting". Use the

for the object.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

In theory you do not need to measure or eyeball things, you know from the code you wrote where you placed it. In practice, you want to make sure your code is correct, and does what was intended. I am no exception. After I code the translate, rotate, sin(dist), a>b?1:0 and so on - was my thinking correct? My tool for measuring is to export the STL and use an STL viewer, which has the facility to measure the distance (and angle or radius) between any points, lines or surfaces -> www.3d-tool.de (use the free version). It does slow down the loop: code, render, export STL, import, do measurement, and then go back and iterate, but that is my encouragement to think more and experiment less :-) (Sorry, the original OpenSCAD code has aged out of my mailwastebaset, but here is a screenshot of something similar with a measurement [image: image.png] Note it has "found" the centre of the circle even though it is in midair.) On Wed, 20 Oct 2021 at 19:53, larry <lar3ry@sasktel.net> wrote: > On Wed, 2021-10-20 at 09:27 +0100, Terry wrote: > > On Mon, 18 Oct 2021 13:22:24 -0600, you wrote: > > > My no-brainer workaround is to left-click and rotate the view > > > slightly. > > > I can't get any such small rotation to display a readable scale. > > Could you show > > me a screenshot please? > > I see your particular object is positioned in such a way as to make it > difficult to use the scale markers at all, except for the Y markers, > and that, only for the tall vertical piece. All other parts are not > near any of the scale markers. > > Sorry, but when I said it was easy, I was assuming that the object > would have several parts of interest at the origin lines, and that you > wanted to find measurements of an STL that you had not coded yourself. > > So what I did, to place things next to scale markers: > > Exported the object as an STL > ran a python script called stlplace on the STL, available at > > https://github.com/lar3ry/OpenSCAD---Move-STL-to-origin/blob/master/stlplace.py > > This will give you translate() statements to position the object at > various places: > Positions: NE, NW, SW, SE, Centre XY, Centre All > > Making it a lot easier to see the markers. > > I then copied the NE translate, and added lines at the beginning and > end of your code: > > translate([ 6.0 , -10.0 , -0.0 ]) { > <your code> > } > > See the attached for a picture. > > From there, simply use one of the other positions from stlplace or > adjust the translate to bring objects of interest into the appropriate > place. > > Once you have something against the appropriate markers, it's easy to > see. > > One caveat; if you zoom in, at some point, the scale markers will not > be numbered unless thay are multiples of 10, but you can look at the > bigger picture before zooming. > > A mmore accurate way is to create an object and place it over the part > you want to measure, and adjust it so it creates 'Z-fighting". Use the > # for the object. > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JB
Jordan Brown
Wed, Oct 20, 2021 8:02 PM

On 10/20/2021 12:45 PM, Michael Möller wrote:

In theory you do not need to measure or eyeball things, you know from
the code you wrote where you placed it.

In practice, you want to make sure your code is correct, and does what
was intended.

Yes.  Also, if you're modeling a real-world object, you may be
accumulating errors as you work your way around the object, and at some
point you may want to check that the resulting position is still
acceptable.  For instance, in modeling an armchair I would start from
the seat of the chair and work upward to the arms, connecting one part
to the next, but then once I reached the end of the arms I'd want to
double-check that they ended up at the (more or less) right separation.

On 10/20/2021 12:45 PM, Michael Möller wrote: > In theory you do not need to measure or eyeball things, you know from > the code you wrote where you placed it. > > In practice, you want to make sure your code is correct, and does what > was intended. Yes.  Also, if you're modeling a real-world object, you may be accumulating errors as you work your way around the object, and at some point you may want to check that the resulting position is still acceptable.  For instance, in modeling an armchair I would start from the seat of the chair and work upward to the arms, connecting one part to the next, but then once I reached the end of the arms I'd want to double-check that they ended up at the (more or less) right separation.
W
Wolf
Wed, Oct 20, 2021 8:59 PM

Why do you want to restrict yourself to the two decimal places of
accuracy available from measuring on a screen, or the five places
available from echo() or an stl file, if you can have the full 18
decimal places (=64 bit) accuracy available from OpenSCAD?

Take a look here:

/*Rotation matrix from axis and angle
Sources:
https://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_and_angle
https://www.varsitytutors.com/hotmath/hotmath_help/topics/multiplying-vector-by-a-matrix
*/

Angle=12;            // angle of rotation
Axis=[1,2,3];        // axis of rotation
Cube=[10,20,15];     // vector defining a cube
Position=[30,20,0];  // vector defining how far the shape is to be
translated
Pos=[-30,20,0];
MyCube(Position,Angle,Axis,Cube);    // packaging the action into a
module makes the list of point coordinates unavailable outside the module

         /*  Improper approach: packaging the action into a module
makes the list of point coordinates unavailable outside the module  */
module MyCube(Position,Angle,Axis,Cube)
{
  MakeCube=CubePoints(Cube);                  // create the list of all
8 cube vertices
  MovedCube=MoveTo(Pos,MakeCube);             // translate the cube to
a new position
  RotatedCube=Orient(Angle,Axis,MovedCube);   // rotate the cube
  polyhedron(RotatedCube, CubeFaces());       // put the cube onto preview
  PointerPosition=RotatedCube[0];
    echo("Inside",RotatedCube,PointerPosition);
  color("blue")  Pointer(PointerPosition,[1,0,0],90);
}

         /*  proper approach: packaging the information into functions
makes the list of points available to modules inside this program,
             and to modules outside this program linked to it by the
use < . . .> command.
             If desired, the three functions Make(), Moved() and
Rotated() may also be merged into a single function  */
function Make()=CubePoints(Cube);                // create the list of
all 8 cube vertices
function Moved()=MoveTo(Position,Make());        // translate the shape
to a new position
function Rotated()=Orient(Angle,Axis,Moved());   // rotate the shape
polyhedron(Rotated(), CubeFaces());              // put the cube onto
preview
RotatedCube=Orient(Angle,Axis,Moved());
PointerPosition=RotatedCube[0];
echo("Outside",RotatedCube,PointerPosition);
color("green")  Pointer(PointerPosition,[1,0,0],90);
//  function Cut()                   // cutting action, replaces
difference()

         /*  Cube is a vector containing x,y,and z coordinates of a
cube  /
function CubePoints(Cube)= [[-Cube.x,0,0], [0,0,0], [0,Cube.y,0],
[-Cube.x,Cube.y,0], [-Cube.x,0,Cube.z], [0,0,Cube.z], [0,Cube.y,Cube.z],
[-Cube.x,Cube.y,Cube.z]];
         /
CubeFaces is the list of index numbers referencing
individual CubePoints and their coordinates  */
function CubeFaces()=[ [0,1,2,3],/Bottom Face/ [4,5,1,0],/Front
Face
/ [7,6,5,4],/Top Face/
                       [5,6,2,1],/Right Face/  [6,7,3,2],/Rear
Face
/  [7,4,0,3]/Left Face/ ];

         /* functions A11..A33 represent the 9 components of the
rotation matrix. When combined
            into function 'Rot(Point,Axis,Angl)', they enable the
rotation of a single point around
            the axis 'Axs' by the angle 'Angl'.  /
function A11(Axs,Angl)=cos(Angl)+Axs.x
Axs.x*(1-cos(Angl));             
// column 1 of matrix describing rotation by 'Angl' around axis 'Axs'
function A12(Axs,Angl)=Axs.yAxs.x(1-cos(Angl))+Axs.zsin(Angl);
function A13(Axs,Angl)=Axs.z
Axs.x*(1-cos(Angl))-Axs.y*sin(Angl);

function A21(Axs,Angl)=Axs.xAxs.y(1-cos(Angl))-Axs.zsin(Angl);       
// column 2 of matrix describing rotation by 'Angl' around axis 'Axs'
function A22(Axs,Angl)=cos(Angl)+Axs.y
Axs.y*(1-cos(Angl));
function A23(Axs,Angl)=Axs.zAxs.y(1-cos(Angl))+Axs.x*sin(Angl);

function A31(Axs,Angl)=Axs.xAxs.z(1-cos(Angl))+Axs.ysin(Angl);       
// column 3 of matrix describing rotation by 'Angl' around axis 'Axs'
function A32(Axs,Angl)=Axs.y
Axs.z*(1-cos(Angl))-Axs.xsin(Angl);
function A33(Axs,Angl)=cos(Angl)+Axs.z
Axs.z*(1-cos(Angl));

function
RotX(Point,Axs,Angl)=Point.xA11(Axs,Angl)+Point.yA21(Axs,Angl)+Point.zA31(Axs,Angl);
// x-coordinate of rotated point
function
RotY(Point,Axs,Angl)=Point.x
A12(Axs,Angl)+Point.yA22(Axs,Angl)+Point.zA32(Axs,Angl);
// y-coordinate of rotated point
function
RotZ(Point,Axs,Angl)=Point.xA13(Axs,Angl)+Point.yA23(Axs,Angl)+Point.z*A33(Axs,Angl);
// z-coordinate of rotated point

function
Rot(Point,Axis,Angl)=[RotX(Point,Axis,Angl),RotY(Point,Axis,Angl),RotZ(Point,Axis,Angl)];
// coordinates of rotated point as vector
function Axs()=Axis/norm(Axis);         // convert 'Axis' vector to unit
vector so that Axs.xAxs.x+Axs.yAxs.y+Axs.z*Axs.z=1

         /* A translation adds the same vector to all 8 points of the cube
            A shape is any form of geometric "Shape'. A cube is an
example of a shape, it is a shape having 8 corners or vertices /
function MoveTo(Vector,Shape)=[for (i=[0:len(Shape)-1])
Shape[i]+Vector];      // replaces translate()
         /
A rotation changes the coordinates of all points of a shape
using the function Rot((Point,Axis,Angl))  */
function Orient(Angle,Axis,Shape)=[for (i=[0:len(Shape)-1])
Rot(Shape[i],Axis,Angle)];     // replaces rotate(a=angle, v=axis)

/*  debugging aid 'Pointer()'  */
module Pointer(Point,Axis,Angle)   // marks a 'Point' in 3D space.
'Axis' of rotation and 'Angle' mark the direction from where to mark the
'Point'
{
  $fn=3;
  PointerLength=10;
  translate(Point)     rotate(a=Angle,v=Axis)
cylinder(h=PointerLength,d1=0,d2=5,center=false);
}

As you may have noticed, this code is work in progress. Avail yourself
of it, if you like it, I do not attach any copyright to it. Tell me if
it contains bugs, but do not tell me how to extend it - those
suggestions I will ignore.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Why do you want to restrict yourself to the two decimal places of accuracy available from measuring on a screen, or the five places available from echo() or an stl file, if you can have the full 18 decimal places (=64 bit) accuracy available from OpenSCAD? Take a look here: /*Rotation matrix from axis and angle Sources: https://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_and_angle https://www.varsitytutors.com/hotmath/hotmath_help/topics/multiplying-vector-by-a-matrix */ Angle=12;            // angle of rotation Axis=[1,2,3];        // axis of rotation Cube=[10,20,15];     // vector defining a cube Position=[30,20,0];  // vector defining how far the shape is to be translated Pos=[-30,20,0]; MyCube(Position,Angle,Axis,Cube);    // packaging the action into a module makes the list of point coordinates unavailable outside the module          /*  Improper approach: packaging the action into a module makes the list of point coordinates unavailable outside the module  */ module MyCube(Position,Angle,Axis,Cube) {   MakeCube=CubePoints(Cube);                  // create the list of all 8 cube vertices   MovedCube=MoveTo(Pos,MakeCube);             // translate the cube to a new position   RotatedCube=Orient(Angle,Axis,MovedCube);   // rotate the cube   polyhedron(RotatedCube, CubeFaces());       // put the cube onto preview   PointerPosition=RotatedCube[0];     echo("Inside",RotatedCube,PointerPosition);   color("blue")  Pointer(PointerPosition,[1,0,0],90); }          /*  proper approach: packaging the information into functions makes the list of points available to modules inside this program,              and to modules outside this program linked to it by the use < . . .> command.              If desired, the three functions Make(), Moved() and Rotated() may also be merged into a single function  */ function Make()=CubePoints(Cube);                // create the list of all 8 cube vertices function Moved()=MoveTo(Position,Make());        // translate the shape to a new position function Rotated()=Orient(Angle,Axis,Moved());   // rotate the shape polyhedron(Rotated(), CubeFaces());              // put the cube onto preview RotatedCube=Orient(Angle,Axis,Moved()); PointerPosition=RotatedCube[0]; echo("Outside",RotatedCube,PointerPosition); color("green")  Pointer(PointerPosition,[1,0,0],90); //  function Cut()                   // cutting action, replaces difference()          /*  Cube is a vector containing x,y,and z coordinates of a cube  */ function CubePoints(Cube)= [[-Cube.x,0,0], [0,0,0], [0,Cube.y,0], [-Cube.x,Cube.y,0], [-Cube.x,0,Cube.z], [0,0,Cube.z], [0,Cube.y,Cube.z], [-Cube.x,Cube.y,Cube.z]];          /* CubeFaces is the list of index numbers referencing individual CubePoints and their coordinates  */ function CubeFaces()=[ [0,1,2,3],/*Bottom Face*/ [4,5,1,0],/*Front Face*/ [7,6,5,4],/*Top Face*/                        [5,6,2,1],/*Right Face*/  [6,7,3,2],/*Rear Face*/  [7,4,0,3]/*Left Face*/ ];          /* functions A11..A33 represent the 9 components of the rotation matrix. When combined             into function 'Rot(Point,Axis,Angl)', they enable the rotation of a single point around             the axis 'Axs' by the angle 'Angl'.  */ function A11(Axs,Angl)=cos(Angl)+Axs.x*Axs.x*(1-cos(Angl));              // column 1 of matrix describing rotation by 'Angl' around axis 'Axs' function A12(Axs,Angl)=Axs.y*Axs.x*(1-cos(Angl))+Axs.z*sin(Angl); function A13(Axs,Angl)=Axs.z*Axs.x*(1-cos(Angl))-Axs.y*sin(Angl); function A21(Axs,Angl)=Axs.x*Axs.y*(1-cos(Angl))-Axs.z*sin(Angl);        // column 2 of matrix describing rotation by 'Angl' around axis 'Axs' function A22(Axs,Angl)=cos(Angl)+Axs.y*Axs.y*(1-cos(Angl)); function A23(Axs,Angl)=Axs.z*Axs.y*(1-cos(Angl))+Axs.x*sin(Angl); function A31(Axs,Angl)=Axs.x*Axs.z*(1-cos(Angl))+Axs.y*sin(Angl);        // column 3 of matrix describing rotation by 'Angl' around axis 'Axs' function A32(Axs,Angl)=Axs.y*Axs.z*(1-cos(Angl))-Axs.x*sin(Angl); function A33(Axs,Angl)=cos(Angl)+Axs.z*Axs.z*(1-cos(Angl)); function RotX(Point,Axs,Angl)=Point.x*A11(Axs,Angl)+Point.y*A21(Axs,Angl)+Point.z*A31(Axs,Angl); // x-coordinate of rotated point function RotY(Point,Axs,Angl)=Point.x*A12(Axs,Angl)+Point.y*A22(Axs,Angl)+Point.z*A32(Axs,Angl); // y-coordinate of rotated point function RotZ(Point,Axs,Angl)=Point.x*A13(Axs,Angl)+Point.y*A23(Axs,Angl)+Point.z*A33(Axs,Angl); // z-coordinate of rotated point function Rot(Point,Axis,Angl)=[RotX(Point,Axis,Angl),RotY(Point,Axis,Angl),RotZ(Point,Axis,Angl)]; // coordinates of rotated point as vector function Axs()=Axis/norm(Axis);         // convert 'Axis' vector to unit vector so that Axs.x*Axs.x+Axs.y*Axs.y+Axs.z*Axs.z=1          /* A translation adds the same vector to all 8 points of the cube             A shape is any form of geometric "Shape'. A cube is an example of a shape, it is a shape having 8 corners or vertices */ function MoveTo(Vector,Shape)=[for (i=[0:len(Shape)-1]) Shape[i]+Vector];      // replaces translate()          /* A rotation changes the coordinates of all points of a shape using the function Rot((Point,Axis,Angl))  */ function Orient(Angle,Axis,Shape)=[for (i=[0:len(Shape)-1]) Rot(Shape[i],Axis,Angle)];     // replaces rotate(a=angle, v=axis) /*  debugging aid 'Pointer()'  */ module Pointer(Point,Axis,Angle)   // marks a 'Point' in 3D space. 'Axis' of rotation and 'Angle' mark the direction from where to mark the 'Point' {   $fn=3;   PointerLength=10;   translate(Point)     rotate(a=Angle,v=Axis) cylinder(h=PointerLength,d1=0,d2=5,center=false); } > > > As you may have noticed, this code is work in progress. Avail yourself > of it, if you like it, I do not attach any copyright to it. Tell me if > it contains bugs, but do not tell me how to extend it - those > suggestions I will ignore. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
RW
Ray West
Wed, Oct 20, 2021 9:29 PM

On 20/10/2021 21:59, Wolf wrote:

Why do you want to restrict yourself to the two decimal places of
accuracy available from measuring on a screen, or the five places a

I asked Alexa. Her answer was good enough for me - rounding up to two
decimal places can tell whether a person is in a store, or in the
neighbourhood... from blis.com  - I understood that, but not all that
matrix stuff

On 20/10/2021 21:59, Wolf wrote: > Why do you want to restrict yourself to the two decimal places of > accuracy available from measuring on a screen, or the five places a I asked Alexa. Her answer was good enough for me - rounding up to two decimal places can tell whether a person is in a store, or in the neighbourhood... from blis.com  - I understood that, but not all that matrix stuff
T
terrypingm@gmail.com
Wed, Oct 20, 2021 10:08 PM

Thanks Michael, looking forward to trying that radically different STL approach. Prompted by your post I recall vaguely that my slicing app, Cura, can measure things, although it’s not going to beat being able to do it directly in OpenSCAD.
(I’d also have to resist the temptation to go the one extra step and print it, with potential sawing/sanding/shimmying in view.)

I agree with your entreaty, essentially to get the code right in the first place. But, like you, theory versus practice… Add my novice status and impatience to get it printed and working.

Terry

On 20 Oct 2021, at 20:45, Michael Möller private2michael@gmail.com wrote:



In theory you do not need to measure or eyeball things, you know from the code you wrote where you placed it.

In practice, you want to make sure your code is correct, and does what was intended.

I am no exception. After I code the translate, rotate, sin(dist), a>b?1:0 and so on - was my thinking correct? My tool for measuring is to export the STL and use an STL viewer, which has the facility to measure the distance (and angle or radius) between any points, lines or surfaces -> www.3d-tool.de (use the free version). It does slow down the loop: code, render, export STL, import, do measurement, and then go back and iterate, but that is my encouragement to think more and experiment less :-)

(Sorry, the original OpenSCAD code has aged out of my mailwastebaset, but here is a screenshot of something similar with a measurement
<image.png>

Note it has "found" the centre of the circle even though it is in midair.)

On Wed, 20 Oct 2021 at 19:53, larry lar3ry@sasktel.net wrote:
On Wed, 2021-10-20 at 09:27 +0100, Terry wrote:

On Mon, 18 Oct 2021 13:22:24 -0600, you wrote:

My no-brainer workaround is to left-click and rotate the view
slightly.

I can't get any such small rotation to display a readable scale.
Could you show
me a screenshot please?

I see your particular object is positioned in such a way as to make it
difficult to use the scale markers at all, except for the Y markers,
and that, only for the tall vertical piece. All other parts are not
near any of the scale markers.

Sorry, but when I said it was easy, I was assuming that the object
would have several parts of interest at the origin lines, and that you
wanted to find measurements of an STL that you had not coded yourself.

So what I did, to place things next to scale markers:

Exported the object as an STL
ran a python script called stlplace on the STL, available at
https://github.com/lar3ry/OpenSCAD---Move-STL-to-origin/blob/master/stlplace.py

This will give you translate() statements to position the object at
various places:
Positions: NE, NW, SW, SE, Centre XY, Centre All

Making it a lot easier to see the markers.

I then copied the NE translate, and added lines at the beginning and
end of your code:

translate([ 6.0 , -10.0 , -0.0 ]) {
<your code>
}

See the attached for a picture.

From there, simply use one of the other positions from stlplace or
adjust the translate to bring objects of interest into the appropriate
place.

Once you have something against the appropriate markers, it's easy to
see.

One caveat; if you zoom in, at some point, the scale markers will not
be numbered unless thay are multiples of 10, but you can look at the
bigger picture before zooming.

A mmore accurate way is to create an object and place it over the part
you want to measure, and adjust it so it creates 'Z-fighting". Use the

for the object.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Thanks Michael, looking forward to trying that radically different STL approach. Prompted by your post I recall vaguely that my slicing app, Cura, can measure things, although it’s not going to beat being able to do it directly in OpenSCAD. (I’d also have to resist the temptation to go the one extra step and print it, with potential sawing/sanding/shimmying in view.) I agree with your entreaty, essentially to get the code right in the first place. But, like you, theory versus practice… Add my novice status and impatience to get it printed and working. Terry > On 20 Oct 2021, at 20:45, Michael Möller <private2michael@gmail.com> wrote: > >  > > In theory you do not need to measure or eyeball things, you know from the code you wrote where you placed it. > > In practice, you want to make sure your code is correct, and does what was intended. > > I am no exception. After I code the translate, rotate, sin(dist), a>b?1:0 and so on - was my thinking correct? My tool for measuring is to export the STL and use an STL viewer, which has the facility to measure the distance (and angle or radius) between any points, lines or surfaces -> www.3d-tool.de (use the free version). It does slow down the loop: code, render, export STL, import, do measurement, and then go back and iterate, but that is my encouragement to think more and experiment less :-) > > (Sorry, the original OpenSCAD code has aged out of my mailwastebaset, but here is a screenshot of something similar with a measurement > <image.png> > > Note it has "found" the centre of the circle even though it is in midair.) > >> On Wed, 20 Oct 2021 at 19:53, larry <lar3ry@sasktel.net> wrote: >> On Wed, 2021-10-20 at 09:27 +0100, Terry wrote: >> > On Mon, 18 Oct 2021 13:22:24 -0600, you wrote: >> > > My no-brainer workaround is to left-click and rotate the view >> > > slightly. >> >> > I can't get any such small rotation to display a readable scale. >> > Could you show >> > me a screenshot please? >> >> I see your particular object is positioned in such a way as to make it >> difficult to use the scale markers at all, except for the Y markers, >> and that, only for the tall vertical piece. All other parts are not >> near any of the scale markers. >> >> Sorry, but when I said it was easy, I was assuming that the object >> would have several parts of interest at the origin lines, and that you >> wanted to find measurements of an STL that you had not coded yourself. >> >> So what I did, to place things next to scale markers: >> >> Exported the object as an STL >> ran a python script called stlplace on the STL, available at >> https://github.com/lar3ry/OpenSCAD---Move-STL-to-origin/blob/master/stlplace.py >> >> This will give you translate() statements to position the object at >> various places: >> Positions: NE, NW, SW, SE, Centre XY, Centre All >> >> Making it a lot easier to see the markers. >> >> I then copied the NE translate, and added lines at the beginning and >> end of your code: >> >> translate([ 6.0 , -10.0 , -0.0 ]) { >> <your code> >> } >> >> See the attached for a picture. >> >> From there, simply use one of the other positions from stlplace or >> adjust the translate to bring objects of interest into the appropriate >> place. >> >> Once you have something against the appropriate markers, it's easy to >> see. >> >> One caveat; if you zoom in, at some point, the scale markers will not >> be numbered unless thay are multiples of 10, but you can look at the >> bigger picture before zooming. >> >> A mmore accurate way is to create an object and place it over the part >> you want to measure, and adjust it so it creates 'Z-fighting". Use the >> # for the object. >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
TP
Terry Pinnell
Wed, Oct 20, 2021 10:21 PM

Thanks for the detailed follow up. As you may have seem, Michael has also
recommended getting the STL on the case, and I'll explore. For my
relatively simple projects my favourites so far are

  1. Add an appropriate cube and 'fitting' it. (Or a sphere as Ray does.)
  2. My macro tool plus calculator.

On Wed, 20 Oct 2021 at 18:53, larry lar3ry@sasktel.net wrote:

On Wed, 2021-10-20 at 09:27 +0100, Terry wrote:

On Mon, 18 Oct 2021 13:22:24 -0600, you wrote:

My no-brainer workaround is to left-click and rotate the view
slightly.

I can't get any such small rotation to display a readable scale.
Could you show
me a screenshot please?

I see your particular object is positioned in such a way as to make it
difficult to use the scale markers at all, except for the Y markers,
and that, only for the tall vertical piece. All other parts are not
near any of the scale markers.

Sorry, but when I said it was easy, I was assuming that the object
would have several parts of interest at the origin lines, and that you
wanted to find measurements of an STL that you had not coded yourself.

So what I did, to place things next to scale markers:

Exported the object as an STL
ran a python script called stlplace on the STL, available at

https://github.com/lar3ry/OpenSCAD---Move-STL-to-origin/blob/master/stlplace.py

This will give you translate() statements to position the object at
various places:
Positions: NE, NW, SW, SE, Centre XY, Centre All

Making it a lot easier to see the markers.

I then copied the NE translate, and added lines at the beginning and
end of your code:

translate([ 6.0 , -10.0 , -0.0 ]) {
<your code>
}

See the attached for a picture.

From there, simply use one of the other positions from stlplace or
adjust the translate to bring objects of interest into the appropriate
place.

Once you have something against the appropriate markers, it's easy to
see.

One caveat; if you zoom in, at some point, the scale markers will not
be numbered unless thay are multiples of 10, but you can look at the
bigger picture before zooming.

A mmore accurate way is to create an object and place it over the part
you want to measure, and adjust it so it creates 'Z-fighting". Use the

for the object.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

--
LargePrefPlaceholder-XKUz1MEJBwkOM

Thanks for the detailed follow up. As you may have seem, Michael has also recommended getting the STL on the case, and I'll explore. For my relatively simple projects my favourites so far are 1. Add an appropriate cube and 'fitting' it. (Or a sphere as Ray does.) 2. My macro tool plus calculator. On Wed, 20 Oct 2021 at 18:53, larry <lar3ry@sasktel.net> wrote: > On Wed, 2021-10-20 at 09:27 +0100, Terry wrote: > > On Mon, 18 Oct 2021 13:22:24 -0600, you wrote: > > > My no-brainer workaround is to left-click and rotate the view > > > slightly. > > > I can't get any such small rotation to display a readable scale. > > Could you show > > me a screenshot please? > > I see your particular object is positioned in such a way as to make it > difficult to use the scale markers at all, except for the Y markers, > and that, only for the tall vertical piece. All other parts are not > near any of the scale markers. > > Sorry, but when I said it was easy, I was assuming that the object > would have several parts of interest at the origin lines, and that you > wanted to find measurements of an STL that you had not coded yourself. > > So what I did, to place things next to scale markers: > > Exported the object as an STL > ran a python script called stlplace on the STL, available at > > https://github.com/lar3ry/OpenSCAD---Move-STL-to-origin/blob/master/stlplace.py > > This will give you translate() statements to position the object at > various places: > Positions: NE, NW, SW, SE, Centre XY, Centre All > > Making it a lot easier to see the markers. > > I then copied the NE translate, and added lines at the beginning and > end of your code: > > translate([ 6.0 , -10.0 , -0.0 ]) { > <your code> > } > > See the attached for a picture. > > From there, simply use one of the other positions from stlplace or > adjust the translate to bring objects of interest into the appropriate > place. > > Once you have something against the appropriate markers, it's easy to > see. > > One caveat; if you zoom in, at some point, the scale markers will not > be numbered unless thay are multiples of 10, but you can look at the > bigger picture before zooming. > > A mmore accurate way is to create an object and place it over the part > you want to measure, and adjust it so it creates 'Z-fighting". Use the > # for the object. > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > -- LargePrefPlaceholder-XKUz1MEJBwkOM