Contact us Heritage collections Image license terms
HOME ACL Associates Technology Literature Applications Society Software revisited
Further reading □ OverviewNo.1No.2No.3No.4No.5No.6No.7No.8No.9No.10No.11No.12No.13No.14No.15No.16No.17No.18No.19No.20No.22No.23No.24No.25
ACD C&A INF CCD CISD Archives Contact us Heritage archives Image license terms

Search

   
ACLLiteratureProgress ReportsSPROGS Technical Papers
ACLLiteratureProgress ReportsSPROGS Technical Papers
ACL ACD C&A INF CCD CISD Archives
Further reading

Overview
No.1
No.2
No.3
No.4
No.5
No.6
No.7
No.8
No.9
No.10
No.11
No.12
No.13
No.14
No.15
No.16
No.17
No.18
No.19
No.20
No.22
No.23
No.24
No.25

SPROGS Technical Paper No 22: 3-dimensional SPROGS

R E Thomas

18 April 1974

1. INTRODUCTION

This paper describes a set of routines which gives SPROGS the ability to handle line-drawn 3-D objects. The set is available in this form so that the existing 2-D system is not slowed by extra tests nor enlarged by extra table entries. However, it would be possible to provide an integrated 3-D system in the manner outlined at the end by using this set as a basis.

2. USER ROUTINES

The following routines are available:

      ZVIEW (X,Y,Z,D) 

defines the view point, from which the 3-D objects will be projected, as (X,Y,Z). Objects are projected onto a view plane, which is situated at right-angles to the line joining (X,Y,Z) to the origin, and at distance D from the view point in the direction of the origin (D may be negative). Objects behind the view point will be excluded. The co-ordinate system of the view plane is the currently selected region, with origin at the projection of the 3-D origin. The 2-D Y axis is in the same plane as the 3-D Y axis.

The. value of D determines the direction of view and the extent of perspective distortion. It can also be used to give a depth intensity variation by calling:

      ZVIS (XMI, XMO) 

which sets the intensities of points near the viewer to XMI and of points on the other side of the view plane to XMO. Setting one or other of these values to zero will effectively cut the object. Care must be taken, however, that INTNST is used to restore the desired intensity if 2-D work is resumed.

The three basic 3-D routines are:

      SETXYZ (X,Y,Z) 
      TODXYZ (DX,DY,DZ) 
      PLOTZ (CH) 

Since SETXYZ performs no calculation, the routine PLOTZ is required to plot a character at a point in 3-D. If, however, TODXYZ has been used immediately prior to this, and the resulting line endpoint is visible, PLOT will also put a character at the desired place. Throughout, 2-D routines can be used to draw directly on the view plane, but the 3-D routines will reset the current 2-D co-ordinates (XPOS,YPOS) as required.

TODXYZ will call INTNST   
                 VEC   
                 INTNST   
                 VEC   
PLOTZ  will call INTNST   
                 SETXY   
                 PLOT   

If XMI=XMO, no call of INTNST will be made. VEC will only be called twice if the view plane intersects the line, and different intensities are required. Points and lines behind the view point are ignored.

The 'high-level' routines:

      UPDXYZ (DX,DY,DZ) 
      TOXYZ (X,Y,Z) 
      VECZ (X1,Y1,Z1,X2,Y2,Z2) 
      CUBER (DX,DY,DZ) 

are also provided. CUBER will draw a cube from the current 3-D point, with axes parallel to the 3-D co-ordinate axes.

3-D.expansion and rotation are provided by:

      ROTAXZ (X1,Y1,Z1,X2,Y2,Z2) 
      ROTANZ (TH) 
      EXPANZ (X,Y,Z,XT,YT,ZY) 
      ERDRZ (ORDR) 

ERDRZ defines the rotation/expansion order (as in the 2-D case). EXPANZ defines the expansion factors and the point about which expansion is to take place. ROTAXZ defines the axis of rotation, and ROTANZ defines the angle through which objects are to be rotated about the given axis. It is, of course, possible to use the 2-D rotation and expansion system as well, to change the projected image.

