Hello. I’m trying to create a simple compass in processing.
I’m following this tutorial:
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, radius2, radius2);
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: