<?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 anglemode() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=anglemode%28%29</link>
      <pubDate>Sun, 08 Aug 2021 19:59:47 +0000</pubDate>
         <description>Tagged with anglemode() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedanglemode%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>angleMode Not working?</title>
      <link>https://forum.processing.org/two/discussion/27379/anglemode-not-working</link>
      <pubDate>Mon, 26 Mar 2018 18:22:21 +0000</pubDate>
      <dc:creator>m4ge</dc:creator>
      <guid isPermaLink="false">27379@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone,</p>

<p>So I'm doing some work with angles/trigonometry, but for some reason angleMode(DEGREES); does absolutely nothing. If I run angleMode(DEGREES); Math.sin(90); in the console I got the value of sin(90 radians) instead of the value for degrees.</p>
]]></description>
   </item>
   <item>
      <title>How to define an origin for atan2()</title>
      <link>https://forum.processing.org/two/discussion/27380/how-to-define-an-origin-for-atan2</link>
      <pubDate>Mon, 26 Mar 2018 18:29:09 +0000</pubDate>
      <dc:creator>Battlesquid</dc:creator>
      <guid isPermaLink="false">27380@/two/discussions</guid>
      <description><![CDATA[<p>The p5js page for atan2 states that it works in the following way:</p>

<blockquote class="Quote">
  <p>Calculates the angle (in radians) from a specified point to the coordinate origin as measured from the positive x-axis.</p>
</blockquote>

<p>However, I would like to calculate the angle between a set of points other than the origin. Is there any way to do this, and if so, can I get a pointer towards the right track? Thanks in advance! :)</p>
]]></description>
   </item>
   <item>
      <title>My p5js clock draws over itself with every update.</title>
      <link>https://forum.processing.org/two/discussion/25765/my-p5js-clock-draws-over-itself-with-every-update</link>
      <pubDate>Sun, 31 Dec 2017 07:50:21 +0000</pubDate>
      <dc:creator>TheAshwin</dc:creator>
      <guid isPermaLink="false">25765@/two/discussions</guid>
      <description><![CDATA[<p><strong>Project link</strong>: <a rel="nofollow" href="https://gurbuxani.github.io/time-and-tide/">https://gurbuxani.github.io/time-and-tide/</a></p>

<p><strong>Problem</strong>: As you can see on the link above, my clock updates just fine ... but the pixels created in previous loop are not deleted. It's very obvious if you look at the time in text near the bottom. If you wait till the analog clock goes from 60 seconds to the next minute's first second - the previous arc is not deleted and leaves behind a circle. Please see the attached screenshot for a visual representation.</p>

<p><strong>Update</strong>: I have a feeling, it might have something to do with the lack of a background on my canvas. When I add <code>background(0);</code> to <code>draw</code>, it works just fine. But I don't want a black background, I want a transparent one. Using <code>background('rgba(0, 0, 0, 0)')</code> does not solve this either :(</p>

<p><img src="https://i.imgur.com/O3UzRQh.png" alt="" /></p>

<p><strong>Code</strong>: GitHub repo - <a href="https://github.com/gurbuxani/time-and-tide" target="_blank" rel="nofollow">https://github.com/gurbuxani/time-and-tide</a></p>

<pre lang="javascript">

function setup() {
  createCanvas(800, 800);
  angleMode(DEGREES);
}

function draw() {
  translate(400, 400);
  rotate(-90);

  let hr = hour();
  let mn = minute();
  let sc = second();

  // seconds arc
  strokeWeight(2);
  stroke(255);
  noFill();
  let secondAngle = map(sc, 0, 60, 0, 360);
  arc(0, 0, 350, 350, 0, secondAngle);

  // minutes arc
  strokeWeight(4);
  stroke(255);
  let minuteAngle = map(mn, 0, 60, 0, 360);
  arc(0, 0, 280, 280, 0, minuteAngle);

  // hours arc
  strokeWeight(8);
  stroke(255);
  let hourAngle = map(hr % 12, 0, 12, 0, 360);
  arc(0, 0, 150, 150, 0, hourAngle);

  // center point
  strokeWeight(2);
  stroke(255);
  point(0, 0);

  // time in text
  rotate(90);
  fill(255);
  noStroke();
  text(hr + ':' + mn + ':' + sc, 5, 400);
}

</pre>

<p>What am I doing wrong? How can I fix this?</p>

<p>&lt;3</p>
]]></description>
   </item>
   <item>
      <title>Check colision</title>
      <link>https://forum.processing.org/two/discussion/23643/check-colision</link>
      <pubDate>Sun, 30 Jul 2017 20:06:42 +0000</pubDate>
      <dc:creator>garwan50</dc:creator>
      <guid isPermaLink="false">23643@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>i'm trying to do some kind of QTE game with p5.js, i have a question :</p>

<p><img src="https://cdn.discordapp.com/attachments/236955284474429440/341295506405982209/skillcheck.gif" alt="" /></p>

<p>How can I check if the red line is touching the black or the white arc ?</p>

<p>To move the red line i'm using the rotate function so i'm not sure how i should proceed.</p>

