Hi,

Guest

SL

Steve Lelievre

Tue, Aug 13, 2024 6:18 PM

Is there a way in OpenSCAD to distort a shape based on some kind of

function that takes the x,y,z coordinates of the vertices and modifies

them to produce a new x,y,z?

Specifically, I have a shape that I want to stretch in the x direction

by a percentage that depends on the point's y value. It would produce

something like the distortion in the sketch below - except that my shape

is more complex than a simple rectangle or cuboid. I've had a look at

multmatrix but even with that I can't see a direct way to do what I want.

Any suggestions?

Thanks,

Steve

Is there a way in OpenSCAD to distort a shape based on some kind of
function that takes the x,y,z coordinates of the vertices and modifies
them to produce a new x,y,z?
Specifically, I have a shape that I want to stretch in the x direction
by a percentage that depends on the point's y value. It would produce
something like the distortion in the sketch below - except that my shape
is more complex than a simple rectangle or cuboid. I've had a look at
multmatrix but even with that I can't see a direct way to do what I want.
Any suggestions?
Thanks,
Steve

CA

Carsten Arnholm

Tue, Aug 13, 2024 6:42 PM

On 2024-08-13 20:18, Steve Lelievre via Discuss wrote:

Is there a way in OpenSCAD to distort a shape based on some kind of

function that takes the x,y,z coordinates of the vertices and modifies

them to produce a new x,y,z?

The answer is no, not in OpenSCAD.

The best you can do is save the shape to a file, such as e.g. OBJ and

then modify the vertices in separate software. Example

https://gist.github.com/arnholm/af72c7d0790bb3d72e6bdf29c7aac1ed

On 2024-08-13 20:18, Steve Lelievre via Discuss wrote:
> Is there a way in OpenSCAD to distort a shape based on some kind of
> function that takes the x,y,z coordinates of the vertices and modifies
> them to produce a new x,y,z?
The answer is no, not in OpenSCAD.
The best you can do is save the shape to a file, such as e.g. OBJ and
then modify the vertices in separate software. Example
https://gist.github.com/arnholm/af72c7d0790bb3d72e6bdf29c7aac1ed

DP

Dan Perry

Tue, Aug 13, 2024 6:56 PM

A very simplistic way, and something I use a lot:

function y_at_x(x) = x*sin(30);

points=[x0, y_at_x(x0)], [x1, y_at_x(x1)], etc etc.

On Tue, Aug 13, 2024 at 7:19 PM Steve Lelievre via Discuss <

discuss@lists.openscad.org> wrote:

Is there a way in OpenSCAD to distort a shape based on some kind of

function that takes the x,y,z coordinates of the vertices and modifies them

to produce a new x,y,z?

Specifically, I have a shape that I want to stretch in the x direction by

a percentage that depends on the point's y value. It would produce

something like the distortion in the sketch below - except that my shape is

more complex than a simple rectangle or cuboid. I've had a look at

multmatrix but even with that I can't see a direct way to do what I want.

Any suggestions?

Thanks,

Steve

OpenSCAD mailing list

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

A very simplistic way, and something I use a lot:
function y_at_x(x) = x*sin(30);
points=[x0, y_at_x(x0)], [x1, y_at_x(x1)], etc etc.
On Tue, Aug 13, 2024 at 7:19 PM Steve Lelievre via Discuss <
discuss@lists.openscad.org> wrote:
> Is there a way in OpenSCAD to distort a shape based on some kind of
> function that takes the x,y,z coordinates of the vertices and modifies them
> to produce a new x,y,z?
>
> Specifically, I have a shape that I want to stretch in the x direction by
> a percentage that depends on the point's y value. It would produce
> something like the distortion in the sketch below - except that my shape is
> more complex than a simple rectangle or cuboid. I've had a look at
> multmatrix but even with that I can't see a direct way to do what I want.
>
> Any suggestions?
>
> Thanks,
>
> Steve
>
>
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>

GB

Glenn Butcher

Tue, Aug 13, 2024 7:38 PM

Could you not define your shape as a polyhedron, then distort the points

with simple math?

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

On 8/13/2024 12:42 PM, Carsten Arnholm via Discuss wrote:

On 2024-08-13 20:18, Steve Lelievre via Discuss wrote:

function that takes the x,y,z coordinates of the vertices and modifies

them to produce a new x,y,z?

