Design: 02.03.03/P03

This is an abstract, language-independent design. Grim details may be found in the corresponding source code. You may return to the documentation for the module containing this program design, or to the entire hierarchical table of topics covered by the PVT.


PROGRAM 3: Geometrical borderline cases for graphical primitives

CHARACTERISTICS: ynnn

OPERATOR SCRIPT: passive test.

DESIGN:

ndtran = non-distorting transformation: arbitrary shift and
  rotate (but not scale).  Apply this to easily visualized
  2D cases to generate more complex 3D cases.

*** *** *** *** ***   polyline   *** *** *** *** *** ***

simpl = simple polyline = (1,1),(2,2),(2,1)
compl = complex polyline = ndtran X simpl

Build structure 101:
  1. polyline 3: compl

sisrp = simple search reference point = (2.1, 1.5, 0.1)
sdist = distance from primitive = 0.1 * sqrt(2)

TEST: #SR 2 4 5 6 7 9 10 12
      "The middle of a line segment in a 3D polyline should be
       found if and only if its true distance from the search
       reference point is not greater than the search distance."

With transformed SRP, try search distance first just above and
   then just below sdist.
pass/fail depending on (polyline first not found, then found)

sisrp = simple search reference point = (2.1, 2.1, 0.1)
sdist = distance from primitive = 0.1 * sqrt(3)

TEST: #SR 2 4 5 6 7 9 10 12
      "The vertex of a 3D polyline should be found if and only if
       its true distance from the search reference point is not
       greater than the search distance."

With transformed SRP, try search distance first just above and
   then just below sdist.
pass/fail depending on (polyline first not found, then found)


*** *** *** *** ***   text   *** *** *** *** *** ***

tdv1 =  first text direction vector = 1.2, 5.1, 0.2
tdv2 = second text direction vector = 2.1, 1.4, 3.2
tlcu = text local co-ordinate U vector = normalized tdv1
tlcv = text local co-ordinate V vector = unit vector in tdv-plane,
       perpendicular to tlcu, and such that tlcv . tdv2 > 0
tlcw = text local co-ordinate W vector, perpendicular to text
       plane = tlcu X tlcv
tpos = text position = 3.1, 4.2, 0.1

Set up geometric attributes:
chht = character height = 3.3
chup = character up vector = (1.2, -3.1)
txpath = text path = UP
txalh,txalv = text alignment = CENTER,CAP
str = character string = "Quod licet Jovi, non licet bovi."

