4

I am trying to draw an interlocking tori like this one:

enter image description here

For this I have been looking for the web for similar images and then have tried to modify the code. So far I got to this:

def torus {
    def n_segs 60
    sweep [draw=none, fill=cyan, fill opacity=0.75] {n_segs, rotate(360/n_segs, (0,0,0), [0,1,0])}
        sweep {n_segs, rotate(360/n_segs, (1.5,0,0), [0,0,1])}
        (2,0,0)
}

def torus2 {
    def n_segs 60
    sweep [draw=none, fill=orange, fill opacity=0.75] {n_segs, rotate(360/n_segs, (1.5,0,0), [0,0,1]) }
        sweep {n_segs, rotate(360/n_segs, (0,0,0), [0,1,0])}
        (2,0,0)

}

put { view((10,4,2)) } {{torus2} {torus}}

global { language tikz }

Here torus was the original piece of code, and I wrote torus2 mimicking the original code. However I got this ugly thing:

enter image description here

I would like to request assistance fixing torus2 so the complete image look like the first one. The orientation of the tori, their colors and those things are not meaningful at this moment.

1 Answer 1

1

I believe something like this should work:

def torus {
    def n_segs 60
    sweep [draw=none, fill=cyan, fill opacity=0.75] {n_segs, rotate(360/n_segs, (0,0,0), [0,1,0])}
        sweep {n_segs, rotate(360/n_segs, (1.5,0,0), [0,0,1])}
        (2,0,0)
}

def torus2 {
    def n_segs 60
    sweep [draw=none, fill=orange, fill opacity=0.75] {n_segs, rotate(360/n_segs, (0,0,0), [0,0,0.5]) }
        sweep {n_segs, rotate(360/n_segs, (0,0.75,0), [0.5,0,0])}
        (1,0,0)

}

put { view((10,4,2)) } {{torus2} {torus}}

global { language tikz }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.