Newbie with rotation problem

classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Newbie with rotation problem

Wim ten Brink
All I want to do is have a cube with all corners intersecting the axis, thus, it needs to be rotated. Rotating it 45 degrees like this should work, I thought: rotate([45, 45, 45]) cube(20, center=true);
But it doesn't! I don't know why but the corners of the cube are not located on any of the axis. Seems so simple to me, yet I can't understand why it's not working...

So, question! How do I rotate a cube so all corners will be at one of the three axis?

With kind regards,
Wim,
W.A. ten Brink.
With kind regards,
Wim,
W.A. ten Brink
Reply | Threaded
Open this post in threaded view
|

Re: Newbie with rotation problem

doug.moen
I don't think it is geometrically possible for a cube to do this. A cube has 12 vertexes, and you want 8 of those vertexes to be aligned with the axes. It's not possible without warping the cube into an irregular hexahedron. You can do this with an octahedron, which has 8 vertexes.

On 31 March 2016 at 19:47, Wim ten Brink <[hidden email]> wrote:
All I want to do is have a cube with all corners intersecting the axis, thus,
it needs to be rotated. Rotating it 45 degrees like this should work, I
thought: rotate([45, 45, 45]) cube(20, center=true);
But it doesn't! I don't know why but the corners of the cube are not located
on any of the axis. Seems so simple to me, yet I can't understand why it's
not working...

So, question! How do I rotate a cube so all corners will be at one of the
three axis?

With kind regards,
Wim,
W.A. ten Brink.



-----
With kind regards,
Wim,
W.A. ten Brink
--
View this message in context: http://forum.openscad.org/Newbie-with-rotation-problem-tp16873.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org




_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Newbie with rotation problem

fred_dot_u
I'm not sure where the 12 vertices comes from, as I count eight, four for the top face and four for the bottom face, which are common to the sides, of course.

For the original post, though, I don't believe what you seek is possible. Consider that if you slice a cube across any plane that meets your requirements, you do not get a square. I took four points that would represent two of the axes, but they are not co-planar, so you can't make them fit on those axes.

A regular octohedron would fit, but would not be a cube, of course. It has six vertices, to match the axis intersection points.

Wim ten Brink, am I missing something with the vertex counts? They don't match yours but geometry is challenging me at the moment.
Reply | Threaded
Open this post in threaded view
|

Re: Newbie with rotation problem

Wim ten Brink
In reply to this post by Wim ten Brink
Okay, dumb question... There are three axis, thus making 6 points where the cube can go through an axis. But the cube has 8 corners so it will never touch the axis with all sides...
So, how to create a shape that does have all corners on an axis? Oh, well... This is what I was actually looking for:

hull(){
  translate([10, 0, 0]) sphere(1);
  translate([-10, 0, 0]) sphere(1);
  translate([0, 10, 0]) sphere(1);
  translate([0, -10, 0]) sphere(1);
  translate([0, 0, 10]) sphere(1);
  translate([0, 0, -10]) sphere(1);
}
Problem solved.
With kind regards,
Wim,
W.A. ten Brink
Reply | Threaded
Open this post in threaded view
|

Re: Newbie with rotation problem

Ronaldo
Or:

cylinder(r1=10,r2=0,h=10,$fn=4);
scale([1,1,-1]) cylinder(r1=10,r2=0,h=10,$fn=4);

2016-03-31 23:05 GMT-03:00 Wim ten Brink <[hidden email]>:
Okay, dumb question... There are three axis, thus making 6 points where the
cube can go through an axis. But the cube has 8 corners so it will never
touch the axis with all sides...
So, how to create a shape that does have all corners on an axis? Oh, well...
This is what I was actually looking for:


> hull(){
>   translate([10, 0, 0]) sphere(1);
>   translate([-10, 0, 0]) sphere(1);
>   translate([0, 10, 0]) sphere(1);
>   translate([0, -10, 0]) sphere(1);
>   translate([0, 0, 10]) sphere(1);
>   translate([0, 0, -10]) sphere(1);
> }

Problem solved.



-----
With kind regards,
Wim,
W.A. ten Brink
--
View this message in context: http://forum.openscad.org/Newbie-with-rotation-problem-tp16873p16876.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Newbie with rotation problem

macdarren
Now that is an interesting use of a negative 'scale' never thought to use it like that...
Reply | Threaded
Open this post in threaded view
|

Re: Newbie with rotation problem

