FUNCTION enclose_pregion_in_cregion

(* SCHEMA FUNCTIONAL_DATA_AND_SCHEMATIC_REPRESENTATION_MIM_LF; *)
 
FUNCTION enclose_pregion_in_cregion(prgn : polar_complex_number_region) : 
  cartesian_complex_number_region;
   
  PROCEDURE nearest_good_direction(acart : REAL; aitv : finite_real_interval; 
    VAR a : REAL; VAR a_in : BOOLEAN);
    a := acart;
    a_in := TRUE;
    IF a < aitv.min THEN
      IF a + 2.0 * PI < aitv.max THEN
        RETURN;
      END_IF;
      IF a + 2.0 * PI = aitv.max THEN
        a_in := max_included(aitv);
        RETURN;
      END_IF;
    ELSE
      IF a = aitv.min THEN
        a_in := min_included(aitv);
        RETURN;
      ELSE
        IF a < aitv.max THEN
          RETURN;
        ELSE
          IF a = aitv.max THEN
            a_in := max_included(aitv);
            RETURN;
          END_IF;
        END_IF;
      END_IF;
    END_IF;
    IF COS(acart - aitv.max) >= COS(acart - aitv.min) THEN
      a := aitv.max;
      a_in := max_included(aitv);
    ELSE
      a := aitv.min;
      a_in := min_included(aitv);
    END_IF;
  END_PROCEDURE;
LOCAL
  xc : REAL := 0.0;
  yc : REAL := 0.0;
  xmin : REAL := 0.0;
  xmax : REAL := 0.0;
  ymin : REAL := 0.0;
  ymax : REAL := 0.0;
  ritv : real_interval;
  xitv : real_interval;
  yitv : real_interval;
  aitv : finite_real_interval;
  xmin_exists : BOOLEAN;
  xmax_exists : BOOLEAN;
  ymin_exists : BOOLEAN;
  ymax_exists : BOOLEAN;
  xmin_in : BOOLEAN := FALSE;
  xmax_in : BOOLEAN := FALSE;
  ymin_in : BOOLEAN := FALSE;
  ymax_in : BOOLEAN := FALSE;
  a : REAL := 0.0;
  r : REAL := 0.0;
  a_in : BOOLEAN := FALSE;
  min_clo : open_closed := open;
  max_clo : open_closed := open;
END_LOCAL;
  IF NOT EXISTS(prgn) THEN
    RETURN (?);
  END_IF;
  xc := prgn.centre.real_part;
  yc := prgn.centre.imag_part;
  ritv := prgn.distance_constraint;
  aitv := prgn.direction_constraint;
  nearest_good_direction(PI, aitv, a, a_in);
  IF COS(a) >= 0.0 THEN
    xmin_exists := TRUE;
    xmin := xc + real_min(ritv) * COS(a);
    xmin_in := a_in AND (min_included(ritv) OR (COS(a) = 0.0));
  ELSE
    IF max_exists(ritv) THEN
      xmin_exists := TRUE;
      xmin := xc + real_max(ritv) * COS(a);
      xmin_in := a_in AND max_included(ritv);
    ELSE
      xmin_exists := FALSE;
    END_IF;
  END_IF;
  nearest_good_direction(0.0, aitv, a, a_in);
  IF COS(a) <= 0.0 THEN
    xmax_exists := TRUE;
    xmax := xc + real_min(ritv) * COS(a);
    xmax_in := a_in AND (min_included(ritv) OR (COS(a) = 0.0));
  ELSE
    IF max_exists(ritv) THEN
      xmax_exists := TRUE;
      xmax := xc + real_max(ritv) * COS(a);
      xmax_in := a_in AND max_included(ritv);
    ELSE
      xmax_exists := FALSE;
    END_IF;
  END_IF;
  nearest_good_direction(-0.5 * PI, aitv, a, a_in);
  IF SIN(a) >= 0.0 THEN
    ymin_exists := TRUE;
    ymin := yc + real_min(ritv) * SIN(a);
    ymin_in := a_in AND (min_included(ritv) OR (SIN(a) = 0.0));
  ELSE
    IF max_exists(ritv) THEN
      ymin_exists := TRUE;
      ymin := yc + real_max(ritv) * SIN(a);
      ymin_in := a_in AND max_included(ritv);
    ELSE
      ymin_exists := FALSE;
    END_IF;
  END_IF;
  nearest_good_direction(0.5 * PI, aitv, a, a_in);
  IF SIN(a) <= 0.0 THEN
    ymax_exists := TRUE;
    ymax := yc + real_min(ritv) * SIN(a);
    ymax_in := a_in AND (min_included(ritv) OR (SIN(a) = 0.0));
  ELSE
    IF max_exists(ritv) THEN
      ymax_exists := TRUE;
      ymax := yc + real_max(ritv) * SIN(a);
      ymax_in := a_in AND max_included(ritv);
    ELSE
      ymax_exists := FALSE;
    END_IF;
  END_IF;
  IF NOT (xmin_exists OR xmax_exists OR ymin_exists OR ymax_exists) THEN
    RETURN (?);
  END_IF;
  IF xmin_exists THEN
    IF xmin_in THEN
      min_clo := closed;
    ELSE
      min_clo := open;
    END_IF;
    IF xmax_exists THEN
      IF xmax_in THEN
        max_clo := closed;
      ELSE
        max_clo := open;
      END_IF;
      xitv := make_finite_real_interval(xmin, min_clo, xmax, max_clo);
    ELSE
      xitv := make_real_interval_from_min(xmin, min_clo);
    END_IF;
  ELSE
    IF xmax_exists THEN
      IF xmax_in THEN
        max_clo := closed;
      ELSE
        max_clo := open;
      END_IF;
      xitv := make_real_interval_to_max(xmax, max_clo);
    ELSE
      xitv := the_reals;
    END_IF;
  END_IF;
  IF ymin_exists THEN
    IF ymin_in THEN
      min_clo := closed;
    ELSE
      min_clo := open;
    END_IF;
    IF ymax_exists THEN
      IF ymax_in THEN
        max_clo := closed;
      ELSE
        max_clo := open;
      END_IF;
      yitv := make_finite_real_interval(ymin, min_clo, ymax, max_clo);
    ELSE
      yitv := make_real_interval_from_min(ymin, min_clo);
    END_IF;
  ELSE
    IF ymax_exists THEN
      IF ymax_in THEN
        max_clo := closed;
      ELSE
        max_clo := open;
      END_IF;
      yitv := make_real_interval_to_max(ymax, max_clo);
    ELSE
      yitv := the_reals;
    END_IF;
  END_IF;
  RETURN (make_cartesian_complex_number_region(xitv, yitv));
END_FUNCTION;

Referenced By

Defintion enclose_pregion_in_cregion is references by the following definitions:
DefinitionType
 compatible_complex_number_regions FUNCTION
 subspace_of FUNCTION


[Top Level Definitions] [Exit]

Generated by STEP Tools® EXPRESS to HTML Converter
2012-03-27T17:17:33-04:00