Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

The rotate function does not work as documented

edited January 14 in General Posts: 30

The rotate function does not seem to work if called with more than one argument.

Below is sample code modified from the rotating triangle demo code.

function draw()
    background(0)
    perspective()
    camera(0,0,-500,0,0,0,0,1,0)
    pushMatrix()
    translate(pos,0,0). — pos moves between -100 to 100 and is initialized to 0
 --   rotate(0,0,ElapsedTime*100). — does not work if called with more than one argument
    rotate(ElapsedTime*100)  — works and rotates around z axis
    makeTri(triSize):draw()
    popMatrix()
end

Comments

  • What I mean by “does not work” is that it does not rotate at all.

  • dave1707dave1707 Mod
    Posts: 7,746

    @DavidLeibs Here’s an example using some of your code. Change the parameter sliders to vary the rotation on the x,y,z axis. If all are 0 then the sprite is edge on and invisible. If 1 then the sprite rotates around that axis. Can combine 1 or all three.

    function setup()
        parameter.integer("x",0,1,1)
        parameter.integer("y",0,1,0)
        parameter.integer("z",0,1,0)
        pos=0
        v=1
    end
    
    function draw()
        background(0)
        pos=pos+v
        if pos>100 or pos<-100 then
            v=-v
        end
    
        perspective()
        camera(0,0,-500,0,0,0,0,1,0)
        pushMatrix()
        translate(pos,0,0)
        rotate(pos,x,y,z)
        sprite("Planet Cute:Character Horn Girl",0,0)
        popMatrix()
    end
    
  • The problem was that completely misread the documentation, probably because of some silly expectation for how I thought it should work. I seen now that it takes 4 arguments. Forgive me for increasing noise into your lives. :-)

  • Posts: 1,280
    @DavidLeibs - hi David, did you know that you followed that call with a full stop after the bracket. That can mess up the call.
  • dave1707dave1707 Mod
    Posts: 7,746

    @Bri_G I tried adding a . after the translate call in my code and all I got was an error. So it won’t mess up the call, it just won’t work.

  • @Bri_G and @dave1707, that “.” was not in my real code. It was an artifact of sloppy forum editing. January 14th was a day when the awful specter of fuzzy thinking reared its evil head for me and even my fingers were infected.

Sign In or Register to comment.