Close



Results 1 to 10 of 74

Hybrid View

  1. #1
    Senior Engineer
    Join Date
    Jun 2014
    Location
    Burnley, UK
    Posts
    1,662
    You have a Cray then.



    r0 = 4;
    r1 = 2;


    for (v = [0:360])
    {
    for (u = [0: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);
    }
    }
    }

    I think it is right.
    AB and C are xy and z (I thought xyz maybe special within Openscad), your angles are u and v, radii are r0 and r1.

  2. #2
    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.

Posting Permissions

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