# Problem in creating compass in Processing for Android

**URL:** https://discourse.processing.org/t/problem-in-creating-compass-in-processing-for-android/13519
**Category:** Processing for Android
**Created:** [August 21, 2019, 12:33pm UTC](https://discourse.processing.org/t/problem-in-creating-compass-in-processing-for-android/13519 "2019-08-21T12:33:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![aiman](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@aiman](https://discourse.processing.org/u/aiman)
#### Post date: [August 21, 2019, 12:33pm UTC](https://discourse.processing.org/t/problem-in-creating-compass-in-processing-for-android/13519/1 "2019-08-21T12:33:24Z")

</div>

Hello. I’m trying to create a simple compass in processing.  
I’m following this tutorial:  
[https://android.processing.org/tutorials/wallpapers/index.html](https://android.processing.org/tutorials/wallpapers/index.html)

everything is fin. The rotation angle which I’m getting is also correct. (I’ve tried other playstore apps to verify it) but when the compass needle draws itself. I see too much variation in it.

Here’s the code for drawing:

void draw() {  
background(255);

float cx = width \* 0.5;  
float cy = height \* 0.4;  
float radius = 0.8 \* cx;

translate(cx, cy);

noFill();  
stroke(0);  
strokeWeight(2);  
ellipse(0, 0, radius_2, radius_2);  
line(0, -cy, 0, -radius);

fill(192, 0, 0);  
noStroke();  
//rotate(-azimuth);  
rotate(round(bearingInFloat));  
beginShape();  
vertex(-30, 40);  
vertex(0, 0);  
vertex(30, 40);  
vertex(0, -radius);  
endShape();

}

bearingInFloat is the variable containing rotation angle from 0 to 360.

Here’s the video of the problem:

[![](https://img.youtube.com/vi/tpl4T7rsJZE/maxresdefault.jpg "compass in processing") ](https://www.youtube.com/watch?v=tpl4T7rsJZE)

---

<div class="post-metadata">

### Author: ![Waboqueox](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/waboqueox/32/5643_2.png) [@Waboqueox](https://discourse.processing.org/u/Waboqueox)
#### Post date: [August 22, 2019, 9:56am UTC](https://discourse.processing.org/t/problem-in-creating-compass-in-processing-for-android/13519/2 "2019-08-22T09:56:09Z")

</div>

Hi, @aiman

Taking a fast look, the problem can be the angle, rotation expect the angles in radians (when your cursor move that fast with little variations, that can be because of the angles), you can put the anglemode in radians, or cast bearingInFloat to radians

```auto
rotate(radians(bearingInFloat));

```

Hope it helps 😃

---

<div class="post-metadata">

### Author: ![aiman](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@aiman](https://discourse.processing.org/u/aiman)
#### Post date: [August 22, 2019, 10:32am UTC](https://discourse.processing.org/t/problem-in-creating-compass-in-processing-for-android/13519/3 "2019-08-22T10:32:17Z")

</div>

Thank you so much for replying. Yes I did figure that out hours after posting the thread. I do appreciate your help thou. Thanks 🙂
