Close



Page 3 of 8 FirstFirst 12345 ... LastLast
Results 21 to 30 of 74
  1. #21
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,182
    I wasn't able to leverage what you had... So I started with a blank screen in OpenScad.

    It turns out, you don't need a Cray Super Computer to do this. I just made 3 different toriods. I made the generic one with n1=1 and n2=1. And then I made a couple more just to make sure the code worked:

    Toriod.jpg

    UPDATE: Those equations might be flawed. Some of the possible toroids only generate 1 quadrant of the shape. For example, n1=2 and n2=1. You get the correct shape, but only 1/4 of the toroid. I think some of these toroid shapes are imaginary. The reason is this: You can't take a fractional power of a negative number. But X is defined by X= cos^n1(theta)*(r0+r1*cos^n2(phi)) The cosine function goes negative as theta and phi sweep through the circle. So some of the coordinates generated by the equations are meaningless. (You are not allowed to raise a negative number to a fractional power --- that is undefined)

    FURTHER UPDATE: The equations are wrong. Any time n1 or n2 is an even number, you are squaring the sin() and cos() functions. This causes any negative number they produce into a positive number. There is no way to generate points in the negative quadrants if you have n1^2 or n2^2 positive. n1 & n2 can only be 1,3,5,7,etc.
    Last edited by Roxy; 12-04-2014 at 05:09 PM.

  2. #22
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,182
    OK... I'm done with Toroids for now... Here is an updated screen shot with various odd numbers for n1 & n2. Note that the 'round' toroid in the upper right is not a generic toroid. Its edges are curved kind of funny. But, you probably don't want that one anyway, because it is going to waste a lot of space in the doughnut box when you make donuts that shape.

    Toriod.jpg

    You might want to bump the resolution up to examine some of the shapes. Especially ones like the center one. But if you do that, you might want to comment out the generation of the other toroid's because this gets very expensive computationally (but still no need to run out and buy a Cray Super Computer!). You can do that by changing the:

    for (theta = [0:18:360])
    for (phi = [0:18:360])

    to what ever you can tolerate. Maybe something like:

    for (theta = [0:6:360])
    for (phi = [0:6:360])

    and by changing all the +18's to +6 in the hull() directive:

    Toriod.jpg

    And of course... If that is too 'thin' for all the doughnut eater's that are policing Australia, you can mess with the value for r1 so they only need one instead of the usual 2 or 3 doughnuts per session!
    Last edited by Roxy; 12-04-2014 at 04:48 PM.

  3. #23
    Senior Engineer
    Join Date
    Jun 2014
    Location
    Burnley, UK
    Posts
    1,662
    You are right. I only used mine in the first quadrant as it took too long. The shape needs translating wholly into the first quadrant before it is made in order to stop imaginary number problems.

  4. #24
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,182
    Quote Originally Posted by Mjolinor View Post
    You are right. I only used mine in the first quadrant as it took too long. The shape needs translating wholly into the first quadrant before it is made in order to stop imaginary number problems.
    Just as an FYI: I generated tiny cube's as my points. Spheres are much more natural. But computationally, it takes way more to generate them, and it takes a lot more work to put a hull around them. I haven't done it, but I suspect it would take 10x as long to run this same code with sphere() in the generate_point() module.

  5. #25
    Staff Engineer old man emu's Avatar
    Join Date
    Oct 2013
    Location
    Narellan, New South Wales, Australia
    Posts
    912
    Just a wild comment, but to eliminate the "Any time n1 or n2 is an even number, you are squaring the sin() and cos() functions. This causes any negative number they produce into a positive number. There is no way to generate points in the negative quadrants if you have n1^2 or n2^2 positive." problem what would happen if you made the computation use the ABS value?

    I must refer you back to the original source:
    http://paulbourke.net/geometry/torus/

    It shows the results of n1 and n2 being a positive number. n1 controls the shape of the body. If n1 = 2, then the shape is squared up. n2 controls the shape of the cross section.

    OME

  6. #26
    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

    I must refer you back to the original source:
    http://paulbourke.net/geometry/torus/

    It shows the results of n1 and n2 being a positive number. n1 controls the shape of the body. If n1 = 2, then the shape is squared up. n2 controls the shape of the cross section.
    Yeah, in other words... He faked it. He only generated one quadrant and replicated that in the places the equations did not produce valid results. I can mirror the first quadrant where the equations work to make the other quadrants.
    Last edited by Roxy; 12-04-2014 at 10:15 PM.

  7. #27
    Staff Engineer old man emu's Avatar
    Join Date
    Oct 2013
    Location
    Narellan, New South Wales, Australia
    Posts
    912
    What would happen if, instead of having the Origin at (0,0,0), which results in sin and cos being -ve in certain segments, you translate the centre of the object to (r0, r0 , r1 ) so that X, Y and Z are always positive?

    Alternatively, and probably the best way is to do the cheat that Roxy proposed:

    1. Restrict the ranges of theta and phi to between 0 an pi.
    2. Do three translations to put this quarter into the other three quadrants.
    3. Consecrate the Union.

    OME

  8. #28
    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
    What would happen if, instead of having the Origin at (0,0,0), which results in sin and cos being -ve in certain segments, you translate the centre of the object to (r0, r0 , r1 ) so that X, Y and Z are always positive?
    I would love to hear a detailed analysis of this transformation by a resident Math Major. But my guess (just off the top of my head) is this doesn't work. Those equations are written using a spherical (3D Polar) coordinate system that produce a mapping into the Cartesian coordinate system. I would expect shifting its center isn't going to change the fact the equations lose the sign of cos() & sin() function when even powers are used for n1 and n2.
    Quote Originally Posted by old man emu View Post
    Alternatively, and probably the best way is to do the cheat that Roxy proposed:
    This is an example of where the OpenJScad language shines. From a computational perspective, only one quadrant of information would have to be generated (and be saved as a variable) and then it could be mirrored 3 times to fill out the entire solid.

    Maybe Dacb would know enough to convert the existing or next Toriod.scad to a J-Scad file? That would be interesting to see. Especially since J-Scad has cleaned up the syntax of the language so much.
    Quote Originally Posted by old man emu View Post
    1. Restrict the ranges of theta and phi to between 0 an pi.
    The way I understand it, we are dealing with both sin^2() and cos^2() functions losing the negative values. And we have all combinations of sin^n1() and cos^n1() and sin^n2() and cos^n2() of both theta and phi. The only place both of those functions are always positive is in the first quadrant. So we need to restrict theta to values of 0 to pi/2. You can not restrict phi to that range because you wont get the complete shape of the toroid. Phi needs to still vary from 0 to pi. What this means is there may still be some limitations on n2 being stuck at positive numbers because you can't be raising cos(phi) (with a negative value) to a fractional power. However, I think n1 is free to be both positive and negative with this technique.
    Quote Originally Posted by old man emu View Post
    2. Do three translations to put this quarter into the other three quadrants.
    Not translations... mirror() operations. We need to mirror() the positive portion ((x,y,z) all positive) into the other 7 areas. Probably doing the mirror() to the negative z area of the first quadrant makes sense. And then mirroring that to either the 2nd or 4th quadrant would be next to form a 1/2 toroid. And then mirror() that to get the whole thing.

    The big problem with doing this in OpenScad is you have to keep regenerating the base information you are going to mirror() even though you already have generated it. OpenJScad doesn't have this limitation.
    Quote Originally Posted by old man emu View Post
    3. Consecrate the Union.
    I would do the mirror() with an ever so slight transformation([,,]) towards the reflection... That way, you will end up with a manifold surface that is fully joined of the two halves. Without this, you might end up with errors in the .STL file.
    Last edited by Roxy; 12-05-2014 at 07:42 AM.

  9. #29
    Staff Engineer old man emu's Avatar
    Join Date
    Oct 2013
    Location
    Narellan, New South Wales, Australia
    Posts
    912
    OK. Let's put this on hold for the weekend. I've sent an email to Dr Bourke asking for his help.

    OME

  10. #30
    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
    OK. Let's put this on hold for the weekend. I've sent an email to Dr Bourke asking for his help.

    OME
    I changed the wording up above... I had an error. Specifically, it would be useful to ask Dr. Bourke how he generated that table with fractional values. Because (and here is the updated wording):

    So we need to restrict theta to values of 0 to pi/2. You can not restrict phi to that range because you wont get the complete shape of the toroid. Phi needs to still vary from 0 to pi. What this means is there may still be some limitations on n2 being stuck at positive numbers because you can't be raising cos(phi) (with a negative value) to a fractional power. However, I think n1 is free to be both positive and negative with this technique.
    I think you can fake many cases and replicate the data from other parts of the toroid where you can generate valid results. But I'm checking right now, and those fractional values for n1 & n2 seem to be imaginary. Here is the only part of the surface that can be generated for the n1=.2 & n2=.2 case. Notice both theta and phi are sweeping 0 to 360 degrees. And you only get the outside shell of the first quadrant. He faked the data (and entry) in that table:

    partial_toriod.jpg

    Here are the square toriod's using the mirror() fake out method


    :Square_Toriod.jpg
    Last edited by Roxy; 12-05-2014 at 08:34 AM.

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