Solutions TOPIC C: Reals & Booleans

Contents :

 

Exercises :


D1

Exercise


S1

MODULE S1;
<* NOOPTIMIZE + *>  (* voor de Debugger *)
<* WOFF + *> (* geen warnings *)
FROM RealMath IMPORT power, arctan, pi, cos, sin, sqrt;
FROM JJ3D IMPORT StartMy3DWorld, DrawEverything, ClearScreen, WaitUntilQPressed, Delay, WrStr, WrCard, WrInt, WrReal, WrBool, WrLn;
FROM JJ3D IMPORT Plot, Line, ThickLine, PlotText, Triangle, RectangleXY, RectangleYZ, RectangleXZ, Polygon, Cube, Block, Cilinder, Arrow3D;
FROM JJ3D IMPORT RgbColor, Lighter, Darker, RED, GREEN, BLUE, CYAN, MAGENTA, GRAY, BROWN;
FROM JJ3D IMPORT BLACK, BRIGHTWHITE, WHITE, LIGHTRED, LIGHTGREEN, LIGHTBLUE, LIGHTCYAN, LIGHTMAGENTA, LIGHTYELLOW;

 CONST  X0 = 300; Y0 = 50; Z0 = 0;
       
  VAR
    z: ARRAY[1..25] OF INTEGER;   

BEGIN
  StartMy3DWorld("Mijn 3D-wereld") ;

  z[1] :=  10;         z[3] := 100;          z[5] := 200;         z[7] := 300;
  z[9] := 233;         z[11] := 166;         z[13] := 140;        z[15] := 166;
  z[17] := 233;        z[19] := 300;         z[21] := 200;        z[23] := 100;
  z[25] := 12;          
   
  Cube(X0, Y0, Z0, 20, RED, TRUE);
       

       


       
  WaitUntilQPressed();
END S1.
Exercise



S2

MODULE S2;
<* NOOPTIMIZE + *>  (* voor de Debugger *)
<* WOFF + *> (* geen warnings *)
FROM RealMath IMPORT power, arctan, pi, cos, sin, sqrt;
FROM JJ3D IMPORT StartMy3DWorld, DrawEverything, ClearScreen, WaitUntilQPressed, Delay, WrStr, WrCard, WrInt, WrReal, WrBool, WrLn;
FROM JJ3D IMPORT Plot, Line, ThickLine, PlotText, Triangle, RectangleXY, RectangleYZ, RectangleXZ, Polygon, Cube, Block, Cilinder, Arrow3D;
FROM JJ3D IMPORT RgbColor, Lighter, Darker, RED, GREEN, BLUE, CYAN, MAGENTA, GRAY, BROWN;
FROM JJ3D IMPORT BLACK, BRIGHTWHITE, WHITE, LIGHTRED, LIGHTGREEN, LIGHTBLUE, LIGHTCYAN, LIGHTMAGENTA, LIGHTYELLOW;

 CONST HOOGTE = 500;


  VAR


BEGIN
  StartMy3DWorld("Mijn 3D-wereld") ;

  (* geeft de hoogte van de toren aan *)
  Cilinder(100, 100, 0, 20, HOOGTE, BLUE, TRUE);   
  Block(100-200, 100-10, HOOGTE, 400, 20, 10, BLUE, TRUE);


  (* zo teken je een kubus *)
  Cube(450, 100, 100, 100, RgbColor(200, 100, 50), TRUE);


  WaitUntilQPressed();

   
END S2.

Exercise

S3

MODULE S3;
<* NOOPTIMIZE + *>  (* voor de Debugger *)
<* WOFF + *> (* geen warnings *)
FROM RealMath IMPORT power, arctan, pi, cos, sin, sqrt;
FROM JJ3D IMPORT StartMy3DWorld, DrawEverything, ClearScreen, WaitUntilQPressed, Delay, WrStr, WrCard, WrInt, WrReal, WrBool, WrLn;
FROM JJ3D IMPORT Plot, Line, ThickLine, PlotText, Triangle, RectangleXY, RectangleYZ, RectangleXZ, Polygon, Cube, Block, Cilinder, Arrow3D;
FROM JJ3D IMPORT RgbColor, Lighter, Darker, RED, GREEN, BLUE, CYAN, MAGENTA, GRAY, BROWN;
FROM JJ3D IMPORT BLACK, BRIGHTWHITE, WHITE, LIGHTRED, LIGHTGREEN, LIGHTBLUE, LIGHTCYAN, LIGHTMAGENTA, LIGHTYELLOW;

CONST
  HOEK = 30;
  AANTAL = 360/HOEK;

VAR
  x_real, y_real, radialen: REAL;
  i, x, y : INTEGER;
BEGIN
  StartMy3DWorld("Mijn 3D-wereld") ;
   
  FOR i := 1 TO AANTAL DO
    radialen := VAL(REAL, i * HOEK) * pi / 180.0; (* converteer hoek naar REAL en naar radialen *)
    x_real := sin(radialen); (* HIER MOET JE DE JUISTE COORDINATEN BEREKENEN!! *)
    y_real := cos(radialen);
    WrStr("(");WrReal(x_real, 2);WrStr(", ");WrReal(y_real, 2);WrStr(") ");
 
    x := VAL(INTEGER, x_real); (* omzetting terug naar integers *)
    y := VAL(INTEGER, y_real);

  END; (* FOR *)
    WrLn;
   


       
  WaitUntilQPressed();

END S3.
Exercise

X1

Exercise

H1

Exercise

H2



T1

Exercise