The first example is a simple applet that computes the absolute value
and the phase angle of a complex number given by its real and imaginary
parts. Surely this task can be done with every simple pocket calculator,
but quite often the students apply the corresponding formulas without
realising that the arc tangent only returns values within a range of
. The
applet computes the value using the signs of real and imaginary part to
find the correct quadrant.
The user interface contains two input fields to enter real and imaginary part and two output fields for the results. All fields have description texts, and the phase angle field additionally shows the "unit" rad. For the direct input or output of numerical values the PhysBeans library contains the bean NumericTextLine, which will be used here. The applet will then look like
Since a conversion into polar coordinates often appears in physics calculations, PhysBeans has a special function bean Cart2PolarFunction for that. The beans of the applets are connected in a simple way: The input fields send new values directly to the computational bean, which computes the new results and sends them to the output fields. The following image shows all necessary beans and the flow of information between them:
The implementation will proceed in the following steps: