Skip to content

Recipe 11 — Polar Angular Conventions

Polar plots are only useful when the angular convention matches the problem. This recipe compares the two common conventions side by side: compass-style degrees with 0 at the top, and mathematical radians with 0 at the right. See Polar Properties.

Compass convention: degrees, 0 at top

Compass-convention polar plot, 0 degrees at top
Recipe 11A — compass-convention polar plot, 0 degrees at top
#include <ViewPoint.h>
using namespace viewpoint;

float theta = 0.0f;

void setup() {
    view.begin(polar);
    view.setAngularUnits(AngularUnit::Degrees);
    view.setAngularOffset(90);
    view.setAngularStep(15);
    view.setRadialRange(0, 1);
    view.trace("Petal Rose").setColor(colors::Cyan);
}

void loop() {
    view.addData("Petal Rose", fabs(cos(2 * theta * DEG_TO_RAD)), theta);
    view.send();
    theta += 2.0f;
    if (theta >= 360.0f) theta -= 360.0f;
}

Math convention: radians, 0 at right

Math-convention polar plot, 0 radians at right
Recipe 11B — math-convention polar plot, 0 radians at right
#include <ViewPoint.h>
using namespace viewpoint;

float theta = 0.0f;

void setup() {
    view.begin(polar);
    view.setRadians();
    view.setAngularStep(30);
    view.setRadialRange(0, 1);
    view.trace("Phasor").setColor(colors::Gold);
}

void loop() {
    view.addData("Phasor", theta / TWO_PI, theta);
    view.send();
    theta += 0.03f;
    if (theta >= TWO_PI) theta -= TWO_PI;
}

What the functions do

  • setAngularOffset(90) rotates the compass plot so 0 degrees is at the top.
  • setRadians() switches incoming angle values and angular offset to radians.
  • setAngularStep() controls grid spacing. It currently accepts whole degrees even when the angular unit is radians.
  • setRadialRange(0, 1) creates a unit-radius plot suitable for a normalized bearing or phasor.