<inquire text extent> with
  workstation type           = primary workstation type
    (ignored because font #1 is workstation-independent)
  text font                  = 1
  character expansion factor = 1.0
  character spacing          = 0.0
    (three above set as assumed by spatial search, see SR15)
  character height           = chht
  text path                  = txpath
  text alignment             = txalh,txalv
  character string           = str
    to determine:
  recxlo,recxhi,recylo,recyhi = text extent rectangle in TLC,
    with assumed text position = 0,0 character up vector = (0,1),
    and text precision = STROKE

Rotate expected rectangle in TLC around 0,0 according to
  character-up vector.
rotang = rotation angle = atan2(chupv, chupu) - pi/2
build and apply transformation:

xtlc(1),ytlc(1) = rotated (recxlo, recylo)
xtlc(2),ytlc(2) = rotated (recxhi, recylo)
xtlc(3),ytlc(3) = rotated (recxhi, recyhi)
xtlc(4),ytlc(4) = rotated (recxlo, recyhi)

ztlc(1) = 0
ztlc(2) = 0
ztlc(3) = 0
ztlc(4) = 0

Transform 4 TLC corners to expected values in MC; use tlc-vectors
for rotation and tpos for shift.  Also, get midpoint:

midx,midy,midz = 0
for cx = 1 to 4
   xmc(cx) = tposx + tlcux*xtlc(cx) + tlcvx*ytlc(cx) + tlcwx*ztlc(cx)
   ymc(cx) = tposy + tlcuy*xtlc(cx) + tlcvy*ytlc(cx) + tlcwy*ztlc(cx)
   zmc(cx) = tposz + tlcuz*xtlc(cx) + tlcvz*ytlc(cx) + tlcwz*ztlc(cx)
   midx = midx + xmc(cx)/4
   midy = midy + ymc(cx)/4
   midz = midz + zmc(cx)/4
next cx

Expected MC rectangle is complete; now generate actual text extent.

Build structure 101:
  1.  set text precision      = STRING
  2.  set character height    = chht
  3.  set character up vector = chup
  4.  set text path           = txpath
  5.  set text alignment      = txalh,txalv
  6.  text 3: str at tpos with tdv1,tdv2

Project SRP out past corner #4:
SRP    = corner(4) + (corner(4) - mid-point)
sdist  = distance from corner(4) to mid-point

TEST: #SR 2 4 5 6 7 9 10 15
      "The size of a 3D text extent rectangle, as treated by ISS,
       should be based on STROKE precision, even if the current
       precision is not STROKE."

With SRP, try search distance first just above and then just
   below sdist.
pass/fail depending on (text first not found, then found)

replace element number #1 with:
  1.  set text precision      = STROKE

TEST: #SR 2 4 5 6 7 9 10 15
      "The corner of a 3D text extent rectangle should be
       found if and only if its true distance from the search
       reference point is not greater than the search distance."

With SRP, try search distance first just above and then just
   below sdist.
pass/fail depending on (text first not found, then found)

Project SRP above text plane:
SRP    = mid-point + tlcw
sdist  = 1.0 (because tlcw is a unit vector).

TEST: #SR 2 4 5 6 7 9 10 15
      "The middle of a 3D text extent rectangle should be
       found if and only if its true distance from the search
       reference point is not greater than the search distance."

With SRP, try search distance first just above and then just
   below sdist.
pass/fail depending on (text first not found, then found)

Project SRP above and outside of edge of text plane:
zdist  = 2.2
cor12  = vector from corner 2 to corner 1 = corner(1) - corner(2)
SRP    = mid-point + zdist*tlcw + cor12
sdist  = sqrt (zdist ** 2 + (cor12 / 2) ** 2 )

TEST: #SR 2 4 5 6 7 9 10 15
      "The edge of a 3D text extent rectangle should be
       found if and only if its true distance from the search
       reference point is not greater than the search distance."

With SRP, try search distance first just above and then just
   below sdist.
pass/fail depending on (text first not found, then found)


*** *** *** *** ***   cell array   *** *** *** *** *** ***

simpl = simple cell array = p:(1,1), q:(4,2), r:(2,3)
compl = complex cell array = ndtran X simpl

Build structure 101:
  1. cell array 3: compl

sisrp = simple search reference point = (2, 2, 0.1)
sdist = distance from primitive = 0.1

TEST: #SR 2 4 5 6 7 9 10 17
      "The interior region of a 3D cell array should be
       found if and only if its true distance from the search
       reference point is not greater than the search distance."

With transformed SRP, try search distance first just above and
   then just below sdist.
pass/fail depending on (cell array first not found, then found)

sisrp = simple search reference point = (1, 2.25, 0.1)
npe   = nearest point on edge = (1.5, 2, 0)
sdist = distance from primitive =
   sqrt( (sisrpx-npex)**2 + (sisrpy-npey)**2 + (sisrpz-npez)**2 )

TEST: #SR 2 4 5 6 7 9 10 17
      "The edge of a 3D cell array should be found if and only if
       its true distance from the search reference point is not
       greater than the search distance."

With transformed SRP, try search distance first just above and
   then just below sdist.
pass/fail depending on (cell array first not found, then found)


*** *** *** *** ***   fill area   *** *** *** *** *** ***

simpl = simple fill area = (0,0), (2,0), (2,3.5), (.5,3.5),
  (.5,2), (1.5,2), (1.5,3), (0,3), (0,1), (.5,1), (.5,1.5),
  (1.5,1.5), (1.5,.5), (0,.5)
compl = complex fill area = ndtran X simpl

simple fill area looks like:

        ------- 2,3.5
        |     |
     ---+---  |
     |  |  |  |
     |  ----  |
     |        |
     |  ----  |
     |  |  |  |
     ----  |  |
           |  |
     -------  |
     |        |
 0,0 ---------- 2,0


Build structure 101:
  1. fill area 3: compl

sisrp = simple search reference point = (1, 1.7, 0.1)
sdist = distance from primitive = 0.1

TEST: #SR 2 4 5 6 7 9 10 13
      "The interior region of a 3D fill area should be
       found if and only if its true distance from the search
       reference point is not greater than the search distance."

With transformed SRP, try search distance first just above and
   then just below sdist.
pass/fail depending on (fill area first not found, then found)

sisrp = simple search reference point = (2.2, 1, 5)
sdist = distance from primitive = sqrt (0.2**2 + 5**2)

TEST: #SR 2 4 5 6 7 9 10 13
      "The edge of a 3D fill area should be found if and only if
       its true distance from the search reference point is not
       greater than the search distance."

With transformed SRP, try search distance first just above and
   then just below sdist.
pass/fail depending on (fill area first not found, then found)

sisrp = simple search reference point = (1.1, 1.2, 0)
sdist = distance from primitive = 0.3

TEST: #SR 2 4 5 6 7 9 10 13
      "A concave region of a 3D fill area should be
       found if and only if its true distance from the search
       reference point is not greater than the search distance."

With transformed SRP, try search distance first just above and
   then just below sdist.
pass/fail depending on (fill area first not found, then found)

sisrp = simple search reference point = (1.1, 2.7, 0)
sdist = distance from primitive = 0.3

TEST: #SR 2 4 5 6 7 9 10 13
      "An interior region of a 3D fill area surrounding a hole
       formed by a self-intersecting border should be found if
       and only if its true distance from the search reference
       point is not greater than the search distance."

With transformed SRP, try search distance first just above and
   then just below sdist.
pass/fail depending on (fill area first not found, then found)


*** *** *** *** ***   fill area set   *** *** *** *** *** ***

simpl = simple fill area set = (1,0), (0,0), (0,1), (1,1) /
                               (2,1), (3,1), (3,0), (2,0)
compl = complex fill area set = ndtran X simpl

Build structure 101:
  1. fill area set 3: compl

sisrp = simple search reference point = (1.8, 0.2, 0)
sdist = distance from primitive = 0.2

TEST: #SR 2 4 5 6 7 9 10 14
      "The edge of a 3D fill area set should be found if and only
       if its true distance from the search reference point is
       not greater than the search distance."

With transformed SRP, try search distance first just above and
   then just below sdist.
pass/fail depending on (fill area set first not found, then found)

END PROGRAM 3