Geometry

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.

Answer:

    drawStar( width/2, height/2, min/4 );  // draw star in center

Geometry

Unit circle with angle

 

Now consider the method that draws the star:

drawStar( int x, int y, int size )

Each line (of the six) starts at the center, (x, y), and ends at a point on the circle of radius size. The X distance from the center of a point on a circle is size*cos( theta ). The Y distance from the center of a point on a circle is size*sin( theta ).

All you need to do is find the six values for theta and the six endpoints are yours.

QUESTION 7:

How many radians are there in a circle?