/* This is our utility function for drawing overlays describing the force vectors acting on our object. */ void drawOverlay(Vector2D v, Vector2D location, float tscale, String name) { if (showVectors == true) { // save our drawing environment pushMatrix(); // move to our position to draw our force vector translate(location.getX(), location.getY()); // drawing settings stroke(255); float arrowSize = 10; float arrowLength = v.magnitude() * tscale; // rotate so that the direction of our drawing is the heading // of our vector rotate(v.heading()); // draw the arrow line(0, 0, arrowLength, 0); line(arrowLength, 0, arrowLength - arrowSize, arrowSize / 2); line(arrowLength, 0, arrowLength - arrowSize, arrowSize / 2 * -1); // label our arrow fill(255, 255, 255, 255); text(name, arrowLength, 0); // reset our drawing environment popMatrix(); } }