Results 31 to 40 of 74
Thread: Need some geometry help
-
12-05-2014, 11:49 AM #31
- Join Date
- Jun 2014
- Location
- Burnley, UK
- Posts
- 1,662
I don't understand this. I think Openscad is running out of resources ror something.
This draws the toroid but why do I need the "assign" statement again.
r0 = 100;
r1 = 10;
for (v = [0:10:180])
{
for (u = [0:10:360])
{
assign (A = ((r0 + r1 * cos(v)) * cos (u)), B = ((r0 + r1 * cos(v)) * sin (u)), C = (r1 * sin(v)))
translate ([A,B,C])
sphere (r=1);
assign (A = ((r0 + r1 * cos(v)) * cos (u)), B = ((r0 + r1 * cos(v)) * sin (u)), C = (r1 * sin(v)))
translate ([A,B,-C])
sphere (r=1);
}
}
This draws the top:
r0 = 100;
r1 = 10;
for (v = [0:10:180])
{
for (u = [0:10:360])
{
assign (A = ((r0 + r1 * cos(v)) * cos (u)), B = ((r0 + r1 * cos(v)) * sin (u)), C = (r1 * sin(v)))
translate ([A,B,C])
sphere (r=1);
// translate ([A,B,-C])
// sphere (r=1);
}
}
r0 = 100;
r1 = 10;
for (v = [0:10:180])
{
for (u = [0:10:360])
{
assign (A = ((r0 + r1 * cos(v)) * cos (u)), B = ((r0 + r1 * cos(v)) * sin (u)), C = (r1 * sin(v)))
// translate ([A,B,C])
// sphere (r=1);
translate ([A,B,-C])
sphere (r=1);
}
}
r0 = 100;
r1 = 10;
for (v = [0:10:180])
{
for (u = [0:10:360])
{
assign (A = ((r0 + r1 * cos(v)) * cos (u)), B = ((r0 + r1 * cos(v)) * sin (u)), C = (r1 * sin(v)))
translate ([A,B,C])
sphere (r=1);
translate ([A,B,-C])
sphere (r=1);
}
}
Hmm, not so baffled, the assign statement only operates on the next statement so it does what it should in the above examples.
Last edited by Mjolinor; 12-05-2014 at 11:56 AM. Reason: Brain started working
-
12-05-2014, 01:10 PM #32
The assign() statement is to get around a limitation in the OpenScad architecture. Variables are assigned at compile time, not at execution time. Even things that look like the variable is changing value really are not happening. For example, in a for() statement, the index variable isn't changing value. The compiler is just producing multiple pieces of code in line with the values changed as appropriate.
Assign() is used to change and kludge around this fact.
Case and point... If you set a variable to some number in one place in you code. But then you change the variable to some other number in another place. The first place, when it uses that variable will get the 2nd value. Give it a try:
hhh=35;
cylinder(r=5,h=hhh);
hhh=2.5;
translate([20,0,0]) cylinder(r=5,h=hhh);
What do you get on your screen?
Did you notice I did not do intermediate calculations of (X,Y,Z). Instead, I just put the calculations inside a translate([]) so I did not need variables with the current values.
-
12-05-2014, 01:57 PM #33
- Join Date
- Jun 2014
- Location
- Burnley, UK
- Posts
- 1,662
What you do get is a message about openscad not liking so many points. The top example in my previous post works properly, it draws a torus. If you make it use more points then it stops drawing all the torus and only renders parts of it.
You will never be able to use Openscad to make usable complex shapes like these.
-
12-05-2014, 02:58 PM #34
OpenScad does have limitations. But I'm able to get reasonable looking shapes (and computation times) by not trying to calculate so many points. But now that I'm aware of OpenJScad, I'm thinking I am going to check it out and very likely switch to it.
Every programming language has limitations. And of course, they all have different strengths too. If they didn't have strength in certain areas, they wouldn't exist and would fall by the wayside.
-
12-05-2014, 03:15 PM #35
- Join Date
- Jun 2014
- Location
- Burnley, UK
- Posts
- 1,662
It does seem to have a lot of followers that is increasing but the fact that you cannot rotate extrude over a defined angle is a real killer.
I started with Autocad back when PCs were new then moved to Solidworks but had to give that up when I abandoned Windo$e. I've since been using Freecad and generally it does most of what I want. I am still undecided about Openscad, it doesn't seem logical and confuses me but the documentation up and down the net allow me to accomplish what I need relatively easily though it doesn't seem to stick. Probably just getting past it, 60 next time so decidedly over the hill, almost slippers and cat time.
-
12-05-2014, 04:31 PM #36
Reply from Dr Bourke
Here is the reply I got from Dr Bourke.
> I'm a hobbyist 3D printer and incompetent 3D object creator. At the moment I
> am trying to get my head around the Open Source program OpenScan.
I had never heard of that so had a play. Cute.
> we have ground to a halt
I don't see how to do it also. What ones needs to be able to do is
create both the profile as a polygon and then be able to control the
path through which it is revolved. I could not find out how to do the
first and the second certainly seems like it isn't supported.
It is easy to do with a C program, see attached along with
corresponding slt file. The top of the C program has the parameters
double r0=1.0,r1=0.25;
double n1=1.0,n2=0.2;
Here are the files he sent.
supertorus.c
supertorus.stl.zip
Have fun!!
OME
-
12-05-2014, 05:28 PM #37
So... The equations he specified are not real. He has defined a new pow() function that allows a negative number to be raised to a fractional power. Check out the very end of his .C file.
Code:double power(double f,double p) { int sign; double absf; sign = (f < 0 ? -1 : 1); absf = (f < 0 ? -f : f); if (absf < 0.00001) return(0.0); else return(sign * pow(absf,p)); }
-
12-05-2014, 05:39 PM #38
So, is Dr. Bourke a 3D-Printer hobbyist? Or is that quoted text from you. If he is the hobbyist, the OpenScad source code to do most of his toroid's is up above now....
Specifically: http://3dprintboard.com/showthread.p...ll=1#post38221
-
12-05-2014, 07:19 PM #39
- Join Date
- Jun 2014
- Location
- Burnley, UK
- Posts
- 1,662
I didn't use these equations: http://paulbourke.net/geometry/torus/supertoroid3.gif
I used the standard parametric equations for a torus:
x = (r0 + r1(cos(v))* cos(u)
y = (r0 + r1(cos(v))* sin(u)
z = r1 * sin(v)
Which I derived from the parametric equations for a circle:
x = r * cos(v)
y = r * sin(v)
by substituting for "r".Last edited by Mjolinor; 12-05-2014 at 08:18 PM.
-
12-05-2014, 07:46 PM #40
Re Paul Bourke:
http://www.ivec.uwa.edu.au/content/a...of-paul-bourke
Guess he's got a few more notches on his gun butt than most of us.
And he's an Aussie!
OMELast edited by old man emu; 12-05-2014 at 07:52 PM.
Printer will print perfect...
06-14-2024, 10:44 AM in Tips, Tricks and Tech Help