A Processing Java-mode sketch uses nested coordinate transformations to place two joint markers:
void setup() { size(420, 300); noStroke(); ellipseMode(CENTER); pushMatrix(); translate(200, 120); rotate(HALF_PI); pushMatrix(); translate(50, 0); ellipse(0, 0, 12, 12); // marker A popMatrix(); ellipse(30, 0, 12, 12); // marker B popMatrix(); }
Using Processing's default 2D screen coordinates, what are the screen coordinates of the centres of markers A and B? All coordinates below are in pixels.
A: (200,70)(200,70)(200,70); B: (200,90)(200,90)(200,90).
A: (200,170)(200,170)(200,170); B: (200,200)(200,200)(200,200).
A: (200,170)(200,170)(200,170); B: (200,150)(200,150)(200,150).
A: (250,120)(250,120)(250,120); B: (230,120)(230,120)(230,120).
Unlock full course notes by signing up
Tracing the position actually drawn
A Processing Java-mode sketch animates a marker using the following complete code:
Count the first execution of draw() as call 1. Immediately after call 8 returns, before call 9 begins, what is the horizontal screen coordinate of the marker's centre in the displayed image?
Restoring colour without losing position
A Processing Java-mode sketch should draw an orange equipment block with its upper-left corner at (180,80) px(180,80)\ \text{px}(180,80) px and a blue circular indicator centred at (60,50) px(60,50)\ \text{px}(60,50) px. It uses this code:
The indicator appears orange. Which single edit produces both intended colours and both intended positions? A matrix pair means pushMatrix() with its matching popMatrix(); a style pair means pushStyle() with its matching popStyle().
Comparing consecutive-temperature alarm conditions
An equipment monitor records one temperature per second. The following Processing sketch in Java mode processes the stored temperatures, in °C, once from beginning to end:
Determine the final alarmCount and meanTrigger for this original sketch. Then determine both quantities for a modified sketch in which only if (run == 3) becomes if (run >= 3).
Treat the original and modified sketches as independent runs with all variables initialized as shown. Enter both alarm counts as exact integers and both mean trigger temperatures in °C, to one decimal place.