Could you not define your shape as a polyhedron, then distort the points
with simple math?
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids#polyhedron
On 8/13/2024 12:42 PM, Carsten Arnholm via Discuss wrote:
>
> On 2024-08-13 20:18, Steve Lelievre via Discuss wrote:
>> Is there a way in OpenSCAD to distort a shape based on some kind of
>> function that takes the x,y,z coordinates of the vertices and modifies
>> them to produce a new x,y,z?
>
>

GB

Glenn Butcher

Tue, Aug 13, 2024 7:40 PM

(might be a repeat, I sent the first attempt to the wrong address)

Could you not define the shape as a polyhedron, then do the distortion

directly on each point?

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

On 8/13/2024 12:42 PM, Carsten Arnholm via Discuss wrote:

On 2024-08-13 20:18, Steve Lelievre via Discuss wrote:

function that takes the x,y,z coordinates of the vertices and modifies

them to produce a new x,y,z?

The answer is no, not in OpenSCAD.

The best you can do is save the shape to a file, such as e.g. OBJ and

then modify the vertices in separate software. Example

https://gist.github.com/arnholm/af72c7d0790bb3d72e6bdf29c7aac1ed

OpenSCAD mailing list

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

(might be a repeat, I sent the first attempt to the wrong address)
Could you not define the shape as a polyhedron, then do the distortion
directly on each point?
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids#polyhedron
On 8/13/2024 12:42 PM, Carsten Arnholm via Discuss wrote:
>
> On 2024-08-13 20:18, Steve Lelievre via Discuss wrote:
>> Is there a way in OpenSCAD to distort a shape based on some kind of
>> function that takes the x,y,z coordinates of the vertices and modifies
>> them to produce a new x,y,z?
>
> The answer is no, not in OpenSCAD.
>
> The best you can do is save the shape to a file, such as e.g. OBJ and
> then modify the vertices in separate software. Example
> https://gist.github.com/arnholm/af72c7d0790bb3d72e6bdf29c7aac1ed
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org

SL

Steve Lelievre

Tue, Aug 13, 2024 11:03 PM

Thank you, Carsten. Your example looks like it's doing exactly the kind

of thing I want, and AngelCAD looks interesting for other reasons as

well. I'll take a good look at it.

I must thank Dan and Glenn for responding as well. Unfortunately, for my

shapes, I don't know where all the vertices are (because the geometry is

defined and transformed using standard OpenSCAD modules). However,

Carsten's answer got me wondering if there's a facility to convert an

STL directly into a OpenSCAD polyhedron. Sure enough, there is:

https://raviriley.github.io/STL-to-OpenSCAD-Converter/

So, as an alternative to using a different modeller, I could export my

shape to STL, then convert to a polyhedron, insert the polyhedron into

OpenSCAD, and manipulate it there per Glenn's suggestion.

My original question related to laying out engraved patterns on a

sundial, but both methods are general purpose and can help me with some

other projects.

Thanks,

Steve

On 2024-08-13 11:42 a.m., Carsten Arnholm wrote:

On 2024-08-13 20:18, Steve Lelievre via Discuss wrote:

function that takes the x,y,z coordinates of the vertices and modifies

them to produce a new x,y,z?

The answer is no, not in OpenSCAD.

The best you can do is save the shape to a file, such as e.g. OBJ and

then modify the vertices in separate software. Example

https://gist.github.com/arnholm/af72c7d0790bb3d72e6bdf29c7aac1ed

Thank you, Carsten. Your example looks like it's doing exactly the kind
of thing I want, and AngelCAD looks interesting for other reasons as
well. I'll take a good look at it.
I must thank Dan and Glenn for responding as well. Unfortunately, for my
shapes, I don't know where all the vertices are (because the geometry is
defined and transformed using standard OpenSCAD modules). However,
Carsten's answer got me wondering if there's a facility to convert an
STL directly into a OpenSCAD polyhedron. Sure enough, there is:
https://raviriley.github.io/STL-to-OpenSCAD-Converter/
So, as an alternative to using a different modeller, I could export my
shape to STL, then convert to a polyhedron, insert the polyhedron into
OpenSCAD, and manipulate it there per Glenn's suggestion.
My original question related to laying out engraved patterns on a
sundial, but both methods are general purpose and can help me with some
other projects.
Thanks,
Steve
On 2024-08-13 11:42 a.m., Carsten Arnholm wrote:
>
> On 2024-08-13 20:18, Steve Lelievre via Discuss wrote:
>> Is there a way in OpenSCAD to distort a shape based on some kind of
>> function that takes the x,y,z coordinates of the vertices and modifies
>> them to produce a new x,y,z?
>
> The answer is no, not in OpenSCAD.
>
> The best you can do is save the shape to a file, such as e.g. OBJ and
> then modify the vertices in separate software. Example
> https://gist.github.com/arnholm/af72c7d0790bb3d72e6bdf29c7aac1ed
--
https://www.gnomoni.ca
https://www.youtube.com/@gnomonica