<p>I think what I want is to have coordinates of everything so i could compare but the rotate function kind of prevent that.</p>

<p>Here's the code : <a href="https://pastebin.com/WXvGbT9g" target="_blank" rel="nofollow">https://pastebin.com/WXvGbT9g</a></p>

<p>It's my first program using p5.js so sorry if it's a stupid question.</p>

<p>Thanks for your help !</p>

<p>(sorry for my english)</p>
]]></description>
   </item>
   <item>
      <title>[SOLVED] Draw static rect filling the screen infront of PeasyCam</title>
      <link>https://forum.processing.org/two/discussion/22047/solved-draw-static-rect-filling-the-screen-infront-of-peasycam</link>
      <pubDate>Mon, 17 Apr 2017 17:08:47 +0000</pubDate>
      <dc:creator>prince_polka</dc:creator>
      <guid isPermaLink="false">22047@/two/discussions</guid>
      <description><![CDATA[<p>The middle of the rect is static at the origin, where the camera is facing, and the rect shall also face the camera.<br />
Lik if it's stuck on a stick infront of it.<br />
<img src="http://download.java.net/media/java3d/javadoc/1.4.0/javax/media/j3d/doc-files/ViewModel11.gif" alt="" /><br />
<em>ignore the text on the picture, it's the best i found</em><br />
I want to know the coordinates of the corners so can not use camera.beginHUD() or popMatrix() to achieve this since this doesn't give me any coordinates.<br />
Also screenX/Y and the picker library isn't doing what I wan't to do.<br />
Tried to read up on how to do rotation in 3D but euler angles, rotation matrices,quaternions etc is not something I understand at the moment.<br />
Here is my code, with with just Yaw+Roll it works, but with Pitch any other angle than 0 it doesn't.<br />
Use R, Y, P keys to rotate and Enter to reset</p>

<pre><code>import peasy.*;
PeasyCam camera;
float[] rot; 
float disx;
float disy;
float yaw,pitch,roll;
void setup(){
  size(600,400,P3D);
  disx=width*0.6;
  disy=height/10;
  camera = new PeasyCam(this, 100);
  camera.setCenterDragHandler(null);
  strokeWeight(3);
}
float [] rec;

void draw(){
 background(180);
 disx=(float)camera.getDistance()*0.86;
 disy=(float)camera.getDistance()*0.57;
 rec = new float [] {-disx,-disy,0,disx,-disy,0,disx,disy,0,-disx,disy,0};
 //rot = camera.getRotations();
 //yaw=rot[0]; pitch=rot[1]; roll=rot[2];

 if(keyPressed){
 float rotspeed=0.03;
 if(key=='p') { pitch += rotspeed; }
 if(key=='y') {   yaw += rotspeed; }
 if(key=='r') {  roll += rotspeed; }
 if(key==ENTER) {  yaw=pitch=roll=0; }
 }
 camera.setRotations(yaw,pitch,roll);

 float sinyaw,cosyaw, sinpitch,cospitch, sinroll, cosroll;
 sinyaw=sin(-yaw-HALF_PI);
 cosyaw=cos(-yaw-HALF_PI);
 sinpitch=sin(pitch-HALF_PI);
 cospitch=cos(pitch-HALF_PI);
 cosroll=cos(roll);
 sinroll=sin(roll);

 for(int i=0; i&lt;12; i+=3){
 float x,y,z,x0,y0,z0;
 x0=x=rec[i]; y0=y=rec[i+1]; z=z0=rec[i+2];

 x=x0*cosroll-y0*sinroll;
 y=y0*cosroll+x0*sinroll;

 z=x0*cospitch;
 y*=sinpitch;

 z=y*cosyaw;
 y*=sinyaw;

 rec[i]=x; rec[i+1]=y; rec[i+2]=z;

 }

 stroke(#ff0000);
 line(0,0,0,100,0,0);
 stroke(#00ff00);
 line(0,0,0,0,100,0);
 stroke(#0000ff);
 line(0,0,0,0,0,100);

 stroke(0);
 line(rec[0],rec[1],rec[2], rec[3],rec[4],rec[5]);
 line(rec[3],rec[4],rec[5], rec[6],rec[7],rec[8]);
 line(rec[6],rec[7],rec[8], rec[9],rec[10],rec[11]);
 line(rec[9],rec[10],rec[11], rec[0],rec[1],rec[2]);
}
</code></pre>

<p>A bit simpler example just a rotating square and static camera, only rotating in one axis at the time.<br />
Also just found this <a rel="nofollow" href="https://www.khanacademy.org/computer-programming/3d-tutorial-4/1648921303">https://khanacademy.org/computer-programming/3d-tutorial-4/1648921303</a></p>

<pre><code>import peasy.*;
PeasyCam camera;
float S,C,R,D;
float [] rec;
void setup(){
  size(600,400,P3D);
  camera = new PeasyCam(this, 100);
  camera.setCenterDragHandler(null);
  strokeWeight(3);
  D=30;
}
void draw(){
 background(180);
 rec = new float [] {-D,-D,0,D,-D,0,D,D,0,-D,D,0};
 camera.setRotations(0,0,0);
 R+=PI/60;
 S=sin(R);
 C=cos(R);
 for(int i=0; i&lt;12; i+=3){
 float x,y,z,x0,y0,z0;
 x0=x=rec[i]; y0=y=rec[i+1]; z=z0=rec[i+2];
 if(frameCount%180&lt;60){
 x=x0*C-y0*S;
 y=y0*C+x0*S;
 }
 else if(frameCount%180&lt;120){
 z=z0*C-x0*S;
 x=x0*C+z0*S;
 }
 else{
 y=y0*C-z0*S;
 z=z0*C+y0*S;
 }
 rec[i]=x; rec[i+1]=y; rec[i+2]=z;
 }
 stroke(#ff0000);
 line(0,0,0,100,0,0);
 stroke(#00ff00);
 line(0,0,0,0,100,0);
 stroke(#0000ff);
 line(0,0,0,0,0,100);
 stroke(0);
 line(rec[0],rec[1],rec[2], rec[3],rec[4],rec[5]);
 line(rec[3],rec[4],rec[5], rec[6],rec[7],rec[8]);
 line(rec[6],rec[7],rec[8], rec[9],rec[10],rec[11]);
 line(rec[9],rec[10],rec[11], rec[0],rec[1],rec[2]);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Is it better to create vectors using the createVector() function or as a new object?</title>
      <link>https://forum.processing.org/two/discussion/19734/is-it-better-to-create-vectors-using-the-createvector-function-or-as-a-new-object</link>
      <pubDate>Tue, 13 Dec 2016 20:27:04 +0000</pubDate>
      <dc:creator>Tsskyx</dc:creator>
      <guid isPermaLink="false">19734@/two/discussions</guid>
      <description><![CDATA[<p>I currently use them interchangeably. When I need a vector with specific parameters already in place, I use createVector(). When I don't specify any parameters, I do it this way: var v = new p5.Vector();</p>

<p>I don't really know if there's any huge advantage of using the createVector() function, but I use vectors regularly to shorten my code, so I'm curious.</p>
]]></description>
   </item>
   <item>
      <title>How do you add tooltips to p5.js not using HTML?</title>
      <link>https://forum.processing.org/two/discussion/16240/how-do-you-add-tooltips-to-p5-js-not-using-html</link>
      <pubDate>Mon, 25 Apr 2016 10:00:16 +0000</pubDate>
      <dc:creator>hawkdidy</dc:creator>
      <guid isPermaLink="false">16240@/two/discussions</guid>
      <description><![CDATA[<p>Hello All,
I have a project I am working on where I must use p5.js. I have a data visualization that involves a matrix like object. When I hover over one of the boxes of the matrix I want to see underlying data. I have searched on google but did not find anything that would help me. I can't post the data but my code looks like this:</p>

<pre><code>var table;
  var i;
  var j;
  var cellValue;
  var label;
  var test; 

  function preload() {
    matrix = loadTable("dataLayer2matrix.csv","csv")
    labels = loadTable("dataLayer2labels.csv","csv")
    test = matrix
  }

  function setup() {
    createCanvas(1500,1500)
    noStroke()
    fill(0,0,255,10)

   angleMode(DEGREES)
   background(255,255,255)
   matrixStartX = 200
   matrixStartY = 250
   var matrixRows = matrix.getRows()
   var matrixSize = matrixRows.length

   // Experiment with grid
   fill(75, 75, 75, 50)
   for (r = 0; r &lt;= matrixSize; r++) {
   rect(matrixStartX , matrixStartY + r * 20 - 1 , 20 * matrixSize, 1)
   rect(matrixStartX + r * 20 - 1 , matrixStartY, 1, 20 * matrixSize)
   }

   // Draw matrix
   for (var mr = 0; mr &lt; matrixSize; mr++) {
       for (var mc = 0; mc &lt; matrixSize; mc++) {
         cellValue = matrixRows[mr].getNum(mc)
         fill(49,130,189,cellValue*10)
         rect(mc * 20 + matrixStartX, mr * 20 + matrixStartY, 19 ,19)
       }
   }

   // Labels - horizontal
   fill(75, 75, 75, 255)
   labelsRow = labels.getRows()
   for (mc = 0; mc &lt; matrixSize; mc++) {
       label = labelsRow[0].getString(mc)
       text(label, 10, mc*20+matrixStartY + 15)
   }

   // Labels - vertical
   push()
   translate(matrixStartX + 15, matrixStartY - 15)
   rotate(-90)
   for (mc = 0; mc &lt; matrixSize; mc++) {
       label = labelsRow[0].getString(mc)
       text(label, 0, mc*20)
   }
   pop() 
</code></pre>

<p>The resulting data matrix looks like this <a href="http://imgur.com/55jkRiJ" target="_blank" rel="nofollow">http://imgur.com/55jkRiJ</a> . I have no idea where to start. This code does not have any attempted implementation of the tooltip. Just the code that generates the matrix so that maybe someone can point me in the right direction.</p>
]]></description>
   </item>
   </channel>
</rss>