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: circlefunction circv(r=1, fn=32) = [ for(i=[0 : fn-1]) [rcos(360i/fn),rsin(360i/fn)] ];
// display a 2d vector shapemodule 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 .:- the circle is rotate counterclockwise.
- 0 degrees is at the bottom of the circle.
Values to be specified- a radius- the x-/y-vaules, where the circle is begin. (or the center of the circle)- the start degree.
- the stop degree.
An example of values
x=10; // start pos Xy=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
- straight line equation y=kx+m and the
- circle equation rr = (x-x0)(x-x0) + (y-y0)*(y-y0)
r= radius and x0, y0 is the middle of the circle.
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
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: circlefunction circv(r=1, fn=32) = [ for(i=[0 : fn-1]) [r*cos(360*i/fn),r*sin(360*i/fn)] ];
// display a 2d vector shapemodule 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 .:- the circle is rotate counterclockwise.
- 0 degrees is at the bottom of the circle.
Values to be specified- a radius- the x-/y-vaules, where the circle is begin. (or the center of the circle)- the start degree.
- the stop degree.
An example of values
x=10; // start pos Xy=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
- straight line equation y=kx+m and the
- circle equation r*r = (x-x0)*(x-x0) + (y-y0)*(y-y0)
r= radius and x0, y0 is the middle of the circle.
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