RW

Raymond West

Tue, Aug 13, 2024 11:43 PM

If it's 2d, generated within openscad and you can export it as SVG, Then

it is It is quite straightforward to load the SVG into any text editor,

and search and replace to convert it into the point list polygon format

that can be cut and pasted back into openscad. It will need a bit of

work to locate it in the correct position (SVG's never appeared where

you thought they should be). I think there was a discussion on here a

few years ago about it.

But, AngelCAD is worth pursuing.

On 14/08/2024 00:03, Steve Lelievre via Discuss wrote:

Thank you, Carsten. Your example looks like it's doing exactly the

kind of thing I want, and AngelCAD looks interesting for other reasons

as well. I'll take a good look at it.

I must thank Dan and Glenn for responding as well. Unfortunately, for

my shapes, I don't know where all the vertices are (because the

geometry is defined and transformed using standard OpenSCAD modules).

However, Carsten's answer got me wondering if there's a facility to

convert an STL directly into a OpenSCAD polyhedron. Sure enough, there

is: https://raviriley.github.io/STL-to-OpenSCAD-Converter/

So, as an alternative to using a different modeller, I could export my

shape to STL, then convert to a polyhedron, insert the polyhedron into

OpenSCAD, and manipulate it there per Glenn's suggestion.

My original question related to laying out engraved patterns on a

sundial, but both methods are general purpose and can help me with

some other projects.

Thanks,

Steve

On 2024-08-13 11:42 a.m., Carsten Arnholm wrote:

On 2024-08-13 20:18, Steve Lelievre via Discuss wrote:

function that takes the x,y,z coordinates of the vertices and modifies

them to produce a new x,y,z?The answer is no, not in OpenSCAD.

then modify the vertices in separate software. Example

https://gist.github.com/arnholm/af72c7d0790bb3d72e6bdf29c7aac1ed

If it's 2d, generated within openscad and you can export it as SVG, Then
it is It is quite straightforward to load the SVG into any text editor,
and search and replace to convert it into the point list polygon format
that can be cut and pasted back into openscad. It will need a bit of
work to locate it in the correct position (SVG's never appeared where
you thought they should be). I think there was a discussion on here a
few years ago about it.
But, AngelCAD is worth pursuing.
On 14/08/2024 00:03, Steve Lelievre via Discuss wrote:
>
> Thank you, Carsten. Your example looks like it's doing exactly the
> kind of thing I want, and AngelCAD looks interesting for other reasons
> as well. I'll take a good look at it.
>
> I must thank Dan and Glenn for responding as well. Unfortunately, for
> my shapes, I don't know where all the vertices are (because the
> geometry is defined and transformed using standard OpenSCAD modules).
> However, Carsten's answer got me wondering if there's a facility to
> convert an STL directly into a OpenSCAD polyhedron. Sure enough, there
> is: https://raviriley.github.io/STL-to-OpenSCAD-Converter/
>
> So, as an alternative to using a different modeller, I could export my
> shape to STL, then convert to a polyhedron, insert the polyhedron into
> OpenSCAD, and manipulate it there per Glenn's suggestion.
>
> My original question related to laying out engraved patterns on a
> sundial, but both methods are general purpose and can help me with
> some other projects.
>
> Thanks,
>
> Steve
>
>
>
>
>
>
> On 2024-08-13 11:42 a.m., Carsten Arnholm wrote:
>>
>> On 2024-08-13 20:18, Steve Lelievre via Discuss wrote:
>>> Is there a way in OpenSCAD to distort a shape based on some kind of
>>> function that takes the x,y,z coordinates of the vertices and modifies
>>> them to produce a new x,y,z?
>>
>> The answer is no, not in OpenSCAD.
>>
>> The best you can do is save the shape to a file, such as e.g. OBJ and
>> then modify the vertices in separate software. Example
>> https://gist.github.com/arnholm/af72c7d0790bb3d72e6bdf29c7aac1ed
>

SL

Steve Lelievre

Wed, Aug 14, 2024 5:26 AM

Just a quick update on my inquiry about distorting vertices: by

