Close



Page 4 of 8 FirstFirst ... 23456 ... LastLast
Results 31 to 40 of 74
  1. #31
    Senior Engineer
    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);
    }
    }
    and this draws the bottom:

    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);
    }
    }
    But, this does not draw it correctly:

    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);
    }
    }
    It sticks the bottom half as an object in the centre. :baffled:


    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

  2. #32
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,182
    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.

  3. #33
    Senior Engineer
    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.

  4. #34
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,182
    Quote Originally Posted by Mjolinor View Post
    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.
    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.

  5. #35
    Senior Engineer
    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.

  6. #36
    Staff Engineer old man emu's Avatar
    Join Date
    Oct 2013
    Location
    Narellan, New South Wales, Australia
    Posts
    912

    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

  7. #37
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,182
    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));
    }

  8. #38
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,182
    Quote Originally Posted by old man emu View Post
    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.

    > we have ground to a halt

    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

  9. #39
    Senior Engineer
    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.

  10. #40
    Staff Engineer old man emu's Avatar
    Join Date
    Oct 2013
    Location
    Narellan, New South Wales, Australia
    Posts
    912
    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!

    OME
    Last edited by old man emu; 12-05-2014 at 07:52 PM.

Page 4 of 8 FirstFirst ... 23456 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •