<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with rotatez() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=rotatez%28%29</link>
      <pubDate>Sun, 08 Aug 2021 19:01:43 +0000</pubDate>
         <description>Tagged with rotatez() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedrotatez%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>how to rotate a child PShape around its own axis?</title>
      <link>https://forum.processing.org/two/discussion/27755/how-to-rotate-a-child-pshape-around-its-own-axis</link>
      <pubDate>Fri, 13 Apr 2018 09:24:06 +0000</pubDate>
      <dc:creator>dsy199610</dc:creator>
      <guid isPermaLink="false">27755@/two/discussions</guid>
      <description><![CDATA[<p>I create a group PShape which includes a number of child PShape. I want to rotate one of the child PShape around its own axis instead of the axis of the group PShape. However, when I use getChild() and then use childname.rotateZ(), it always rotate around the axis of the group PShape:</p>

<pre><code>PShape JL2 = JL12.getChild(1);
JL2.rotateZ(0.01*PI);
</code></pre>

<p>Thank you very much!</p>
]]></description>
   </item>
   <item>
      <title>GLSL and video Texture</title>
      <link>https://forum.processing.org/two/discussion/26054/glsl-and-video-texture</link>
      <pubDate>Sat, 20 Jan 2018 23:12:54 +0000</pubDate>
      <dc:creator>vjjv</dc:creator>
      <guid isPermaLink="false">26054@/two/discussions</guid>
      <description><![CDATA[<p>hello everyone. Im trying to pass a video as a texture into a fragment shader. but the sketch crash when i run it.</p>

<p>here is the code:</p>

<pre><code>  import processing.video.*;
import peasy.*;
import peasy.org.apache.commons.math.*;
import peasy.org.apache.commons.math.*;

PeasyCam cam;
PShader sh;
float count;
Movie mov;
PGraphics p;

void setup (){

size(1440, 900, P3D );
mov = new Movie(this, "osc_noc.mov");
mov.play();
p = createGraphics(width,height);
cam = new PeasyCam(this, 500);
sh = loadShader("basicShaderFrag.glsl", "basicShader.glsl");
}

void movieEvent(Movie m) {
  m.read();
}

void draw(){
background(0);
shader(sh);
count +=0.09;
sh.set("u_time", count);

sphere(100);
p.beginDraw();
p.background(0);
p.image(mov, 0, 0, 200, 200);
p.endDraw();
sh.set("tex",p);
// image(p, 5, 260 ,200, 200);
}

#version 150

uniform mat4 transform;
uniform sampler2D tex;

in vec4 position;
in vec2 texCoord;
in vec3 normal;

out vec2 TexCoord;

void main(){

  TexCoord = texCoord;
  gl_Position = transform * position;
}


#ifdef GL_ES
precision mediump float;
#endif

#define PI 3.14

in vec2 TexCoord;
uniform float u_time;
uniform sampler2D tex;

void main(){
  vec2 uv = TexCoord;

  gl_FragColor = vec4(texture(tex, TexCoord));
}
</code></pre>

<p>a white screen appears, and next it close. the console just say: "Finished". 
it may be a bug? i could pass a PImage as a texture. but when i link the fragment and shader program into the sketch folder then crash. ..</p>
]]></description>
   </item>
   <item>
      <title>Getting weird result on the distance Function</title>
      <link>https://forum.processing.org/two/discussion/24869/getting-weird-result-on-the-distance-function</link>
      <pubDate>Sat, 04 Nov 2017 20:07:13 +0000</pubDate>
      <dc:creator>godsamit</dc:creator>
      <guid isPermaLink="false">24869@/two/discussions</guid>
      <description><![CDATA[<p>The general program is this: I have a target square to match, and a "cursor square" to manipulate. So first I match the centers, then I'm rotating and scaling:</p>

<p>(The red square is the target. I need to change the white outlined square)</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/177/T6CIV7MOF66K.PNG" alt="Match the centers" title="Capture" /></p>

<p>My design is to drag the cursor square's corner to the target square's corner, which in the process will scale and rotate to match the square.</p>

<p>The pushMatrix() is set so that the origin is at the <strong>center</strong> of the cursor square. (Square mode is CENTER too.)</p>

<p>Right now, The rotation is working but the size is weird. Here's one example:</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/288/IGFE04LW5PZE.png" alt="weird size" title="Untitled-2" /></p>

<p>It should match the red square, but right now it's too huge.
I printed the distance from my mouse to the center of the square and it's a rather large number...</p>

<p>My suspicion is, I had to use P3D renderer so I could use modelX(), even though the whole thing is just 2D. Somewhere in the 3D might have messed the distance up. But I'm not sure.. I did set Z to 0 every time I have the chance..</p>

<p>Here's an edited version of my code. The parameters for rotation, square size and translation are GLOBAL. I'll really appreciate it if you could take a look!</p>

<pre><code>void draw() {
  //omitted background and other things..
  //===========DRAW TARGET SQUARE=================
  pushMatrix();
  translate(width/2, height/2, 0); //center the drawing coordinates to the center of the screen
  Target t = targets.get(trialIndex);//generated somewhere else
  translate(t.x, t.y, 0); //center the drawing coordinates to the center of the screen
  rotateZ(radians(t.rotation));
  //omitted fill and strokes
  popMatrix();

  //===========DRAW CURSOR SQUARE=================
  pushMatrix();
  translate(width/2, height/2, 0); //center the drawing coordinates to the center of the screen
  translate(screenTransX, screenTransY, 0);
  rotateZ(radians(screenRotation));

  //omitted stroke and fills

  rect(0,0, size, size);

  //record the corner coordinates using modelX
  //up-left
  ULX = modelX(-size/2, -size/2, 0);
  ULY = modelY(-size/2, -size/2, 0);

  //.....
  //omitted code for other corners
  //other stuff......
}

void mouseMoved()
{
  //omitted other code

  //rotate and scale the square once the centers line up
  if (mode == "rotScale" &amp;&amp; rotatingCorner != ""){

    //THIS LINE IS THE PROBLEM
    size = sqrt(2)* dist(mouseX, mouseY, 0, (ULX+URX)/2, (ULY+DLY)/2, 0);
    //THE LINE ABOVE IS THE PROBLEM

    //adding multiplies of 45 since I'm rotating the corners 
    if (rotatingCorner == "UR") screenRotation = degrees(atan2(mouseY-(ULY+DRY)/2, mouseX-(ULX+DRX)/2))-45;
    if (rotatingCorner == "DR") screenRotation = degrees(atan2(mouseY-(ULY+DRY)/2, mouseX-(ULX+DRX)/2))+45;
    if (rotatingCorner == "UL") screenRotation = degrees(atan2(mouseY-(ULY+DRY)/2, mouseX-(ULX+DRX)/2))-135;
    if (rotatingCorner == "DL") screenRotation = degrees(atan2(mouseY-(ULY+DRY)/2, mouseX-(ULX+DRX)/2))+135;
  }

}

void mousePressed()
{
  //decide which corner the user just picked up
  if (mode == "rotScale"){
    if (dist(ULX, ULY, 0, mouseX, mouseY, 0)&lt;5){
      rotatingCorner = "UL";
    //omitted code for other corners
    rotating = true;

    println(dist(mouseX, mouseY, 0, (ULX+URX)/2, DLY - (ULY+DLY)/2, 0));
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Drawing points for each vertex on a rotating 3D sphere</title>
      <link>https://forum.processing.org/two/discussion/21702/drawing-points-for-each-vertex-on-a-rotating-3d-sphere</link>
      <pubDate>Thu, 30 Mar 2017 11:59:46 +0000</pubDate>
      <dc:creator>gvdb</dc:creator>
      <guid isPermaLink="false">21702@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to draw each vertex of a rotating 3D sphere as points in 2D coordinate screen space. Here's my attempt.</p>

<pre><code>    PShape my_sphere;
    ArrayList&lt;PVector&gt; vertices = new ArrayList&lt;PVector&gt;();

    void setup(){
      size(800, 600, P3D);
      frameRate(60);
      smooth();
      sphereDetail(10);
      fill(255,0,0);
      my_sphere = createShape(SPHERE, 100);
    }

    void draw_sphere(){
      pushMatrix();
      translate(width/2, height/2);
      rotateZ(millis() * 0.0001 * TWO_PI);
      //rotateY(millis() * 0.0001 * TWO_PI);
      shape(my_sphere);
      my_sphere.setVisible(false);
      popMatrix();
    }

    void draw_points(){
      getVertices(my_sphere, vertices);
      for(int i=0; i &lt; vertices.size(); i++){
        PVector vertex = vertices.get(i);
        float x = vertex.x;
        float y = vertex.y;
        float z = vertex.z;

        float s_x = screenX(x, y, z);
        float s_y = screenY(x, y, z);

        point(s_x+(width/2), s_y+(height/2));
      }
    }

    void draw(){
      background(255,255,255);
      draw_sphere();
      draw_points();
      vertices.clear();
    }

    void getVertices(PShape shape, ArrayList&lt;PVector&gt; vertices){
      for(int i = 0 ; i &lt; shape.getVertexCount(); i++){
        PVector vertex = shape.getVertex(i);
        vertices.add(vertex);
      }
    }
</code></pre>

<p>The issue I'm seeing is that as the sphere rotates (which I've hidden) the points aren't updating to match. Why? I've tried lots of things and can't seem to figure it out. Help would be appreciated.</p>
]]></description>
   </item>
   <item>
      <title>How to make a cube face a 3D coordinate (x,y,z) ?</title>
      <link>https://forum.processing.org/two/discussion/20133/how-to-make-a-cube-face-a-3d-coordinate-x-y-z</link>
      <pubDate>Sat, 07 Jan 2017 19:23:30 +0000</pubDate>
      <dc:creator>Stephcraft</dc:creator>
      <guid isPermaLink="false">20133@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I have a problem with a sketch in witch I need to make some cubes face a certain coordinate in P3D
it works for the Z axis just like 2D with atan2() but when it comes to the X and Y axis it doesn't work :/</p>

<p>here is the code I have for now:</p>

<hr />

<pre><code>import peasy.*;

PeasyCam cam;


float x;
float y;
float z;

void setup() {
  size(500,500,P3D);
  cam = new PeasyCam(this, 100);
}

void draw() {
  background(50);

  //the angles
  float angleZ = atan2(-x,y); //-x,y
  float angleX = atan2(0,z);
  float angleY = atan2(-z,x);

  //Cube that need to face the target
  pushMatrix();
  rotateZ(angleZ);
  rotateX(angleX);
  //rotateY(angleY);
  translate(0,0,0);
  box(100);
  line(0,0,0,0,1000,0);
  popMatrix();

  //Cube that need to face the target
  pushMatrix();
  translate(1000,1000,1000);
  rotateZ(atan2(-x+1000,y-1000));
  //rotateX(atan2(y+100,-z-100));
  box(100);
  line(0,0,0,0,1000,0);
  popMatrix();

  //to control the little cube (target)
  if(keyPressed) {
   if(keyCode==UP) {
      y+=4;
    }
    if(keyCode==DOWN) {
      y-=4;
    }
    if(keyCode==LEFT) {
      x+=4;
    }
    if(keyCode==RIGHT) {
      x-=4;
    }
    if(key==' ') {
      z+=4;
    }
    if(keyCode==SHIFT) {
      z-=4;
    }
  }

  //little cube (taget)
  pushMatrix();
  translate(x,y,z);
  box(50);
  popMatrix();
}
</code></pre>

<hr />

<p>I used the peasyCam so its easier to see and control</p>

<p>float x,y,z are the targets to face, you can control them with Arrows Space and Shift</p>

<p>thanks !</p>
]]></description>
   </item>
   <item>
      <title>Rotation cube problem</title>
      <link>https://forum.processing.org/two/discussion/19837/rotation-cube-problem</link>
      <pubDate>Tue, 20 Dec 2016 05:24:08 +0000</pubDate>
      <dc:creator>Spicy</dc:creator>
      <guid isPermaLink="false">19837@/two/discussions</guid>
      <description><![CDATA[<p>Hey, I'm new at processing code and I'm doing a little code for the mouvement of a finger (the index).
I'm doing it with the rotation of phalanges, remplaced by cube.</p>

<p>But I have a big problem,  the third box 's rotation isn't what I want, I don't know how to explain it but here is my code.
How to fix this and have a good  mouvement of index ?
Thanks for the help.</p>

<pre><code>int a = 80;
int z = 0;
int e =50;
int r = 60;
float rot1;//rotation of cube_1
float rot2;//rotation of cube_2
float rot3;//rotation of cube_3




void setup() {
  size(400, 400, P3D);
  smooth();
}

void  draw() {
  background(20, 50, 80);

  //base
  translate(width/4, height/4);
  box(80, 50, 50);
  pushMatrix();
  // 1/2/3
  translate(a, z);//1
  rotateZ(rot1);
  box(r, e, e);
  translate(a, z);//2
  rotateZ(rot2);
  box(r, e, e);

  translate(a, z);//3
  rotateZ(rot3);
  box(r, e, e);
  popMatrix();

  if  (keyPressed == true)
  {
    if (key =='a') {  //Rot1
      rot1 = rot1 + 0.01;
    } else if (key == 'z') {
      rot1 = rot1 - 0.01;
    }

    if (key =='a') { //rot2
      rot2 = rot2 + 0.01;
    } else if (key == 'z') {
      rot2 = rot2 - 0.01;
    }

    if (key =='a') { //rot3
      rot3 = rot3 + 0.01;
    } else if (key == 'z') {
      rot3 = rot3 - 0.01;
    }
  }

  if (rot1 &gt; 1.5) {
    rot1 = 1.5;
  } else if (rot1 &lt; -0.5) {
    rot1 = -0.5;
  }
  if (rot2 &gt; 1.0) {
    rot2 =60;
  } else if (rot2 &lt; 0.0) {
    rot2 = 0.0;
  }
  if (rot3 &gt; 1.5) {
    rot3 = 1.5;
  } else 
  if (rot3 &lt; 0) {
    rot3 = 0;
  }
  println(rot3);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Rotating and Scaling Multiple Stars</title>
      <link>https://forum.processing.org/two/discussion/19120/rotating-and-scaling-multiple-stars</link>
      <pubDate>Fri, 18 Nov 2016 11:13:36 +0000</pubDate>
      <dc:creator>tillemetry</dc:creator>
      <guid isPermaLink="false">19120@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to write a piece of code that rotates a group of 25 stars, and scales them randomly too.</p>

<p>Found good code for rotating PShapes, but scale doesn't seem to work for me.  I always end up with scale somehow in the draw loop, which to my understanding means it is going to be run over and over (See results).  I know this is a very basic question, but I'm still learning.</p>

<p>Thanks,</p>

<p>// A list of objects
ArrayList polygons;</p>

<p>void setup() {
  size(640, 360, P3D);</p>

<p>// Make a PShape
  PShape star = createShape();
  star.beginShape();
  star.noStroke();
  star.fill(0, 127);
  star.vertex(0, -50);
  star.vertex(14, -20);
  star.vertex(47, -15);
  star.vertex(23, 7);
  star.vertex(29, 40);
  star.vertex(0, 25);
  star.vertex(-29, 40);
  star.vertex(-23, 7);
  star.vertex(-47, -15);
  star.vertex(-14, -20);
  star.endShape(CLOSE);</p>

<p>// Make an ArrayList
  polygons = new ArrayList();</p>

<p>// Add a bunch of objects to the ArrayList
  // Pass in reference to the PShape
  // We coud make polygons with different PShapes
  for (int i = 0; i &lt; 25; i++) {
    polygons.add(new Polygon(star));
  }
}</p>

<p>void draw() {
  background(255);</p>

<p>// Display and move them all
  for (Polygon poly : polygons) {
    scale(0.9);
    poly.display();
    poly.move();
  }
}
// A class to describe a Polygon (with a PShape)</p>

<p>class Polygon {
  // The PShape object
  PShape s;
  // The location where we will draw the shape
  float x, y;
  // Variable for simple motion
  float speed;
  float theta1 = 0;</p>

<p>Polygon(PShape s_) {
    x = random(width);
//    y = random(-500, -100); 
    y = random(height);
    s = s_;
//    speed = random(2, 6);
    speed = 0;
  }</p>

<p>// Simple motion
  void move() {
    y += speed;
    if (y &gt; height+100) {
      y = -100;
    }
  }
  //</p>

<p>// Draw the object
  void display() {
    pushMatrix();
    translate(x, y);
    rotateZ(theta1);
//    scale(0.5);
    shape(s);
    theta1+=0.02;
    popMatrix();
  }
}</p>
]]></description>
   </item>
   <item>
      <title>How to rotate the cylinder in Processing?</title>
      <link>https://forum.processing.org/two/discussion/14721/how-to-rotate-the-cylinder-in-processing</link>
      <pubDate>Tue, 02 Feb 2016 08:05:18 +0000</pubDate>
      <dc:creator>Rclub</dc:creator>
      <guid isPermaLink="false">14721@/two/discussions</guid>
      <description><![CDATA[<p>I have drawn the 3D cylinder in Processing based on <a href="http://vormplus.be/blog/article/drawing-a-cylinder-with-processing" target="_blank" rel="nofollow">http://vormplus.be/blog/article/drawing-a-cylinder-with-processing</a>. i have to move/rotate the cylinder but only one face should rotate just like pendulum (top is always fixed and bottom is moving).. similarly my bottom face of the 3D cylinder should move and top face should be fixed. How to do that?</p>
]]></description>
   </item>
   <item>
      <title>deleted</title>
      <link>https://forum.processing.org/two/discussion/13636/deleted</link>
      <pubDate>Tue, 24 Nov 2015 23:48:54 +0000</pubDate>
      <dc:creator>FrankOcean</dc:creator>
      <guid isPermaLink="false">13636@/two/discussions</guid>
      <description><![CDATA[<p>i have several OBJ files from my 3D CAD Design and i will like to bring it in to processing for interactive gui for arduino project</p>
]]></description>
   </item>
   <item>
      <title>3D picking_Python mode</title>
      <link>https://forum.processing.org/two/discussion/6067/3d-picking-python-mode</link>
      <pubDate>Sun, 29 Jun 2014 13:16:59 +0000</pubDate>
      <dc:creator>ma_pa</dc:creator>
      <guid isPermaLink="false">6067@/two/discussions</guid>
      <description><![CDATA[<p>Hello!</p>

<p>I'm a beginner who's trying to pick a 3D box with a mouse click using the Shapes 3D and PeasyCam libraries in Python mode.</p>

<p>I referred to this previous discussion: <a href="http://forum.processing.org/two/discussion/4066/peasycam-cursor-location-in-comparison-to-objects-shapes3d-#Item_9" target="_blank" rel="nofollow">http://forum.processing.org/two/discussion/4066/peasycam-cursor-location-in-comparison-to-objects-shapes3d-#Item_9</a>, but I'm getting a NullPointerException.</p>

<p>Here's the code:</p>

<pre><code>add_library('Shapes3d')
add_library('peasycam')

clicked = False 
picked = None

Boxes = [] 

def setup():
    size(400,400,P3D)
    cursor(CROSS) 

    cam = PeasyCam(this, 150) 
    cam.setMinimumDistance(50)
    cam.setMaximumDistance(300)
    cam.setYawRotationMode()

    b = Box(this,30,60,100)
    b.fill(0)
    b.stroke(color(0,255,0))
    b.strokeWeight(2)
    b.drawMode(S3D.WIRE)
    Boxes.append(b) 

def draw():

    background(0)

    rotateX(1.57)
    rotateZ(-.75)

    if clicked :
        clicked = False
        picked = Shape3D.pickShape(this, mouseX, mouseY) 
        if picked != None:    
            print 'preso!'      

    Boxes[0].draw()

def mouseClicked():
    clicked = True
</code></pre>

<p>Can someone take a look over this?</p>

<p>Thank you,</p>

<p>Marco</p>
]]></description>
   </item>
   </channel>
</rss>