<?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 degrees() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=degrees%28%29</link>
      <pubDate>Sun, 08 Aug 2021 19:59:46 +0000</pubDate>
         <description>Tagged with degrees() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggeddegrees%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <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>Midpoint Circle Algorithm, Modifying it to use arcs</title>
      <link>https://forum.processing.org/two/discussion/22375/midpoint-circle-algorithm-modifying-it-to-use-arcs</link>
      <pubDate>Wed, 03 May 2017 23:11:58 +0000</pubDate>
      <dc:creator>EvanJbesser</dc:creator>
      <guid isPermaLink="false">22375@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I have been having quite an annoying problem figuring out how to convert Processing's use of rotations into standard 0-360 degree counter-clockwise unit circle. \
I have JUST about figured it out however once the rotation goes from -180 (standard 180 degrees) abruptly to 180 degrees (standard 181 degrees) the &gt; algorithm doesn't fulfill the condition and creates a dot at 180 degrees, however it is supposed to create an arc that extends 90 degrees. Every other octant performs perfectly except for the 135-180 degree octant. I'm using the code of "Midpoint Circle Algorithm" on the Wikipedia page.
code as follows.</p>

<p>the added code for arcs is below</p>

<p>`// Calculate the angle the current point makes with the circle center
  int angle = (int) degrees(atan2(y, x)); //int(degrees(atan2(mouseY-(height/2),mouseX-(width/2))));</p>

<p>// draw the circle points as long as they lie in the range specified
  if (x &lt; y) {</p>

<pre><code>// draw point in range 0 to 45 degrees
if ( -90 + angle &gt;= startAngle &amp;&amp;  -90 + angle &lt;= endAngle) {
  point(centerX + y, centerY - x);
}

//// draw point in range 45 to 90 degrees
if (-angle &gt;= startAngle &amp;&amp; -angle &lt;= endAngle) {
  point(centerX + x, centerY - y);
}

//// draw point in range 90 to 135 degrees
if (-180 + angle &gt;= startAngle &amp;&amp; -180 + angle &lt;= endAngle) {
  point(centerX - x, centerY - y);
}

//// draw point in range 135 to 180 degrees
if ((-90 + -angle &gt;= (startAngle) &amp;&amp; -90 + -angle &lt;= (endAngle))) {
  point(centerX - y, centerY - x);
}

// draw point in range 180 to 225 degrees
if (90 + (angle) &gt;= (startAngle) &amp;&amp; 90 + (angle) &lt;= (endAngle)) {
  point(centerX - y, centerY + x);

  System.out.println("angle " + (90 + (angle)));
}

// draw point in range 225 to 270 degrees
if (180 + -angle &gt;= startAngle &amp;&amp; 180 + -angle &lt;= endAngle) {
  point(centerX - x, centerY + y);
}

// draw point in range 270 to 315 degrees
if (angle &gt;= startAngle &amp;&amp; angle &lt;= endAngle) {
  point(centerX + x, centerY + y);
}

// draw point in range 315 to 360 degrees
if (-angle + 90 &gt;= startAngle &amp;&amp; -angle + 90 &lt;= endAngle) {
  point(centerX + y, centerY + x);
}
</code></pre>

<p>}
}
`</p>
]]></description>
   </item>
   <item>
      <title>deg to rad</title>
      <link>https://forum.processing.org/two/discussion/14075/deg-to-rad</link>
      <pubDate>Sat, 19 Dec 2015 07:15:54 +0000</pubDate>
      <dc:creator>Jai</dc:creator>
      <guid isPermaLink="false">14075@/two/discussions</guid>
      <description><![CDATA[<p>why can i convert this neg deg into a rad</p>

<p><code>float deg = −3.5;</code></p>

<p>i get this when i try to run this deg as a float ,whats the issue? i have calculated <code>float deg = -144.3;</code> but i cant do −3.5?</p>

<pre><code>processing.app.SketchException: unexpected char: '\'
    at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:386)
    at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:192)
    at processing.mode.java.JavaBuild.build(JavaBuild.java:151)
    at processing.mode.java.JavaBuild.build(JavaBuild.java:130)
    at processing.mode.java.JavaMode.handleRun(JavaMode.java:120)
    at processing.mode.java.JavaEditor$23.run(JavaEditor.java:697)
    at java.lang.Thread.run(Unknown Source)
</code></pre>

<p>in a forum i visited looking to learn more about the subject i seen this</p>

<pre><code>π=3.141592653...π=3.141592653... is a constant (it's just a number).

Type this into a calculator and you're done.

To convert radians to degrees: multiply by 180π180π.

To convert degrees to radians: multiply by π180π180.

So −3.5×180π=−200.535228296...−3.5×180π=−200.535228296..., which is
−200.54 ∘
−200.54 ∘
to two decimal places.
</code></pre>

<p>which translate into 
<code>-3.5 \times \frac{180}{\pi}= -200.535228296...</code></p>
]]></description>
   </item>
   <item>
      <title>Changing colours of triangles with mousex and mousey</title>
      <link>https://forum.processing.org/two/discussion/13808/changing-colours-of-triangles-with-mousex-and-mousey</link>
      <pubDate>Sun, 06 Dec 2015 18:09:02 +0000</pubDate>
      <dc:creator>R_B</dc:creator>
      <guid isPermaLink="false">13808@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to make a simple sketch where depending on mouse location, the triangle changes colour.</p>

