5

I'm using sketch to generate 3D tikz graphics, but the sketch documentation is not helpful. For example, here is some sketch code:

def v1 ( 0.000,  0.000,  1.000 ) 
def v2 ( 0.894,  0.000,  0.447 ) 
def v3 ( 0.276,  0.851,  0.447 ) 
def v4 ( -0.724,  0.526,  0.447 ) 
def v5 ( -0.724, -0.526,  0.447 )
def v6 (  0.276, -0.851,  0.447 ) 
def v7 (  0.724,  0.526, -0.447 ) 
def v8 ( -0.276,  0.851, -0.447 ) 
def v9 ( -0.894,  0.000, -0.447 )
def v10 ( -0.276, -0.851, -0.447 )
def v11 (  0.724, -0.526, -0.447 ) 
def v12 (  0.000,  0.000, -1.000 ) 

polygon(v1)(v2)(v3)
polygon(v1)(v3)(v4)
polygon(v1)(v4)(v5)
polygon(v1)(v5)(v6)
polygon(v1)(v6)(v2)
polygon(v8)(v7)(v12)
polygon(v9)(v8)(v12)
polygon(v10)(v9)(v12)
polygon(v11)(v10)(v12)
polygon(v7)(v11)(v12)
polygon(v7)(v3)(v2)
polygon(v8)(v4)(v3)
polygon(v9)(v5)(v4)
polygon(v10)(v6)(v5)
polygon(v11)(v2)(v6)
polygon(v7)(v8)(v3)
polygon(v8)(v9)(v4)
polygon(v9)(v10)(v5)
polygon(v10)(v11)(v6)
polygon(v11)(v7)(v2)

global {language tikz}

Which successfully generates the tikz code for this:

icosahedron

However, I cannot find in the documentation how to set the camera view for tikz to anything other than straight on. It seems that if I try to use rotate(), I would have to do this for each polygon separately?

2

You can check out section 3.1.3.3 of the manual for the details of the view transform.

Or look at the example about halfway down in section 4.1:

def eye (10,4,10)
def look_at (0,0,-5)
put { view((eye), (look_at)) } {bunchofpolygons}

Where bunchofpolygons is defined as what you're drawing.

Also, if you collect your polygon commands in one function, you could rotate just that one function without any trouble. So you can either rotate what you're drawing, or you can move the camera, it's up to you.

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.