combining advice from Carsten and Glenn, I was able to solve one of my

other problems - finding an easy way to engrave text on a cylinder and

get it looking good. Until I've either used positioned letters manually

or used a clumsy and process-intensive method involving creating dozens

of thin slices of a flat engraved shape, and standing them up to be

arranged as the facets of a cylinder.

Instead, today I used the new roof feature to turn text into 3D and then

scaled it by -1 in the z direction to create 'negative valleys' instead

of hills. I then exported the shape to STL and retrieved it as a a set

of points and faces using the converter at

https://raviriley.github.io/STL-to-OpenSCAD-Converter/ (note: the

converter produces faces that are wound in the opposite direction to

objects created within OpenSCAD, causing the subtraction to fail. You

may need to reverse the order of all the individual faces.)

A fairly simple rule applied to the points displaces them so that the

original flat text polyhedron is bent into a ring, which I then

subtracted from a cylinder using 'difference' to get the final shape.

Overall, it's easier and quicker than the ways I've done it before, and

a similar approach would work for raised text.

Steve

On 2024-08-13 4:03 p.m., Steve Lelievre wrote:

[I was] wondering if there's a facility to convert an STL directly

into a OpenSCAD polyhedron. Sure enough, there is:

https://raviriley.github.io/STL-to-OpenSCAD-Converter/

[...] I could export my shape to STL, then convert to a polyhedron,

insert the polyhedron into OpenSCAD, and manipulate it there [...]

Just a quick update on my inquiry about distorting vertices: by
combining advice from Carsten and Glenn, I was able to solve one of my
other problems - finding an easy way to engrave text on a cylinder and
get it looking good. Until I've either used positioned letters manually
or used a clumsy and process-intensive method involving creating dozens
of thin slices of a flat engraved shape, and standing them up to be
arranged as the facets of a cylinder.
Instead, today I used the new roof feature to turn text into 3D and then
scaled it by -1 in the z direction to create 'negative valleys' instead
of hills. I then exported the shape to STL and retrieved it as a a set
of points and faces using the converter at
https://raviriley.github.io/STL-to-OpenSCAD-Converter/ (note: the
converter produces faces that are wound in the opposite direction to
objects created within OpenSCAD, causing the subtraction to fail. You
may need to reverse the order of all the individual faces.)
A fairly simple rule applied to the points displaces them so that the
original flat text polyhedron is bent into a ring, which I then
subtracted from a cylinder using 'difference' to get the final shape.
Overall, it's easier and quicker than the ways I've done it before, and
a similar approach would work for raised text.
Steve
On 2024-08-13 4:03 p.m., Steve Lelievre wrote:
>
> [I was] wondering if there's a facility to convert an STL directly
> into a OpenSCAD polyhedron. Sure enough, there is:
> https://raviriley.github.io/STL-to-OpenSCAD-Converter/
>
> [...] I could export my shape to STL, then convert to a polyhedron,
> insert the polyhedron into OpenSCAD, and manipulate it there [...]

GS

Guenther Sohler

Wed, Aug 14, 2024 2:19 PM

looks similar to this one ...

https://www.reddit.com/r/pythonscad/comments/1cug84c/new_function_to_wrap_objects_around_a_cylinder/

main challenge when "bending" something is to split straight lines often

enough to be able to establish equidistant rounding

ps: no external tool needed

On Tue, Aug 13, 2024 at 10:27 PM Steve Lelievre via Discuss <

discuss@lists.openscad.org> wrote:

Just a quick update on my inquiry about distorting vertices: by combining

advice from Carsten and Glenn, I was able to solve one of my other problems

- finding an easy way to engrave text on a cylinder and get it looking

good. Until I've either used positioned letters manually or used a clumsy

and process-intensive method involving creating dozens of thin slices of a

flat engraved shape, and standing them up to be arranged as the facets of a

cylinder.

Instead, today I used the new roof feature to turn text into 3D and then

scaled it by -1 in the z direction to create 'negative valleys' instead of

hills. I then exported the shape to STL and retrieved it as a a set of

points and faces using the converter at

https://raviriley.github.io/STL-to-OpenSCAD-Converter/ (note: the

converter produces faces that are wound in the opposite direction to

objects created within OpenSCAD, causing the subtraction to fail. You may

need to reverse the order of all the individual faces.)

A fairly simple rule applied to the points displaces them so that the

original flat text polyhedron is bent into a ring, which I then subtracted

from a cylinder using 'difference' to get the final shape.