<p>I can do this for quarter squares by saying 
if (mouseX &lt; 300 &amp; mouseY &lt; 300) {
rect ...  }</p>

<p>but am unable to work out how to define the triangle from two corners to the centre - shown in my sketch as coloured red.</p>

<pre><code>void draw() {
  background(145,180,70);

  if (mouseX &lt; 300 &amp; mouseY &lt; 300) {
    triangle(0, 0, 0,600, 300,300); // Left
    fill(190,75,90);
    }

    if (mouseX &gt; 300 &amp; mouseY &gt; 300){
    triangle(300, 300, 600,600, 600,0); // Left
    fill(190,75,90); // Right
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Draw line at 90 degrees to other line</title>
      <link>https://forum.processing.org/two/discussion/13632/draw-line-at-90-degrees-to-other-line</link>
      <pubDate>Tue, 24 Nov 2015 21:35:02 +0000</pubDate>
      <dc:creator>rumlac</dc:creator>
      <guid isPermaLink="false">13632@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I am trying to work out how to draw a line with a length of 100 at 90 degrees to a line that originates at the centre of a circle.</p>

<p><img src="http://i67.tinypic.com/14lbba.png" alt="" /></p>

<p>I know:
the angle of the black line from the centre,
The x and y coordinates of the start point of the red line (small black circle)
The intended length of the red line</p>

<p>I need:
The X and Y coordinates of the end point of the red line so that it remains at 90 degrees to the black line and the length remains at 100.</p>

<p>The code for the sketch it:</p>

<pre><code>PVector a = new PVector(0, 0);
PVector b = new PVector(0, 150);
PVector c = new PVector(150, 0);
float angle1, arcangle1;
float tangentAngle;
int smallRadius = 10;
float bigDiam = 400;

void setup() {
  size(500, 500);
  smooth();
  strokeWeight(2);
}

void draw() {
  background(255);
  translate(width/2, height/2);
  noFill();
  ellipse(0, 0, bigDiam, bigDiam);
  fill(255);
  if (dist(b.x, b.y, 0, 0)&gt;((bigDiam/2) - smallRadius/2)) {
    fill(255, 0, 0);
  }

  line(a.x, a.y, b.x, b.y);
  ellipse(a.x, a.y, 20, 20);
  ellipse(b.x, b.y, smallRadius, smallRadius);
  strokeWeight(2);

  b.set(mouseX-width/2, mouseY-height/2, 0);


  angle1 = PVector.angleBetween(b, c);

if (c.y &lt;= b.y) { 
    arcangle1 = angle1;
  } else { 
    arcangle1 = angle1 + 2*(PI-angle1);
  }

  float tDistance = dist(b.x, b.y, 0, 0);

  fill(0);
  ellipse(0, 0, 50, 50);
  fill(255);
  text(degrees(arcangle1), -20, 0);
  fill(0, 0, 0, 50);
  arc(0, 0, bigDiam-150, bigDiam-150, 0, arcangle1, PIE);
  println(degrees(arcangle1));
  stroke(255, 0, 100);
  line(0+(200/tDistance)*(b.x-0), 0+(200/tDistance)*(b.y-0), 0, -(bigDiam/2));
  stroke(0);
  ellipse(0+(200/tDistance)*(b.x-0), 0+(200/tDistance)*(b.y-0), 10, 10);
}
</code></pre>

<p>Thanks!</p>
]]></description>
   </item>
   <item>
      <title>How do you constrain an angle</title>
      <link>https://forum.processing.org/two/discussion/12887/how-do-you-constrain-an-angle</link>
      <pubDate>Thu, 08 Oct 2015 02:00:35 +0000</pubDate>
      <dc:creator>gperez</dc:creator>
      <guid isPermaLink="false">12887@/two/discussions</guid>
      <description><![CDATA[<p>Hi. I'm trying to constrain an angle. , measured in radians. But radians takes negative values so constrain() method will not work.</p>

<p>So, i tried converting radians to angles, constrain degrees and convert to radians again. But the result is the same.</p>

<p><code>a = radians(constrain(degrees(a), 90, 270));</code></p>

<p>Any clue?</p>
]]></description>
   </item>
   <item>
      <title>Display relative bearing of joystick</title>
      <link>https://forum.processing.org/two/discussion/11898/display-relative-bearing-of-joystick</link>
      <pubDate>Thu, 30 Jul 2015 12:33:09 +0000</pubDate>
      <dc:creator>harrzack</dc:creator>
      <guid isPermaLink="false">11898@/two/discussions</guid>
      <description><![CDATA[<p>I'm creating a simple radar simulation and need to display the relative bearing of a joystick cursor.  I'm using the GameControlPlus library, and getting excellent results with a Logitech Extreme 3D stick.  I'm just not up to speed on the trig to do this...</p>

<p>I'd like to be able to display the relative degree position of the joystick cursor, such at at the top of the screen it would show 0 degrees,  when in the 3 o'clock position it would be 90 degree, and 6 o'clock would show 180 degrees and a 9 o'clock it would show 270... and so on.  I guess the max would be 359 deg after which the bearing would become 0 again.
This is relative to the center of the screen, so the Y portion (width) should have no effect on the reading.</p>

<p>I suspect this is fairly trivial to do, but as a Processing noob, my best efforts have failed!</p>
]]></description>
   </item>
   </channel>
</rss>