nophead
cylinder(r1=10,r2=0,h=10,$fn=4);
mirror([0,0,-1]) cylinder(r1=10,r2=0,h=10,$fn=4);


Is more readable I think.

On 1 April 2016 at 07:02, macdarren <[hidden email]> wrote:
Now that is an interesting use of a negative 'scale' never thought to use it
like that...




--
View this message in context: http://forum.openscad.org/Newbie-with-rotation-problem-tp16873p16878.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Newbie with rotation problem

Wim ten Brink
In reply to this post by Ronaldo
Nice! Never considered that option. Normally, I expect round objects with cylinders. :)

Still like my own, though, since I actually want those rounded edges. But this is something to remember.
With kind regards,
Wim,
W.A. ten Brink
Reply | Threaded
Open this post in threaded view
|

Re: Newbie with rotation problem

Ronaldo
Rounded

hull() {
   sphere(1);
    union() {
   cylinder(r1=10,r2=0,h=10,$fn=4);
   mirror([0,0,-1]) cylinder(r1=10,r2=0,h=10,$fn=4);
  }
}

2016-04-01 5:24 GMT-03:00 Wim ten Brink <[hidden email]>:
Nice! Never considered that option. Normally, I expect round objects with
cylinders. :)

Still like my own, though, since I actually want those rounded edges. But
this is something to remember.



-----
With kind regards,
Wim,
W.A. ten Brink
--
View this message in context: http://forum.openscad.org/Newbie-with-rotation-problem-tp16873p16880.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Newbie with rotation problem

Ronaldo
Sorry. That is what I mean:

minkowski() {
    sphere(1);
    union() {
      cylinder(r1=10,r2=0,h=10,$fn=4);
      mirror([0,0,-1]) cylinder(r1=10,r2=0,h=10,$fn=4);
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: Newbie with rotation problem

macdarren
This post was updated on .
In reply to this post by Ronaldo
huh...that last doesn't work for me at all...I can kinda round part of the primary object if I translate the sphere out to the coroner of the object but still it only rounds part of it...

I admit I don't know much about hull(), so maybe there is some way to make it work over the entire thing.
To my mind I would need a sphere at each vertex.

maybe minkowski() instead of hull()?

edit:  beat me to it...at least it wasn't my own misunderstanding...:)


Reply | Threaded
Open this post in threaded view
|

Re: Newbie with rotation problem

cacb
In reply to this post by Ronaldo
On 01. april 2016 21:11, Ronaldo wrote:
> Sorry. That is what I mean:
>
> minkowski() {
>      sphere(1);
>      union() {
>        cylinder(r1=10,r2=0,h=10,$fn=4);
>        mirror([0,0,-1]) cylinder(r1=10,r2=0,h=10,$fn=4);
>      }
> }

Interesting ... so minkowski does not really care about the
specification of the object type (cylinder), only the discretized result.

It appears to me to be a major hack to use cylinder to specify a cone
which becomes a pyramid and then use minkowski on that....

Carsten Arnholm


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Newbie with rotation problem

nophead
There are no true spheres, cylinders, circles or curves in OpenScad once the renderings starts. All the geometry is represented by polygons and polyhedra.

On 1 April 2016 at 20:45, Carsten Arnholm <[hidden email]> wrote:
On 01. april 2016 21:11, Ronaldo wrote:
Sorry. That is what I mean:

minkowski() {
     sphere(1);
     union() {
       cylinder(r1=10,r2=0,h=10,$fn=4);
       mirror([0,0,-1]) cylinder(r1=10,r2=0,h=10,$fn=4);
     }
}

Interesting ... so minkowski does not really care about the specification of the object type (cylinder), only the discretized result.

It appears to me to be a major hack to use cylinder to specify a cone which becomes a pyramid and then use minkowski on that....

Carsten Arnholm



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Newbie with rotation problem

Wim ten Brink
This post was updated on .
In reply to this post by macdarren
I generally use $fn=100; as the first line in my projects, setting it at a global level. With hull(), it then gives a nice, round shape. The minkowski version also gives a good-looking result but when I subtract them from one anoter by using:
$fn=100;
radius=10;
rounding=1;
difference(){
    hull(){
        translate([radius-rounding, 0, 0]) sphere(rounding);
        translate([-radius+rounding, 0, 0]) sphere(rounding);
        translate([0, radius-rounding, 0]) sphere(rounding);
        translate([0, -radius+rounding, 0]) sphere(rounding);
        translate([0, 0, radius-rounding]) sphere(rounding);
        translate([0, 0, -radius+rounding]) sphere(rounding);
    }
    minkowski() {
        sphere(rounding);
        union() {
          cylinder(r1=radius, r2=0, h=radius, $fn=4);
          mirror([0,0,-1]) cylinder(r1=radius, r2=0, h=radius, $fn=4);
        }
    }
}
They are both overlapping exactly, after I fixed a few errors. Not sure which is better, though. Both hull and minkowski do a good job. Which would have the best performance anyways?
With kind regards,
Wim,
W.A. ten Brink
Reply | Threaded
Open this post in threaded view
|

Re: Newbie with rotation problem

Wim ten Brink
Oops, one minus needs to be a +. :)



-----
With kind regards,
Wim,
W.A. ten Brink
--
View this message in context: http://forum.openscad.org/Newbie-with-rotation-problem-tp16873p16904.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
With kind regards,
Wim,
W.A. ten Brink
Reply | Threaded
Open this post in threaded view
|

Re: Newbie with rotation problem

Ronaldo
In reply to this post by nophead
nophead wrote
There are no true spheres, cylinders, circles or curves in OpenScad once
the renderings starts. All the geometry is represented by polygons and
polyhedra.
This is a quiz :) The following image is the preview of translated primitives. No boolean operations, no rotation, neither scale nor mirror. How to get them?

