Close



Page 7 of 8 FirstFirst ... 5678 LastLast
Results 61 to 70 of 74
  1. #61
    Staff Engineer old man emu's Avatar
    Join Date
    Oct 2013
    Location
    Narellan, New South Wales, Australia
    Posts
    912
    Roxy, you put this up in post # 37:

    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));
    }

    would you explain what a pow() function is? I believe that function is recognised by Openscad

    OME

  2. #62
    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
    Roxy, you put this up in post # 37:
    would you explain what a pow() function is? I believe that function is recognised by Openscad
    pow() is common in computer languages. Some times the name shifts a little bit. Like in some computer languages you get a square root by using sqr(). But in others it might be spelled sqrt(). pow() is actually pretty consistent in its spelling and parameters across different languages.

    With that said, in both C and OpenScad the pow() function takes two parameters. The first number is the base and the second parameter is the exponent. pow(x,y) will raise x^y. Using a pow(3,4) would be equivalent to saying 3*3*3*3. You are raising 3 to the 4th power.

    This is all fun and games until somebody uses a negative base with a fractional power. Then you get an imaginary number! You can take the square root of a number (say 4) by saying pow(4,.5) This will raise 4^.5 power and you get 2. But what happens if the base is a negative number? Say -4? You can raise -4^2 without a problem. That is the same as saying (-4)*(-4) and you get 16. But trying to raise a negative number to a fractional power is undefined. In both the C math library and OpenScad the result is undefined! You can't do that. You lose an eye!

  3. #63
    Staff Engineer old man emu's Avatar
    Join Date
    Oct 2013
    Location
    Narellan, New South Wales, Australia
    Posts
    912
    From Dr Bourke:

    It's only a short note on the old page
    http://paulbourke.net/geometry/torus/

    "Note that with the normal definition of power the above equations are only defined for a single quadrant, namely that where the cosine and sine terms are positive.

    When creating the supertorus
    in practice one has two choices, either replicate the result in the one quadrant to the other three with the correct mirror operations, or define x^n = sign(x) * abs(x)^n."

    I guess when I was putting that text together back in 1990 I wasn't paying much attention to those details.

    OME




    Last edited by old man emu; 12-12-2014 at 02:04 AM.

  4. #64
    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
    From Dr Bourke:
    I guess when I was putting that text together back in 1990 I wasn't
    paying much attention to those details.

    OME
    When you cut and pasted that table, I wish you had included that text immediately before it!

    Update: You couldn't have included the 'warning' that preceded the table. The text that would have been helpful says:

    Note that with the normal definition of power the above equations are only defined for a single quadrant, namely that where the cosine and sine terms are positive. When creating the supertorus in practice one has two choices, either replicate the result in the one quadrant to the other three with the correct mirror operations, or define xn = sign(x) * abs(x)n.
    But of course... Using the Way Back machine, it used to read differently:

    http://web.archive.org/web/201404022...eometry/torus/
    It is different values of these powers which give rise to a family of 3D shapes all basically toroidal in shape. The value of n1 determines the shape of the torus ring, n2 determines the shape of the cross section of the ring.

    Examples of the supertoroid generated for different values of n1 and n2 are shown below, of course, the legal values of n1 and n2 form a continuum of values from 0 to infinity (although there are representation issues near 0 and above 4).

    Last edited by Roxy; 12-10-2014 at 08:21 AM.

  5. #65
    Staff Engineer old man emu's Avatar
    Join Date
    Oct 2013
    Location
    Narellan, New South Wales, Australia
    Posts
    912
    Hey! I just cuts and pastes them as I sees them.

    We should be happy that our discussion has lead him to revisit a bit of his early work. From his emails, I get the impression that he is a bit chuffed that people are looking at his work 25 years on from when he did it. He's done heaps of stuff. I suggest that you take a wander through here: http://paulbourke.net/

    He mentioned that for some of the 3D printing of his cultural images, he uses Shapeways. Here's my question and his reply:

    > How come you send your stls to Shapeways for printing. I would have thought that a university would have its own 3D printers.

    Sure, there are a few around, but I don't think that is cost effective or a good use of my time.
    For
    example, I print some pretty extreme things, things that cannot be handled by low cost machines. Many of the things I print require the finest detail possible especially some of the mathematical models, very thin structures only supported by the big end of town machines.

    Also, not everything I do is suited to a single machine type,
    traditionally one did colour on the ZCorp machines, find details on the Objet, metal on other machines ... so I would need a collection of
    printers. Don't want to sound conceited but I really do need things the very expensive machines can do ... for example, recently printed a 1/2m sphere of the earths oceans, small version here on the ZCorp http://paulbourke.net/miscellaneous/oceans/

    But the final version was a colour ObJet. Some of the packing theory stuff is printing down to 1/3mm threads, which structurally is challenging even the ObJet. And it's not just Shapeways, I have a Hong Kong company who print my really big models for a fraction of the Shapeways cost.

    By the way, if you want to see some really nice work work look up Henry Degerman, or on shapeways http://www.shapeways.com/shops/henryseg
    Another Aussie. :-) But in the USA now. Stunning work and really nice videos.

    OME
    Last edited by old man emu; 12-10-2014 at 06:13 PM.

  6. #66
    Senior Engineer
    Join Date
    Jun 2014
    Location
    Burnley, UK
    Posts
    1,662
    Why doesn't this work:

    It is supposed to make a toroid of any angle by making the full toroid with a rotate_extrude then subtracting a load of wedges from that toroid.

    The wedge bit works, the toroid bit works but the difference() doesn't work with any angle over 5 degrees. It makes no difference if I put the wedge in a union(), I thought it would.

    Parameters at the top, module for wedge at the bottom and the difference() bit in the middle between the //************************ lines. In that middle bit you can comment out either the toroid or the wedge and see that they perform as they should.

    If you are wondering about the little multipliers like 1.01 they are to make the wedge slightly bigger so it doesn't give zero thickness bits.

    Code:
    major_radius = 10;
    minor_radius = 4;
    angle = 70;
    
    
    //****************************************************
    
    
    difference()
        {
    // Make toroid
    //rotate_extrude(convexity = 10)    translate ([major_radius, minor_radius, 0])    circle (r = minor_radius);
    
    
    // Make wedge to remove
    wedge(major_radius, minor_radius, angle);
        }
    
    
    //****************************************************
    
    
    module wedge(major_radius, minor_radius, angle)
        {
        for (i = [0 : 1 : angle-1])
            {
        rotate(i)
            difference()
                {
                translate ([0,0,-0.05])
                cube ([(major_radius+minor_radius)*1.01,(major_radius+minor_radius)*sin(1) , 2*minor_radius*1.01]);
    
    
                rotate(1.01) // make is slightly bigger than the first rotate so no stringy bits
                translate ([0,0,-0.06])
                cube ([(major_radius+minor_radius)*1.02,(major_radius+minor_radius)*sin(2) , 2*minor_radius*1.05]);
                }
            }
        }

  7. #67
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,182

    Post

    Wouldn't it make more sense to construct the toroid, and then take an intersection() with something simpler like this:
    Code:
    difference() {     
             cylinder(r=25, h=15,$fn=50);
             translate([-100,-100,0]) cube([200,100,100]);
             translate([-100,0,0]) cube([100,100,100]);
             rotate([0,0,45]) cube([100,100,100]);
     }

  8. #68
    Senior Engineer
    Join Date
    Jun 2014
    Location
    Burnley, UK
    Posts
    1,662
    how would you remove a segment say 5 degrees wide with cubes though?

    OK, ignore that, talking out of it instead of sitting on it as usual.

    Still can't see it working all the way round, it can go from 0 to 270 missing with that method but you would need to go to difference for the remainder I think.

    I suppose an "if >180" would sort it and have two different modules, one for difference() and one for intersection()

  9. #69
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,182
    I guess I don't understand what you are trying to do. I instantiated wedge() and saw what it generated. It just seems way simpler to make a wedge another way.

  10. #70
    Senior Engineer
    Join Date
    Jun 2014
    Location
    Burnley, UK
    Posts
    1,662
    I am not really trying to do anything other than learn. I don't understand why my first one doesn't work, seems right to me.

    With the cubes it will probably work better but a lot harder to understand the angles and things.

Page 7 of 8 FirstFirst ... 5678 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
  •