Overall, it's easier and quicker than the ways I've done it before, and a

similar approach would work for raised text.

Steve

On 2024-08-13 4:03 p.m., Steve Lelievre wrote:

[I was] wondering if there's a facility to convert an STL directly into a

OpenSCAD polyhedron. Sure enough, there is:

https://raviriley.github.io/STL-to-OpenSCAD-Converter/

[...] I could export my shape to STL, then convert to a polyhedron, insert

the polyhedron into OpenSCAD, and manipulate it there [...]

OpenSCAD mailing list

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

looks similar to this one ...
https://www.reddit.com/r/pythonscad/comments/1cug84c/new_function_to_wrap_objects_around_a_cylinder/
main challenge when "bending" something is to split straight lines often
enough to be able to establish equidistant rounding
ps: no external tool needed
On Tue, Aug 13, 2024 at 10:27 PM Steve Lelievre via Discuss <
discuss@lists.openscad.org> wrote:
> Just a quick update on my inquiry about distorting vertices: by combining
> advice from Carsten and Glenn, I was able to solve one of my other problems
> - finding an easy way to engrave text on a cylinder and get it looking
> good. Until I've either used positioned letters manually or used a clumsy
> and process-intensive method involving creating dozens of thin slices of a
> flat engraved shape, and standing them up to be arranged as the facets of a
> cylinder.
>
> Instead, today I used the new roof feature to turn text into 3D and then
> scaled it by -1 in the z direction to create 'negative valleys' instead of
> hills. I then exported the shape to STL and retrieved it as a a set of
> points and faces using the converter at
> https://raviriley.github.io/STL-to-OpenSCAD-Converter/ (note: the
> converter produces faces that are wound in the opposite direction to
> objects created within OpenSCAD, causing the subtraction to fail. You may
> need to reverse the order of all the individual faces.)
>
> A fairly simple rule applied to the points displaces them so that the
> original flat text polyhedron is bent into a ring, which I then subtracted
> from a cylinder using 'difference' to get the final shape.
>
> Overall, it's easier and quicker than the ways I've done it before, and a
> similar approach would work for raised text.
>
> Steve
>
>
> On 2024-08-13 4:03 p.m., Steve Lelievre wrote:
>
>
> [I was] wondering if there's a facility to convert an STL directly into a
> OpenSCAD polyhedron. Sure enough, there is:
> https://raviriley.github.io/STL-to-OpenSCAD-Converter/
>
> [...] I could export my shape to STL, then convert to a polyhedron, insert
> the polyhedron into OpenSCAD, and manipulate it there [...]
>
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>

SL

Steve Lelievre

Wed, Aug 14, 2024 4:55 PM

On 2024-08-14 7:19 a.m., Guenther Sohler via Discuss wrote:

looks similar to this one ...

https://www.reddit.com/r/pythonscad/comments/1cug84c/new_function_to_wrap_objects_around_a_cylinder/

For sure. Lots of ways of doing it, but I guess my underlying thought

was that the "export to STL - convert - reimport as polyhedron data"

method is fairly general and doable for people who aren't very techie,

and can apply to situations besides the one I asked about in my original

post.

ps: no external tool needed

PythonSCAD is a fork, isn't it? So to the average OpenSCAD user like me,

it is a separate tool that has to be installed and learned. I've been

told python doesn't have much of a learning curve but it is something

new to contend with. Still, I realize that I'm going to become a python

user one day, and I hope you will be able to merge it back into the

original OpenSCAD sooner rather than later.

Steve

On 2024-08-14 7:19 a.m., Guenther Sohler via Discuss wrote:
> looks similar to this one ...
>
> https://www.reddit.com/r/pythonscad/comments/1cug84c/new_function_to_wrap_objects_around_a_cylinder/
>
>
For sure. Lots of ways of doing it, but I guess my underlying thought
was that the "export to STL - convert - reimport as polyhedron data"
method is fairly general and doable for people who aren't very techie,
and can apply to situations besides the one I asked about in my original
post.
>
> ps: no external tool needed
>
PythonSCAD is a fork, isn't it? So to the average OpenSCAD user like me,
it is a separate tool that has to be installed and learned. I've been
told python doesn't have much of a learning curve but it is something
new to contend with. Still, I realize that I'm going to become a python
user one day, and I hope you will be able to merge it back into the
original OpenSCAD sooner rather than later.
Steve

Replying to:

Empathy v1.0
2024 ©Harmonylists.com