rather than remembering all the coordinates, it is convenient if turtle
type movement is defined
e.g. rather than writing a list like [[0,0],[0,50],[30,50],[30,0]] it
would be convenient to write [[0,0],[0,50],[30,0],[0,-50]] and still get
the same coordinates. I have found this to be better for complex shapes.
for finding the radius at corners angle between the 2 lines joining the
corner needs to be calculated first.
center point of radius, tangent point at 2 joining lines, angle of rotation
based on the 2 points obtained and then draw an arc with all this
information.
Apart from this it also depends on the length of the lines and the radius
defined on the adjacent corners are also important e.g. if the tangent
points are crossing on a line it would be an invalid geometry. so you need
to check for the user input and stop with an error message in such a case.
you can refer to an example attached here
for this to work you need to keep both these files in the same folder and
also a latest version of openscad maybe 2021 should work
On Sun, 27 Mar 2022 at 04:57, Jan Öhman via Discuss <
discuss@lists.openscad.org> wrote:
---------- Forwarded message ----------
From: "Jan Öhman" jan_ohman@yahoo.com
To: "Jan Öhman via Discuss" discuss@lists.openscad.org
Cc:
Bcc:
Date: Sat, 26 Mar 2022 23:27:26 +0000 (UTC)
Subject: [OpenSCAD] Re: Create [x,y] - 2D values from a formula to a
polygon
Excuse me - it should be clockwise (not counterclockweis in the example)
Found an example that almost does what I want.
but,
this example below works counterclockwise - 0 degrees is to the right.
Is it complicated to make it work clockwise?
after that, there are probably only a number of calculations that need to
be created.
x = 10;
y = 0;
startDeg = 10;
stopDeg = 45;
radius = 10;
angles = [startDeg, stopDeg];
points = [
for(a = [angles[0] : 1 : angles[1]]) [radius * cos(a), radius * sin(a)]
];
polygon(concat([[0, 0]], points));
Den lördag 26 mars 2022 23:42:50 CET, Jan Öhman via Discuss <
discuss@lists.openscad.org> skrev:
Yes! (I hope I can explain)
I found a tip (but I do not understand what happens and how to use it in
my case.)
radius = 10;
fn = 18; // The shape
v1 = circv(radius, fn);
dispv(v1);
// create 2d vector shape: circle
function circv(r=1, fn=32) =
[ for(i=[0 : fn-1]) [rcos(360i/fn),rsin(360i/fn)] ];
// display a 2d vector shape
module dispv(v){
indi = [[for(i=[0 : len(v)-1])i]];
polygon(points=v, paths=indi);
}
This code above, creates a 2D circle (360 degrees).
My wish - the example below is not easy to give, because I do not know
the conditions of the solution
(eg. I have no idea if the circle spins clockwise or counterclockwise.)
Asume the following .:
Values to be specified
An example of values
x=10; // start pos X
y=0; // start pos Y
rad=10; // center of the circle is [10,10]
startDeg = 0; // at the bottom of the circle
stopDeg = 90; // if counterclockwise
the result 2D circle sector is begin at [10,0] and end at [0,10]
Preferably if it can be solved with e.g. one function() like this .:
points = circSec(x, y, startDeg, stopDeg, rad)
and
polygon(points);
Is it possible?
Den lördag 26 mars 2022 21:48:25 CET, Father Horton <
fatherhorton@gmail.com> skrev:
The various libraries can do that. If I don't want to use a library, I'll
use hull, like this:
p1a = [ 0, 0];
p2a = [ 0, 50];
p3a = [30, 50];
p4a = [30, 0];
radie = 5;
p1b = [p1a.x + radie, p1a.y + radie];
p2b = [p2a.x + radie, p2a.y - radie];
p3b = [p3a.x - radie, p3a.y - radie];
p4b = [p4a.x - radie, p4a.y + radie];
hull() {
translate(p1b) circle(radie);
translate(p2b) circle(radie);
translate(p3b) circle(radie);
translate(p4b) circle(radie);
};
On Sat, Mar 26, 2022 at 2:44 PM Jan Öhman via Discuss <
discuss@lists.openscad.org> wrote:
---------- Forwarded message ----------
From: "Jan Öhman" jan_ohman@yahoo.com
To: OpenSCAD General Discussion discuss@lists.openscad.org
Cc:
Bcc:
Date: Sat, 26 Mar 2022 19:45:07 +0000 (UTC)
Subject: [OpenSCAD] Create [x,y] - 2D values from a formula to a polygon
Hi! (Hope I describe it correctly)
My wish is to create 2D contours to be able to produce a polygon.
To manually create a square, this works:
p1a = [ 0, 0];
p2a = [ 0, 50];
p3a = [30, 50];
p4a = [30, 0];
color("cyan")
polygon([p1a, p2a, p3a, p4a]);
Started trying to manually round the corners (it also works)
xSize = 30;
ySize = 50;
radie = 5;
rad1 = radie/3.5;
p01b = [ radie, 0];
p02b = [ rad1, rad1];
p03b = [ 0, radie];
p04b = [ 0, ySize-radie];
p05b = [ rad1, ySize-rad1];
p06b = [ radie, ySize];
p07b = [ xSize-radie, ySize];
p08b = [ xSize-rad1, ySize-rad1];
p09b = [ xSize, ySize-radie];
p10b = [ xSize, radie];
p11b = [ xSize-rad1, rad1];
p12b = [ xSize-radie, 0];
polygon([p01b, p02b, p03b, p04b, p05b, p06b, p07b, p08b, p09b, p10b, p11b,
p12b ]);
But I want more rounded corners. (it is possible, but quickly becomes many
x, y-values, (only for the corners)
Do not know how to set up an equation that creates desired [x, y] values
that are adapted to the instruction .: polygon([]);
In this case, two equations are needed
Maybe only the start and stop values are needed for the corners? (then a
straight line is created between the corners automatically) No problem
adding an extra corner later?
But how to do this?
---------- Forwarded message ----------
From: "Jan Öhman via Discuss" discuss@lists.openscad.org
To: OpenSCAD General Discussion discuss@lists.openscad.org
Cc: "Jan Öhman" jan_ohman@yahoo.com
Bcc:
Date: Sat, 26 Mar 2022 19:45:07 +0000 (UTC)
Subject: [OpenSCAD] Create [x,y] - 2D values from a formula to a polygon
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
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
---------- Forwarded message ----------
From: "Jan Öhman via Discuss" discuss@lists.openscad.org
To: "Jan Öhman via Discuss" discuss@lists.openscad.org
Cc: "Jan Öhman" jan_ohman@yahoo.com
Bcc:
Date: Sat, 26 Mar 2022 23:27:26 +0000 (UTC)
Subject: [OpenSCAD] Re: Create [x,y] - 2D values from a formula to a
polygon
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org