[Oberon] Oberon-7 - Circle Segments

Jörg joerg.straube at iaeth.ch
Wed Feb 20 09:34:40 CET 2019


Tomas

The twelve segments - as originally requested - can be done with HourTicks below with INTEGER arithmetic only.
According to JR Strohm's suggestion even MinuteTicks can be calculated quite accurately with REALs without module "Math".

PROCEDURE MinuteTicks*;
	VAR x, y: ARRAY 60 OF REAL; s6, c6: REAL; i: INTEGER;
	BEGIN
		x[0]:= 0.0; y[0] := 1.0; s6 := 0.10452846; c6 := 0.99452189;
		FOR i := 1 TO 59 DO
			x[i] := x[i-1] * c6 + y[i-1] * s6;
			y[i] := y[i-1] * c6 - x[i-1] * s6;
			Out.RealFix(x[i], 10, 3); Out.RealFix(y[i], 10, 3); Out.Ln; (* debug output *)
		END
	END MinuteTicks;

Jörg

Am 19.02.19, 20:06 schrieb "Jörg" <joerg.straube at iaeth.ch>:

    PROCEDURE HourTicks(r: INTEGER);
    BEGIN
      s:= r DIV 2; c := r * 181 DIV 209;
      x[0] := 0; y[0] := r;
      x[1] := s; y[1] := c;
      x[2] := c; y[2] := s;
      x[3] := r; y[3] := 0;
      x[4] := c; y[4] := -s;
      x[5] := s; y[5] := -c;
      x[6] := 0; y[6] := -r;
      x[7] := -s; y[7] := -c;
      x[8] := -c; y[8] := -s;
      x[9] := -r; y[9] := 0;
      x[10] := -c; y[10] := s;
      x[11] := -s; y[11] := c;
    END HourTicks
    
    br
    Jörg
    
    > Am 19.02.2019 um 18:23 schrieb Tomas Kral <thomas.kral at email.cz>:
    > 
    > On Tue, 19 Feb 2019 18:08:54 +0100
    > Tomas Kral <thomas.kral at email.cz> wrote:
    > 
    >> circle into 12
    >> segments
    > 
    > Looking at V4 `ClockElem' I see this
    > 
    >  PROCEDURE Init;
    >    VAR i: INTEGER;
    >  BEGIN i := 0;
    >    WHILE i < 60 DO
    >      sin[i] := Math.sin(2 * Math.pi / 60 * i);
    >      cos[i] := Math.cos(2 * Math.pi / 60 * i);
    >      INC(i)
    >    END
    >  END Init;
    > 
    > I probably cannot do without trigonometry, right?
    > 
    > -- 
    > Tomas Kral <thomas.kral at email.cz>
    > --
    > Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
    > https://lists.inf.ethz.ch/mailman/listinfo/oberon
    




More information about the Oberon mailing list