3. 3-D PROJECTION EQUATIONS

O Y X Z V' V A A' P P' β α
V     = view point
A     = point of 3-D object, co-ordinates  (X',Y',Z')   
PP'   = line in view plane           
a     = angle between OV and its projection OV' in XZ plane   
b     = angle between OV' and Z axis       
V' and A' are projections of V and A respectively on XZ plane 
O X Z V' A' B' β
B'  is the perpendicular from A' to OV'
OB' = Z' cos β + X' sin β
A'B' = X' cos β - Z' sin β
O Y V' V A" B' B C α
B is the perpendicular from B' to OV
A" is the perpendicular from A to the plane OVV'
C is the perpendicular from A" to OV
OB    =   (Z'cos β + X' sin β) cos α
A"C   =   Y' cos α - (Z' cos β + X' sin β) sin α
OC    =   Y' sin α + (Z' cos β + X' sin β) cos α
VC    = OV-OC

If A is in the view plane, the desired projection co-ordinates are (A'B',A"C) . If not, these values have to be modified by VP/VC. If VC is negative, or AC/VC is greater than 106, the point is 'behind' the view point. A line which passes behind the view point must be clipped in 3 dimensions to prevent any image cross-over.

The relative signs of PC and PV vectors indicate which side of the view plane A is on.

4. 3-D ROTATION ALGORITHM

The axis (X1,Y1,Z1) to (X2,Y2,Z2) may also be defined as an axis through (X1,Y1,Z1) with direction cosines (A,B,C), where:

 A = (X2-X1)/R,  B = (Y2-Y1)/R,  C = (Z2-Z1)/R 
 R = SQRT((X2-X1)2 + (Y2-Y1)2 +  (Z2-Z1)2)

The following three matrices translate the point (Xl,Y1,Z1) to the origin and move the axis to coincide with the Z-axis:

     -                          -
T =  |   1      0      0      0  |
     |   0      1      0      0  |
     |   0      0      1      0  |
     | -X1    -Y1    -Z1      1  |
     -                           -
                                           V= SQRT(B2+C2)
     -                          -
R1=  |   1      0      0      0  |
     |   0    C/V    B/V      0  |
     |   0   -B/V    C/V      0  |
     |   0      0      0      1  |
     -                           -
     -                          -
R2=  |   V      0      A      0  |
     |   0      1      0      0  |
     |  -A      0      V      0  |
     |   0      0      0      1  |
     -                           -
using the homogenous transformation equation
   (x', y', z', 1) = (x,y,z,1)M
where M is the transformation matrix.
   
Rotation about this axis through angle TH is given by:
     -                          -
RTH= | COS(TH)  -SIN(TH)  0   0  |
     | SIN(TH)   COS(TH)  0   0  |
     |   0      0      1      0  |
     |   0      0      0      1  |
     -                           -
To perform the required rotation, M is calculated as the matrix product:
M = R.T1.R2.RTH.R2
            -1.T-1
the inverse matrices being required to return the axis to its original position. 

5. AN INTEGRATED 3-D SYSTEM

The following scheme would produce a fully integrated 3-D system, but would cause an extra overhead for al1 2-D use.

(a) Define a 3-D region, whose parameters would be the arguments of ZVIEW and ZVIS.

(b) Define all plotting and drawing routines as display routines, and express the current basic set (SETXY,TODXY etc) in terms of the 3-D routines.

(c) If the current region is 3-D, use 3-D rotation and expansion.

(d) Use the current Z value if a 3-D region is met in the middle of a 2-D chain.

(e) Send all three co-ordinates to a device if a 3-D basic region is defined.

⇑ Top of page
© Chilton Computing and UKRI Science and Technology Facilities Council webmaster@chilton-computing.org.uk
Our thanks to UKRI Science and Technology Facilities Council for hosting this site