Reply | Threaded
Open this post in threaded view
|

Re: Newbie with rotation problem

fred_dot_u
It would appear that a good part of the answer to your question lies here:

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids

Some of the answer involves low values of $fn along with cylinders of different r1 and r2 values.

Do you already know the answers and this is a true quiz, or are you seeking a solution?
Reply | Threaded
Open this post in threaded view
|

Re: Newbie with rotation problem

doug.moen
In reply to this post by Ronaldo
The second from the left is a sphere.
All the rest could be done using cylinder.
The middle could be a cube.
The second from right could be a sphere.

See how OpenSCAD has warped me? When I first started using OpenSCAD, I was really annoyed by all of this. I wanted sphere to always produce a sphere, cylinder to always produce a cylinder, etc.

I am still in favour of adding prism(), pyramid() and cone(), even though you would normally do those using cylinder().

On 2 April 2016 at 14:21, Ronaldo <[hidden email]> wrote:
nophead wrote
> There are no true spheres, cylinders, circles or curves in OpenScad once
> the renderings starts. All the geometry is represented by polygons and
> polyhedra.

This is a quiz :) The following image is the preview of translated
primitives. No boolean operations, no rotation, neither scale nor mirror.
How to get them?

<http://forum.openscad.org/file/n16907/primitives.png>



--
View this message in context: http://forum.openscad.org/Newbie-with-rotation-problem-tp16873p16907.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org




_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
rew
Reply | Threaded
Open this post in threaded view
|

Re: Newbie with rotation problem

rew
On Sat, Apr 02, 2016 at 02:57:39PM -0400, doug moen wrote:
> See how OpenSCAD has warped me? When I first started using OpenSCAD, I was
> really annoyed by all of this. I wanted sphere to always produce a sphere,
> cylinder to always produce a cylinder, etc.

IMHO, it is fine if openscad has to "simplify" cylinders to extruded
polygons. However, in writing code, it would be best to assume that
the implementation reserves the right to use the simplification OR
BETTER.

That means that the triangular prism could suddenly upgrade to a
perfect cylinder if say the output format directly supports cylinders.

But alas, it has become customary to exploit the defects of the
implementation so that now there is no way back.

> I am still in favour of adding prism(), pyramid() and cone(), even though
> you would normally do those using cylinder().

Those would, be oneliner modules, right? There is a "system" library
now, so it could be added there, right?

        Roger.

--
** [hidden email] ** http://www.BitWizard.nl/ ** +31-15-2600998 **
**    Delftechpark 26 2628 XH  Delft, The Netherlands. KVK: 27239233    **
*-- BitWizard writes Linux device drivers for any device you may have! --*
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Newbie with rotation problem

Ronaldo
In reply to this post by fred_dot_u
fred_dot_u wrote
It would appear that a good part of the answer to your question lies here:

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids

Some of the answer involves low values of $fn along with cylinders of different r1 and r2 values.

Do you already know the answers and this is a true quiz, or are you seeking a solution?
You are right. I generated the image so it is really a quiz.
12