T
thomas-hn
Wed, Oct 11, 2017 8:39 PM
Hello,
I'm relatively new to OpenScad and are working on my first bigger project
right now.
There the following question came up for which I tried to search for
existing discussions here, without success
Is it possible to place a polygon in 3D space and not only on the x/y-plane?
I would like to have a polygon with its vertices (points) at defined
coordinates in 3D space (x,y,z) and then to linearextrude this polygon. Do I
have to use a polyhedron instead? If I got it correctly from the polyhedron
description it cannot be flat, so I have to "linearextrude" it myself by
placing all the vertices at the correct positions in 3D space and not only
my known vertices of the base face.
Any ideas?
Thanks a lot in advance,
Thomas
--
Sent from: http://forum.openscad.org/
Hello,
I'm relatively new to OpenScad and are working on my first bigger project
right now.
There the following question came up for which I tried to search for
existing discussions here, without success
Is it possible to place a polygon in 3D space and not only on the x/y-plane?
I would like to have a polygon with its vertices (points) at defined
coordinates in 3D space (x,y,z) and then to linearextrude this polygon. Do I
have to use a polyhedron instead? If I got it correctly from the polyhedron
description it cannot be flat, so I have to "linearextrude" it myself by
placing all the vertices at the correct positions in 3D space and not only
my known vertices of the base face.
Any ideas?
Thanks a lot in advance,
Thomas
--
Sent from: http://forum.openscad.org/
NH
nop head
Wed, Oct 11, 2017 8:53 PM
You can linear_extrude() a polygon to make a flat polyhedron that can be
placed in 3D space.
On 11 October 2017 at 21:39, thomas-hn thomas-hn@gmx.de wrote:
Hello,
I'm relatively new to OpenScad and are working on my first bigger project
right now.
There the following question came up for which I tried to search for
existing discussions here, without success
Is it possible to place a polygon in 3D space and not only on the
x/y-plane?
I would like to have a polygon with its vertices (points) at defined
coordinates in 3D space (x,y,z) and then to linearextrude this polygon. Do
I
have to use a polyhedron instead? If I got it correctly from the polyhedron
description it cannot be flat, so I have to "linearextrude" it myself by
placing all the vertices at the correct positions in 3D space and not only
my known vertices of the base face.
Any ideas?
Thanks a lot in advance,
Thomas
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
You can linear_extrude() a polygon to make a flat polyhedron that can be
placed in 3D space.
On 11 October 2017 at 21:39, thomas-hn <thomas-hn@gmx.de> wrote:
> Hello,
>
> I'm relatively new to OpenScad and are working on my first bigger project
> right now.
> There the following question came up for which I tried to search for
> existing discussions here, without success
>
> Is it possible to place a polygon in 3D space and not only on the
> x/y-plane?
>
> I would like to have a polygon with its vertices (points) at defined
> coordinates in 3D space (x,y,z) and then to linearextrude this polygon. Do
> I
> have to use a polyhedron instead? If I got it correctly from the polyhedron
> description it cannot be flat, so I have to "linearextrude" it myself by
> placing all the vertices at the correct positions in 3D space and not only
> my known vertices of the base face.
>
> Any ideas?
>
> Thanks a lot in advance,
>
> Thomas
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
F
fred_dot_u
Wed, Oct 11, 2017 9:02 PM
I'm far from a wizard when it comes to openSCAD, but terminology and
application is important. For the purposes of this discussion, one must
consider that a polygon is a multi-sided shape on a flat plane. Once created
using the polygon command, one can rotate it in 3-space. If you extrude it
as part of the operation, you can rotate it as well.
Moving to another part of your question, if your objective is a solid that
is going to have specific points in space, you can pick any three to make a
plane and use those points to create polyhedra.
I'm not sure about your reference suggesting that the polyhedron description
not be flat, as the wiki specifies that "faces" must be in the same plane,
which implies that they are flat.
When you suggest to use linear_extrude, do you require/desire to have
vertical sides prior to any rotation?
--
Sent from: http://forum.openscad.org/
I'm far from a wizard when it comes to openSCAD, but terminology and
application is important. For the purposes of this discussion, one must
consider that a polygon is a multi-sided shape on a flat plane. Once created
using the polygon command, one can rotate it in 3-space. If you extrude it
as part of the operation, you can rotate it as well.
Moving to another part of your question, if your objective is a solid that
is going to have specific points in space, you can pick any three to make a
plane and use those points to create polyhedra.
I'm not sure about your reference suggesting that the polyhedron description
not be flat, as the wiki specifies that "faces" must be in the same plane,
which implies that they are flat.
When you suggest to use linear_extrude, do you require/desire to have
vertical sides prior to any rotation?
--
Sent from: http://forum.openscad.org/
YA
Yona Appletree
Wed, Oct 11, 2017 9:25 PM
Thomas,
You can only define polygons in 2d space, but this shouldn’t be too much of a limitation. All points in a polygon must be on the same plane, so if you defined it in 3d space, it would be easy to have an invalid polygon.
The best way to do what you want is probably:
Given your set of 3d points, compute a transform so they all lay on the plane
Use polygon() to render that set of points
Use linear_extrude() to create a 3d shape from those points
Apply the inverse of the original transform to put the 3d shape into place
On Oct 11, 2017, at 13:39, thomas-hn thomas-hn@gmx.de wrote:
Hello,
I'm relatively new to OpenScad and are working on my first bigger project
right now.
There the following question came up for which I tried to search for
existing discussions here, without success
Is it possible to place a polygon in 3D space and not only on the x/y-plane?
I would like to have a polygon with its vertices (points) at defined
coordinates in 3D space (x,y,z) and then to linearextrude this polygon. Do I
have to use a polyhedron instead? If I got it correctly from the polyhedron
description it cannot be flat, so I have to "linearextrude" it myself by
placing all the vertices at the correct positions in 3D space and not only
my known vertices of the base face.
Any ideas?
Thanks a lot in advance,
Thomas
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Thomas,
You can only define polygons in 2d space, but this shouldn’t be too much of a limitation. All points in a polygon must be on the same plane, so if you defined it in 3d space, it would be easy to have an invalid polygon.
The best way to do what you want is probably:
Given your set of 3d points, compute a transform so they all lay on the plane
Use polygon() to render that set of points
Use linear_extrude() to create a 3d shape from those points
Apply the inverse of the original transform to put the 3d shape into place
> On Oct 11, 2017, at 13:39, thomas-hn <thomas-hn@gmx.de> wrote:
>
> Hello,
>
> I'm relatively new to OpenScad and are working on my first bigger project
> right now.
> There the following question came up for which I tried to search for
> existing discussions here, without success
>
> Is it possible to place a polygon in 3D space and not only on the x/y-plane?
>
> I would like to have a polygon with its vertices (points) at defined
> coordinates in 3D space (x,y,z) and then to linearextrude this polygon. Do I
> have to use a polyhedron instead? If I got it correctly from the polyhedron
> description it cannot be flat, so I have to "linearextrude" it myself by
> placing all the vertices at the correct positions in 3D space and not only
> my known vertices of the base face.
>
> Any ideas?
>
> Thanks a lot in advance,
>
> Thomas
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
T
thomas-hn
Wed, Oct 11, 2017 9:27 PM
Maybe let's start my question in another way. For example, we have four
vertices [2, 2, 2], [2, 8, 8], [7, 2, 2], [7, 8, 8] and let's create a face
between them and "linearextrude" this.
It is important to have such four vertices at exact the mentioned positions.
How would you create the 3D object? Please also consider that it is not
ensured that all four vertices are placed so "friendly" as in the example,
they could also be somehow rotatet in space.
Is there a way to create the 3D object which has its four bottom vertices at
the given coordinates without a lot of calculations and
transforming/rotating a cube?
fred_dot_u wrote
I'm not sure about your reference suggesting that the polyhedron
description
not be flat, as the wiki specifies that "faces" must be in the same plane,
which implies that they are flat.
When you suggest to use linear_extrude, do you require/desire to have
vertical sides prior to any rotation?
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Maybe let's start my question in another way. For example, we have four
vertices [2, 2, 2], [2, 8, 8], [7, 2, 2], [7, 8, 8] and let's create a face
between them and "linearextrude" this.
It is important to have such four vertices at exact the mentioned positions.
How would you create the 3D object? Please also consider that it is not
ensured that all four vertices are placed so "friendly" as in the example,
they could also be somehow rotatet in space.
Is there a way to create the 3D object which has its four bottom vertices at
the given coordinates without a lot of calculations and
transforming/rotating a cube?
fred_dot_u wrote
> I'm not sure about your reference suggesting that the polyhedron
> description
> not be flat, as the wiki specifies that "faces" must be in the same plane,
> which implies that they are flat.
>
> When you suggest to use linear_extrude, do you require/desire to have
> vertical sides prior to any rotation?
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@.openscad
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
--
Sent from: http://forum.openscad.org/
T
thomas-hn
Wed, Oct 11, 2017 9:30 PM
This sounds like an interesting solution, thanks
However, has anyone an even simpler solution?
Hypher wrote
The best way to do what you want is probably:
Given your set of 3d points, compute a transform so they all lay on the
plane
Use polygon() to render that set of points
Use linear_extrude() to create a 3d shape from those points
Apply the inverse of the original transform to put the 3d shape into place
This sounds like an interesting solution, thanks
However, has anyone an even simpler solution?
Hypher wrote
> The best way to do what you want is probably:
> Given your set of 3d points, compute a transform so they all lay on the
> plane
> Use polygon() to render that set of points
> Use linear_extrude() to create a 3d shape from those points
> Apply the inverse of the original transform to put the 3d shape into place
--
Sent from: http://forum.openscad.org/
AB
Antonio Bueno
Wed, Oct 11, 2017 10:00 PM
Well, if you don't mind the extra faces, this is pretty simple:
hull()
for(p=[[2,2,2], [2,8,8], [7,2,2], [7,8,8]])
translate(p) cube(0.000002, true);
Something funny. My first try was without the for, and it worked with cubes
as small as 1E-99, but with the for loop, it doesn't work with cubes of
size 1E-6.
2017-10-11 23:30 GMT+02:00 thomas-hn thomas-hn@gmx.de:
This sounds like an interesting solution, thanks
However, has anyone an even simpler solution?
Hypher wrote
The best way to do what you want is probably:
Given your set of 3d points, compute a transform so they all lay on the
plane
Use polygon() to render that set of points
Use linear_extrude() to create a 3d shape from those points
Apply the inverse of the original transform to put the 3d shape into
--
Regards from Spain,
Antonio
Well, if you don't mind the extra faces, this is pretty simple:
hull()
for(p=[[2,2,2], [2,8,8], [7,2,2], [7,8,8]])
translate(p) cube(0.000002, true);
Something funny. My first try was without the for, and it worked with cubes
as small as 1E-99, but with the for loop, it doesn't work with cubes of
size 1E-6.
2017-10-11 23:30 GMT+02:00 thomas-hn <thomas-hn@gmx.de>:
> This sounds like an interesting solution, thanks
> However, has anyone an even simpler solution?
>
>
> Hypher wrote
> > The best way to do what you want is probably:
> > Given your set of 3d points, compute a transform so they all lay on the
> > plane
> > Use polygon() to render that set of points
> > Use linear_extrude() to create a 3d shape from those points
> > Apply the inverse of the original transform to put the 3d shape into
> place
>
>
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
--
Regards from Spain,
Antonio
RP
Ronaldo Persiano
Wed, Oct 11, 2017 11:20 PM
A polygon in OpenSCAD is always a 2D shape on the XY plane. You should not
apply geometric transformations on it that take it away from the XY plane
or you will be in trouble. For instance:
linear_extrude(40)
rotate([90,0,0])
square(20);
Additionally, you are allowed to linear_extrude 2D polygons only.
Following @Appletree, you should define your polygon in the XY plane,
extrude it and then move/rotate the 3D shape to the position you want it.
You can't avoid geometric transformations in this case. If you find the
normal vector of the plane containing the input 3D points ( a cross
product) the geometric transformations will be simple to compute:
// input points
p=[[2,2,2], [2,8,8], [7,8,8], [7,2,2]];
nrm = normal(p);
rot = frotFromTo(nrm,[0,0,1]); // compute the rotation to the XY plane
pxy = [for(pi=p) rot*pi]; // rotate the points to XY plane
p2d = [for(pxyi=pxy) [pxyi[0],pxyi[1]]]; // projects on 2D
rotFromTo([0,0,1], nrm)
linear_extrude(20)
polygon(p2d);
// normal to the triangle [ p[0], p[1], p[2] ]
function normal(p) = cross(p[1]-p[0], p[2]-p[1]);
// matrix of the transformation of mirroring along a direction
function fmirror(v) =
norm(v)==0 ? [[1,0,0],[0,1,0],[0,0,1]] :
let(u = v/norm(v))
[ [1,0,0] - 2*u[0]u, [0,1,0] - 2u[1]u, [0,0,1] - 2u[2]*u ];
// matrix of the minimum rotation that brings the vector di to the
direction do
function frotFromTo(di,do) =
norm(di-do)==0 || norm(di)==0 || norm(do)==0 ?
[[1,0,0],[0,1,0],[0,0,1]] :
fmirror(do/norm(do)+di/norm(di)) * fmirror(di);
// the minimum rotation that brings the vector di to the direction do
module rotFromTo(di,do)
if( norm(di-do)==0 || norm(di)==0 || norm(do)==0 )
children();
else
mirror(do/norm(do)+di/norm(di)) mirror(di) children();
This code does not check if the input points are coplanar. Anyway, it
generates a valid solid provided the first three input points are not
colinear.
2017-10-11 17:39 GMT-03:00 thomas-hn thomas-hn@gmx.de:
Hello,
I'm relatively new to OpenScad and are working on my first bigger project
right now.
There the following question came up for which I tried to search for
existing discussions here, without success
Is it possible to place a polygon in 3D space and not only on the
x/y-plane?
I would like to have a polygon with its vertices (points) at defined
coordinates in 3D space (x,y,z) and then to linearextrude this polygon. Do
I
have to use a polyhedron instead? If I got it correctly from the polyhedron
description it cannot be flat, so I have to "linearextrude" it myself by
placing all the vertices at the correct positions in 3D space and not only
my known vertices of the base face.
Any ideas?
Thanks a lot in advance,
Thomas
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
A polygon in OpenSCAD is always a 2D shape on the XY plane. You should not
apply geometric transformations on it that take it away from the XY plane
or you will be in trouble. For instance:
linear_extrude(40)
rotate([90,0,0])
square(20);
Additionally, you are allowed to linear_extrude 2D polygons only.
Following @Appletree, you should define your polygon in the XY plane,
extrude it and then move/rotate the 3D shape to the position you want it.
You can't avoid geometric transformations in this case. If you find the
normal vector of the plane containing the input 3D points ( a cross
product) the geometric transformations will be simple to compute:
// input points
p=[[2,2,2], [2,8,8], [7,8,8], [7,2,2]];
nrm = normal(p);
rot = frotFromTo(nrm,[0,0,1]); // compute the rotation to the XY plane
pxy = [for(pi=p) rot*pi]; // rotate the points to XY plane
p2d = [for(pxyi=pxy) [pxyi[0],pxyi[1]]]; // projects on 2D
rotFromTo([0,0,1], nrm)
linear_extrude(20)
polygon(p2d);
// normal to the triangle [ p[0], p[1], p[2] ]
function normal(p) = cross(p[1]-p[0], p[2]-p[1]);
// matrix of the transformation of mirroring along a direction
function fmirror(v) =
norm(v)==0 ? [[1,0,0],[0,1,0],[0,0,1]] :
let(u = v/norm(v))
[ [1,0,0] - 2*u[0]*u, [0,1,0] - 2*u[1]*u, [0,0,1] - 2*u[2]*u ];
// matrix of the minimum rotation that brings the vector di to the
direction do
function frotFromTo(di,do) =
norm(di-do)==0 || norm(di)==0 || norm(do)==0 ?
[[1,0,0],[0,1,0],[0,0,1]] :
fmirror(do/norm(do)+di/norm(di)) * fmirror(di);
// the minimum rotation that brings the vector di to the direction do
module rotFromTo(di,do)
if( norm(di-do)==0 || norm(di)==0 || norm(do)==0 )
children();
else
mirror(do/norm(do)+di/norm(di)) mirror(di) children();
This code does not check if the input points are coplanar. Anyway, it
generates a valid solid provided the first three input points are not
colinear.
2017-10-11 17:39 GMT-03:00 thomas-hn <thomas-hn@gmx.de>:
> Hello,
>
> I'm relatively new to OpenScad and are working on my first bigger project
> right now.
> There the following question came up for which I tried to search for
> existing discussions here, without success
>
> Is it possible to place a polygon in 3D space and not only on the
> x/y-plane?
>
> I would like to have a polygon with its vertices (points) at defined
> coordinates in 3D space (x,y,z) and then to linearextrude this polygon. Do
> I
> have to use a polyhedron instead? If I got it correctly from the polyhedron
> description it cannot be flat, so I have to "linearextrude" it myself by
> placing all the vertices at the correct positions in 3D space and not only
> my known vertices of the base face.
>
> Any ideas?
>
> Thanks a lot in advance,
>
> Thomas
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
A
arnholm@arnholm.org
Thu, Oct 12, 2017 7:16 AM
On 2017-10-11 22:39, thomas-hn wrote:
Is it possible to place a polygon in 3D space and not only on the
x/y-plane?
As others have indicated, a polygon is a 2d entity that by definition in
OpenSCAD exists in the XY plane. This could be seen as a specialization
of the mathematical term "polygon".
You may perhaps want to look at OpenSCAD polyhedron instead, which uses
3d coordinates. It is supposed to have flat faces that are in fact
mathematical polygons.
Carsten Arnholm
On 2017-10-11 22:39, thomas-hn wrote:
> Is it possible to place a polygon in 3D space and not only on the
> x/y-plane?
As others have indicated, a polygon is a 2d entity that by definition in
OpenSCAD exists in the XY plane. This could be seen as a specialization
of the mathematical term "polygon".
You may perhaps want to look at OpenSCAD polyhedron instead, which uses
3d coordinates. It is supposed to have flat faces that are in fact
mathematical polygons.
Carsten Arnholm
RP
Ronaldo Persiano
Thu, Oct 12, 2017 8:13 AM
My last code works because the plane through the input points contains
the origin. In a general case, we need to do translations besides the
rotations. Two additional code lines solves this issue.
// input points
p=[[2,2,2+10], [2,8,8+10], [7,8,8+10], [7,2,2+10]]; // changed to not be
coplanar with the origin
nrm = normal(p);
rot = frotFromTo(nrm,[0,0,1]); // compute the rotation to the XY plane
pxy = [for(pi=p) rot*pi]; // rotate the points to XY plane
p2d = [for(pxyi=pxy) [pxyi[0],pxyi[1]]]; // projects on 2D
dis = pxy[0][2]; // compute the displacement of the projection
rotFromTo([0,0,1], nrm)
translate([0,0,dis]) // translate it back
linear_extrude(20)
polygon(p2d);
%color("red") poly(p);
module poly(p)
hull() for(pi=p) translate(pi) cube(0.0001,center=true);
The red polygon is drawn here as a check reference of the input polygon.
My last code works because the plane through the input points contains
the origin. In a general case, we need to do translations besides the
rotations. Two additional code lines solves this issue.
// input points
p=[[2,2,2+10], [2,8,8+10], [7,8,8+10], [7,2,2+10]]; // changed to not be
coplanar with the origin
nrm = normal(p);
rot = frotFromTo(nrm,[0,0,1]); // compute the rotation to the XY plane
pxy = [for(pi=p) rot*pi]; // rotate the points to XY plane
p2d = [for(pxyi=pxy) [pxyi[0],pxyi[1]]]; // projects on 2D
dis = pxy[0][2]; // compute the displacement of the projection
rotFromTo([0,0,1], nrm)
translate([0,0,dis]) // translate it back
linear_extrude(20)
polygon(p2d);
%color("red") poly(p);
module poly(p)
hull() for(pi=p) translate(pi) cube(0.0001,center=true);
The red polygon is drawn here as a check reference of the input polygon.