hp41programs

geom Geometric Transformations for the HP-41
 

Overview
 

-These programs deal with the most usual geometric transformations Tf, essentially projections, symmetries, rotations ( and a few similarities ).
-In the first 4 paragraphs, we compute the coordinates of M' = Tf(M) assuming the coordinates of M ( and Tf itself ) are known:
 

  1°)  Orthogonal Projection and Symmetry ( Reflexion )

    a)  2-dimensional spaces:   Orthogonal Projection and Symmetry / Line
    b)  3-dimensional spaces
       1- Orthogonal Projection and Symmetry / Plane
       2- Orthogonal Projection / Line
    c)  n-dimensional spaces
       1- Orthogonal Projection and Symmetry / Hyperplane
       2- Orthogonal Projection and Symmetry / Line

  2°) Projection and Symmetry

    a)  2-dimensional spaces:   Projection and Symmetry / Line // Vector
    b)  3-dimensional spaces
       1- Projection and Symmetry / Plane // Vector
       2- Projection / Line // Vectorial Plane
    c)  n-dimensional spaces
       1- Projection and Symmetry / Hyperplane // Vector
       2- Projection and Symmetry / Line // Vectorial Hyperplane

  3°)  Rotations

    a)  2-dimensional spaces
    b)  3-dimensional spaces
    c)  n-dimensional spaces

  4°)  Similarity ( Only 3 examples )

    a)  2-dimensional spaces
    b)  3-dimensional spaces
    c)  n-dimensional spaces

-The other programs deal with the link between Matrices and Transformations.

  5°)  Transformation >>>> Matrix

    a)  2-dimensional spaces
    b)  3-dimensional spaces
    c)  n-dimensional spaces

  6°)  Product ( Composition ) of 2 Transformations

  7°)  Reciprocal of a Transformation

  8°)  A Few Tests ( up to 17x18 Matrices )

    a)  Projection ? Symmetry ?
    b)  Isometry ?
    c)  Similarity ?

  9°)  Matrix >>>> Transformation

    a)  2-dimensional spaces
    b)  3-dimensional spaces
    c)  n-dimensional spaces  ( One example only )
 

Remarks:

-Some of these programs use synthetic registers  M  N  O  P  Q  a  ( do not confuse O and Q in the listings )
-Don't stop a running program if registers P and Q are used ( it could alter their contents - without any "crash" however )
-When register "a" is used, the program must not be called as more than a first level subroutine ( however, an alternative is suggested in this case )
-If you're not familiar to synthetic programming, these 6 registers may be replaced by any unused standard registers,
 ( for example:  R39  R40  R41  R42  R43  R44 which are unused in all the following examples )

-The basis is assumed to be orthonormal.
-In the "rotation" programs, the basis must be direct orthonormal,
 and the sign of the rotation angle is determined by the right-hand rule.
 
 

1°) Orthogonal Projection and Symmetry
 

        a-1) 2-Dimensional Space  ( Program#1 )

                       M(x;y)
                        |
                        |
      ------------|M'(x';y')-----------------   ( L ) : y = mx + p
                        |
                        |
                       M"(x";y")

-Given   m , p and  M(x,y) , the following program computes  M'(x',y') and M"(x",y")   where  ( MM' ) is perpendicular to ( L ) and  M' is the midpoint of [MM"]
 
 

Data Registers: /
Flags: /
Subroutines: /
 
 

01  LBL "OPS2A"
02  STO M
03  RDN
04  STO N
05  RDN
06  ST- T
07  RDN
08  ST* Z
09  RDN              
10  +
11  R^
12  X^2
13  SIGN
14  ST+ L
15  X<> L
16  /
17  STO Z            
18  R^
19  *
20  +
21  ENTER^
22  ST+ Y
23  X<> N           
24  -
25  R^
26  ST+ X
27  RCL M
28  -
29  RCL N            
30  R^
31  CLA
32  END
 

 
  ( 54 bytes / SIZE 000 )
 
 

      STACK        INPUTS      OUTPUTS
           T             m             y"
           Z             p             x"
           Y             y             y'
           X             x             x'
           L             /             x

Example:    Line (L) is defined by   y = 3x - 7  and  M(1;2)  ; find M' and M"
 

  3  ENTER^
 -7  ENTER^
  2  ENTER^
  1  XEQ "OPS2A"   >>>>   RDN  2.8  RDN  1.4  RDN  4.6  RDN  0.8    whence   M'(2.8;1.4)  and  M"(4.6;0.8)

Note:

-If (L) // (Oy) , the program doesn't work but you can use "OPS2"  below
-In this case however, the formulas are trivial.
 

        a-2) 2-Dimensional Space  ( Program#2 )
 

                       M(x;y)
                        |
                        |
      ------------|M'(x';y')-----------------   ( L ) :  ax + by = c
                        |
                        |
                       M"(x";y")

Data Registers:     • R00 = c        • R01 = a    • R02 = b  ( these 3 registers are to be initialized before executing "PS2" )
Flags: F01    CF01 = projection
                      SF01 = reflexion
Subroutines: /
 
 

01  LBL "OPS2"
02  STO Z
03  RCL 01
04  *
05  X<>Y
06  RCL 02
07  X<>Y
08  ST* Y
09  RDN
10  +
11  RCL 00       
12  X<>Y
13  -
14  FS? 01
15  ST+ X
16  RCL 01       
17  X^2
18  SIGN
19  CLX
20  RCL 02
21  ST* X
22  ST+ L
23  X<> L
24  /
25  RCL 02       
26  X<>Y
27  *
28  ST+ Z
29  X<> L
30  RCL 01       
31  *
32  X<>Y
33  +
34  END

 
  ( 52 bytes / SIZE 003 )
 
 

      STACK        INPUTS      OUTPUTS
           Y             y        y' or y"
           X             x        x' or x"
           L             /            x

  (x';y')   if Flag F01 is clear
  (x";y")  if Flag F01 is set

Example:    (L): 3x + 4y = 9     M(1;2)    Find  M' and M"

   9  STO 00    3  STO 01    4  STO 02

  CF 01   2  ENTER^   1   XEQ "OPS2"  >>>>   0.76   X<>Y   1.68    whence   M'(0.76;1.68)
  SF 01    2  ENTER^   1        R/S            >>>>   0.52   X<>Y   1.36    whence   M"(0.52;1.36)
 

        b) 3-Dimensional Space

         b-1) Orthogonal Projection ( and Symmetry ) onto ( with respect to ) a Plane.

                                   M(x;y;z)
                                    |
                                    |
                  /  ----------|----------------------------- /
                /                   | M'(x';y';z')                          /
              /                                                               /
            /-P----------------------------------------/       The plane (P) is defined by its equation  ax + by + cz = d
                                    |                                                ( MM' ) is perpendicular to ( P ) and  M' is the midpoint of [MM"]    ( M' belongs to (P) )
                                    |
                                   M"(x";y";z")
 

Data Registers:     • R00 = d        • R01 = a    • R02 = b   •  R03 = c   ( these registers are to be initialized before executing "OPS3" )
Flags: F01    CF01 for the projection
                      SF01 for the reflexion
Subroutines: /
 
 

01  LBL "OPS3"
02  STO M
03  RCL 01
04  *
05  X<>Y
06  STO N
07  RCL 02
08  *
09  +
10  X<>Y
11  STO O
12  RCL 03
13  *
14  +
15  RCL 00      
16  X<>Y
17  -
18  FS? 01
19  ST+ X
20  RCL 01
21  X^2
22  RCL 02      
23  X^2
24  RCL 03
25  X^2
26  +
27  +
28  /
29  RCL 03
30  RCL 02
31  RCL 01      
32  R^
33  ST* Z
34  ST* T
35  *
36  RCL O
37  ST+ T
38  X<> N
39  ST+ Z
40  X<> M      
41  +
42  CLA
43  END

 
  ( 64 bytes / SIZE 004 )
 
 

      STACK        INPUTS      OUTPUTS
           Z             z        z' or z"
           Y             y        y' or y"
           X             x        x' or x"
           L             /            x

  (x';y';z')   if Flag F01 is clear
  (x";y";z")  if Flag F01 is set

Example:    (P): 3x + 4y + 5z = 1    M(2;6;7)   Find M' and M"

   1  STO 00    3  STO 01   4  STO 02   5  STO 03

       CF 01
   7  ENTER^
   6  ENTER^
   2  XEQ "OPS3"  >>>>   -1.84   RDN  0.88   RDN   0.6   whence  M'(-1.84;0.88;0.6)

       SF 01
   7  ENTER^
   6  ENTER^
   2     R/S             >>>>   -5.68   RDN   -4.24   RDN   -5.8    whence  M"(-5.68;-4.24;-5.8)
 

         b-2) Orthogonal Projection onto a Line.
 

-Line (L) is now defined by one of its points, say  A(xA;yA;zA)  and one vector  U(a;b:c)

                                      M(x;y;z)
                                       |
            A                        |
       ----|------->U -------|------------ (L)                  (MM') perpendicular to (L)
                                     M'(x';y';z')

Data Registers:      R00  unused                           ( registers R01 to R06 are to be initialized before executing "OPL3" )

                               • R01 =  xA      • R04 = a
                               • R02 =  yA      • R05 = b
                               • R03 =  zA      • R06 = c
Flags: /
Subroutines: /
 
 

01  LBL "OPL3"
02  RCL 01
03  -
04  RCL 04
05  *
06  X<>Y
07  RCL 02
08  -
09  RCL 05
10  *
11  +
12  X<>Y
13  RCL 03      
14  -
15  RCL 06
16  *
17  +
18  RCL 04
19  X^2
20  RCL 05
21  X^2
22  RCL 06      
23  X^2
24  +
25  +
26  /
27  RCL 03
28  RCL 06
29  RCL Z
30  *
31  +
32  RCL 05      
33  R^
34  *
35  RCL 02
36  +
37  RCL 04
38  R^
39  *
40  RCL 01      
41  +
42  END
 

 
   ( 52 bytes / SIZE 007 )
 
 

      STACK        INPUTS      OUTPUTS
           Z             z            z'
           Y             y            y'
           X             x            x'

Example:    A(2;3;7)   U(3;4;5)      Find M' if M(9;4;1)

    2  STO 01     3  STO 04
    3  STO 02     4  STO 05
    7  STO 03     5  STO 06

    1  ENTER^
    4  ENTER^
    9  XEQ "OPL3"  >>>>   1.7   RDN   2.6   RDN   6.5    Thus,  M'(1.7;2.6;6.5)
 

Note:   The axial symmetry is equivalent to a rotation by 180° around the (L) axis  ( cf 3°) b) below )
 

        c) n-Dimensional Space

         c-1) Orthogonal Projection ( and Symmetry ) onto ( with respect to ) an Hyperplane.

                                  M(x1;...;xn)
                                    |
                                    |
                  /  ----------|------------------------------/
                /                   | M'(x'1;...;x'n)                      /
              /                                                               /
            /-H ---------------------------------------/       The hyperplane (H) is defined by its equation    a1x1 + ......... +  anxn = b
                                    |                                                ( MM' ) is perpendicular to ( P ) and  M' is the midpoint of [MM"]    ( M' belongs to (P) )
                                    |
                                  M"(x"1;...;x"n)
 
 
 

Data Registers:    • R00 = b                        ( Registers R00 thru Rnn and Rdd thru Rff  are to be initialized before executing "OPSN" )

                               • R01 = a1      • R02 = a2  ..................  • Rnn = an
                               • Rbb = x1      • Rbb+1 = x2   ............   • Ree  = xn                                            (  ee - bb = ee' - bb' = n-1 )

                and when the program stops:      Rbb' = x'1   ;    Rbb'+1 = x'2   ;............;    Ree'  = x'n      ( These 2 blocks of registers can't overlap )

Flags: F01          CF 01 means projection
                            SF 01 means reflexion.
Subroutines: /
 
 

01  LBL "OPSN"
02  STO N
03  X<>Y
04  STO M
05  INT
06  CHS
07  LASTX
08  FRC
09   E3
10  *
11  +
12  1
13  +
14  STO O
15  CLX
16  STO P
17  LASTX
18  RCL 00
19  LBL 01
20  RCL IND Y
21  X^2
22  ST+ P
23  X<> L
24  RCL IND M
25  *
26  -
27  ISG Y
28  CLX
29  ISG M
30  GTO 01
31  FS? 01
32  ST+ X
33  RCL P
34  /
35  RCL O
36  ST- M
37  SIGN
38  LBL 02
39  RCL IND X
40  RCL Z
41  *
42  RCL IND M
43  +
44  STO IND N
45  CLX
46  SIGN
47  ST+ N
48  +
49  ISG M
50  GTO 02
51  RCL M
52  RCL N
53  ENTER^
54  DSE X
55   E3
56  /
57  +
58  RCL O       
59  ST- Z
60  -
61  CLA
62  END

 
   ( 101 bytes )
 
 

      STACK        INPUTS      OUTPUTS
           Y       bbb.eee(M)       bbb.eee(M)
           X           bbb'       bbb.eee(M')
           L             /            n

Example:    (H):  x + 2y + 3z + 6t = 10      Find the coordinates of M' and M"   if  M(4;7;1;9)

   10  STO 00
    1   STO 01   2  STO 02   3  STO 03   6  STO 04

 and if we choose registers R05 thru R08 for M ,    4  STO 05  7  STO 06  1  STO 07  9  STO 08   ( control number = 5.008 )
-If we want to get M' in registers R09 thru R12 and M" in R13 thru R16

   CF 01
   5.008  ENTER^
      9      XEQ "OPSN"  yields ( in 5 seconds )   9.012

              RCL 09  >>>>  2.7
              RCL 10  >>>>  4.4
              RCL 11  >>>> -2.9
              RCL 12  >>>>  1.2     whence   M'(2.7;4.4;-2.9;1.2)

-Likewise,  SF 01    5.008  ENTER^
                                  13        R/S        gives   13.016   and  we recall registers  R13 thru R16 to get   M"(1.4;1.8;-6.8;-6.6)
 

         c-2) Orthogonal Projection ( and Symmetry ) onto ( with respect to ) a Line.
 

-Line (L) is determined by one of its points  A(a1;a2;.....;an)   and one vector   U(u1;u2;....;un)

                                      M(x1;...;xn)
                                       |
                                       |
            A                        |
       ----|------->U -------|-M'(x'1;...;x'n)----------------------------- (L)                 (MM") perpendicular to (L) ;   MM' = M'M"
                                       |
                                       |
                                       |
                                     M"(x"1;...;x"n)

Data Registers:      R00 unused                        ( Registers R01 thru R2n and Rbb thru Ree  are to be initialized before executing "OPSLN" )

                               • R01 = a1      • R02 = a2  ..................  • Rnn = an
                               • Rn+1 = u1    • Rn+2 = u2  ................  • R2n = un
                               • Rbb = x1      • Rbb+1 = x2   ............   • Ree  = xn

                and when the program stops:      Rbb' = x'1   ;    Rbb'+1 = x'2   ;............;    Ree'  = x'n      ( These last 2 blocks of registers can't overlap )

Flags: F01          CF 01 = projection
                            SF 01 = reflexion.
Subroutines: /
 
 

01  LBL "OPSLN"
02  STO N
03  X<>Y
04  STO M
05  INT
06  CHS
07  LASTX
08  FRC
09   E3
10  *
11  +
12  1
13  +
14  STO O
15  LASTX
16  +
17  STO P
18  LASTX
19  ENTER^
20  CLX
21  STO Q
22  LBL 01
23  RCL IND M  
24  RCL IND Z
25  -
26  RCL IND P
27  X^2
28  ST+ Q
29  X<> L
30  *
31  +
32  ISG Y
33  CLX
34  ISG P
35  CLX
36  ISG M
37  GTO 01
38  RCL Q
39  /
40  RCL O
41  ST- P
42  PI
43  INT
44  10^X
45  /
46  ISG X
47  LBL 02
48  RCL IND P  
49  RCL Z
50  *
51  RCL IND Y
52  +
53  STO IND N
54  CLX
55  SIGN
56  ST+ N
57  ST+ P
58  RDN
59  ISG X
60  GTO 02
61  FC? 01
62  GTO 04
63  RCL O
64  ST- M
65  ST- N
66  LBL 03
67  RCL IND N  
68  ST+ X
69  RCL IND M
70  -
71  STO IND N
72  ISG N
73  CLX
74  ISG M
75  GTO 03
76  LBL 04
77  RCL M
78  RCL N
79  ENTER^
80  DSE X
81   E3
82  /
83  +
84  RCL O           
85  ST- Z
86  -
87  CLA
88  END

 
  ( 143 bytes )
 
 

      STACK        INPUTS      OUTPUTS
           Y       bbb.eee(M)       bbb.eee(M)
           X           bbb'       bbb.eee(M')
           L             /             n

Example:     A(2;4;7;8)  U(1;2;3;6)    M(4;7;1;9)   Find M' and M"

   2  STO 01     1  STO 05       and, for instance,      4  STO 09
   4  STO 02     2  STO 06                                       7  STO 10
   7  STO 03     3  STO 07                                       1  STO 11
   8  STO 04     6  STO 08                                       9  STO 12        ( control number = 9.012 )

   CF 01   9.012  ENTER^
                   13    XEQ "OPSLN"   >>>>   13.016  ( in 5 seconds )   and recalling registers R13 to R16, we get:   M'(1.92;3.84;6.76;7.52)

   SF 01   9.012  ENTER^
                   13      R/S                   >>>>    13.016  ( in 7 seconds )  and recalling registers R13 to R16, we get:    M"(-0.16;0.68;12.52;6.04)
 
 

2°) Projection and Symmetry
 

        a) 2-Dimensional Space
 

-The direction of projection and symmetry is now determined by a vector V(a';b')

                  M(x;y)           V
                    \                     \
                      \                     \
      ------------\ M'(x';y')-----------------   ( L ) : ax + by = c              (MM') //  V  and  MM' = M'M"
                          \
                            \
                            M"(x";y")

Data Registers:     • R00 = c        • R01 = a    • R02 = b
                                                       • R03 = a'    • R04 = b'    ( these 5 registers are to be initialized before executing "PS2" )
Flags: F01    CF01 = projection
                      SF01 = symmetry
Subroutines: /
 
 

01  LBL "PS2"
02  STO M
03  RCL 01
04  *
05  X<>Y
06  STO N
07  RCL 02
08  *
09  +
10  RCL 00    
11  X<>Y
12  -
13  FS? 01
14  ST+ X
15  RCL 01
16  RCL 03
17  *
18  RCL 02    
19  RCL 04
20  *
21  +
22  /
23  RCL 04
24  RCL 03     
25  RCL Z
26  ST* Z
27  *
28  RCL N
29  ST+ Z
30  X<> M     
31  +
32  CLA
33  END

 
  ( 50 bytes / SIZE 005 )
 
 

      STACK        INPUTS      OUTPUTS
           Y             y        y' or y"
           X             x        x' or x"
           L             /            x

  (x';y')   if Flag F01 is clear
  (x";y")  if Flag F01 is set

Example:    (L): 2x + 3y = 7  ; V(4;-3)  ;  M(1;2)   Find M' and M"

   7  STO 00   2  STO 01    3  STO 02
                      4  STO 03   -3  STO 04

        CF 01
    2  ENTER^
    1  XEQ "PS2"  >>>>  5  X<>Y  -1   whence  M'(5;-1)

        SF 01
    2  ENTER^
    1     R/S           >>>>  9  X<>Y  -4  whence  M"(9;-4)
 

        b) 3-Dimensional Space

         b-1) Projection ( and Symmetry ) onto ( with respect to ) a Plane.

-The direction of the projection is determined by a vector V(a';b';c')

                           M(x;y;z)        V
                             \                    \
                               \                    \
                  /  --------\------------------------------- /
                /                  \  M'(x';y';z')                          /
              /                                                               /
            /-P----------------------------------------/       The plane (P) is defined by its equation  ax + by + cz = d
                                         \                                           ( MM' ) //  V  and  MM' = M'M"    ( M' belongs to (P) )
                                           \
                                          M"(x";y";z")
 

Data Registers:     • R00 = d        • R01 = a    • R02 = b   •  R03 = c
                                                       • R04 = a'    • R05 = b'  •  R06 = c'    ( these 7 registers are to be initialized before executing "PS3" )
Flags: F01    CF01 for the projection
                      SF01 for the symmetry
Subroutines: /
 
 

01  LBL "PS3"
02  STO M    
03  RCL 01
04  *
05  X<>Y
06  STO N
07  RCL 02
08  *
09  +
10  X<>Y
11  STO O
12  RCL 03
13  *
14  +
15  RCL 00     
16  X<>Y
17  -
18  FS? 01
19  ST+ X
20  RCL 01
21  RCL 04
22  *
23  RCL 02
24  RCL 05     
25  *
26  +
27  RCL 03
28  RCL 06
29  *
30  +
31  /
32  RCL 06
33  RCL 05
34  RCL 04     
35  R^
36  ST* T
37  ST* Z
38  *
39  RCL O
40  ST+ T
41  X<> N     
42  ST+ Z
43  X<> M
44  +
45  CLA
46  END

 
  ( 66 bytes / SIZE 007 )
 
 

      STACK        INPUTS      OUTPUTS
           Z             z        z' or z"
           Y             y        y' or y"
           X             x        x' or x"
           L             /            x

  (x';y';z')   if Flag F01 is clear
  (x";y";z")  if Flag F01 is set

Example:    (P): 2x + 3y + 7z = 4   ;   V(6;1;-2)    M(1;4;5)    Find M' and M"

   4  STO 00    2  STO 01   3  STO 02   7  STO 03
                       6  STO 04   1  STO 05  -2  STO 06

       CF 01
   5  ENTER^
   4  ENTER^
   1  XEQ "PS3"  >>>>   -269   RDN  -41   RDN   95   whence  M'(-269;-41;95)

       SF 01
   5  ENTER^
   4  ENTER^
   1     R/S             >>>>   -539   RDN   -86   RDN   185    whence  M"(-539;-86;185)
 

    b-2) Projection ( and Symmetry ) onto ( with respect to ) a Line.
 

-Line (L) is defined by one of its points  A(xA;yA;zA)  and a vector  U(a;b;c)
-The direction of projection is determined by a ( vectorial ) plane (P): a'x + b'y + c'z = 0

                                               A(xA;yA;zA)
                                                   \
                                                     \   U
                                                       \
                     M(x;y;z)-----------M'(x';y';z')---------M"(x";y";z")
                                                           \
                            /---------------------\--------------------/
                          /                                   \                           /
                        /                                                               /
                      /-P----------------------------------------/                     ( MM' ) //  (P)  and  MM' = M'M"
                                                                   \
                                                                     \ (L)

Data Registers:    R00 unused      • R01 = xA   • R02 = yA •  R03 = zA
                                                       • R04 = a       • R05 = b   •  R06 = c
                                                       • R07 = a'      • R08 = b'  •  R09 = c'    ( these 9 registers are to be initialized before executing "PS3" )
Flags: F01    CF01 = projection
                      SF01 = symmetry
Subroutines: /
 
 

01  LBL "PS3L"
02  STO M
03  RCL 01
04  -
05  RCL 07
06  *
07  X<>Y
08  STO N
09  RCL 02
10  -
11  RCL 08
12  *
13  +
14  X<>Y
15  STO O       
16  RCL 03
17  -
18  RCL 09
19  *
20  +
21  RCL 04
22  RCL 07
23  *
24  RCL 05
25  RCL 08
26  *
27  +
28  RCL 06
29  RCL 09       
30  *
31  +
32  /
33  RCL 03
34  RCL 06
35  RCL Z
36  *
37  +
38  RCL 05
39  R^
40  *
41  RCL 02
42  +
43  RCL 04       
44  R^
45  *
46  RCL 01
47  +
48  FC? 01
49  GTO 01
50  2
51  ST* T
52  ST* Z
53  *
54  RCL O       
55  ST- T
56  X<> N
57  ST- Z
58  X<> M
59  -
60  LBL 01
61  CLA
62  END

 
   ( 84 bytes / SIZE 010 )
 
 

      STACK        INPUTS      OUTPUTS
           Z             z        z' or z"
           Y             y        y' or y"
           X             x        x' or x"

  (x';y';z')   if Flag F01 is clear
  (x";y";z")  if Flag F01 is set

Example:    A(4;6;-1)  U(2;3;7)    (P): 6x + y - 2z = 0   ;    M(1;4;2)    Find M' and M"

    4  STO 01   6  STO 02   -1  STO 03
    2  STO 04   3  STO 05    7  STO 06
    6  STO 07   1  STO 08   -2  STO 09

       CF 01
   2  ENTER^
   4  ENTER^
   1  XEQ "PS3L"  >>>>   -48   RDN  -72   RDN   -183   whence  M'(-48;-72;-183)

       SF 01
   2  ENTER^
   4  ENTER^
   1     R/S             >>>>   -97   RDN   -148   RDN   -368    whence  M"(-97;-148;-368)
 

        c) n-Dimensional Space
 

        c-1) Projection ( and Symmetry ) onto ( with respect to ) an Hyperplane.
 

-The direction of projection is defined by a vector  V(v1;v2;....;vn)

                            M(x1;...;xn)      V
                               \                       \
                                 \                       \
                  /  ---------\-------------------------------/
                /                   \ M'(x'1;...;x'n)                      /
              /                                                               /
            /-H ---------------------------------------/           The hyperplane (H) is defined by its equation    a1x1 + ......... +  anxn = b
                                         \                                               ( MM' ) // V  and  M' is the midpoint of [MM"]    ( M' belongs to (P) )
                                           \
                                          M"(x"1;...;x"n)
 
 
 

Data Registers:    • R00 = b                        ( Registers R00 thru R2n and Rdd thru Rff  are to be initialized before executing "PSN" )

                               • R01 = a1      • R02 = a2  ..................  • Rnn = an
                               • Rn+1 = v1    • Rn+2 = v2  ................  • R2n = vn
                               • Rbb = x1      • Rbb+1 = x2   ............   • Ree  = xn                                            (  ee - bb = ee' - bb' = n-1 )

                and when the program stops:      Rbb' = x'1   ;    Rbb'+1 = x'2   ;............;    Ree'  = x'n      ( These 2 blocks of registers can't overlap )

Flags: F01          CF 01 = projection
                            SF 01 = symmetry.
Subroutines: /
 
 

01  LBL "PSN"   
02  STO N
03  X<>Y
04  STO M
05  INT
06  CHS
07  LASTX
08  FRC
09   E3
10  *
11  +
12  1
13  +
14  STO O
15  ST+ O
16  0
17  LBL 01
18  RCL IND Y
19  RCL IND O
20  *
21  +
22  DSE O
23  DSE Y
24  GTO 01
25  STO P 
26  CLX
27  SIGN
28  RCL 00
29  LBL 02
30  RCL IND Y
31  RCL IND M
32  *
33  -
34  ISG Y
35  CLX
36  ISG M
37  GTO 02
38  FS? 01
39  ST+ X
40  RCL P
41  /
42  RCL O
43  ST- M
44  ISG X
45  LBL 03
46  RCL IND X
47  RCL Z
48  *
49  RCL IND M
50  +
51  STO IND N
52  CLX
53  SIGN
54  ST+ N
55  +
56  ISG M
57  GTO 03       
58  RCL M
59  RCL N
60  ENTER^
61  DSE X
62   E3
63  /
64  +
65  RCL O
66  ST- Z
67  -
68  CLA
69  END

 
   ( 112 bytes )
 
 

      STACK        INPUTS      OUTPUTS
           Y       bbb.eee(M)       bbb.eee(M)
           X           bbb'       bbb.eee(M')
           L             /             n

 
Example:    (H):  x + 2y + 3z + 6t = 10  and  V(2;4;7;-5)    Find the coordinates of M' and M"   if  M(4;7;1;9)

  10  STO 00   1  STO 01            2  STO 05         and, for instance:       4  STO 09
                       2  STO 02            4  STO 06                                          7  STO 10
                       3  STO 03            7  STO 07                                          1  STO 11
                      6  STO 04           -5  STO 08                                          9  STO 12        ( control number = 9.012 )

   CF 01   9.012  ENTER^
                   14    XEQ "PSN"  >>>>  14.017   and we recall registers  R14 thru R17 to get   M'(-126;-253;-454;334)

   SF 01   9.012  ENTER^
                   14      R/S             >>>>  14.017   and we recall registers  R14 thru R17 to get   M"(-256;-513;-909;659)
 

         c-2) Projection ( and Symmetry ) onto ( with respect to ) a Line.
 

-Line (L) passes through  A(a1;a2;.....;an)   and is parallel to a vector   U(u1;u2;....;un)
-The direction of projection is given by a ( vectorial ) hyperplane (H):   a'1x1 + ......... +  a'nxn = 0

                                              A(a1;a2;.....;an)
                                                   \
                                                     \
                                                       \
                  M(x1;...;xn)-----------M'(x'1;...;x'n)---------M"(x"1;...;x"n)
                                                           \
                            /---------------------\--------------------/
                          /                                   \                           /
                        /                                                               /
                      /-H----------------------------------------/                     ( MM' ) //  (H)  and  MM' = M'M"
                                                                   \
                                                                     \ (L)
 

Data Registers:      R00 unused                        ( Registers R01 thru R3n and Rbb thru Ree  are to be initialized before executing "PSLN" )

                               • R01 = a1      • R02 = a2  ..................  • Rnn = an
                               • Rn+1 = u1    • Rn+2 = u2  ................  • R2n = un
                               • R2n+1 = a'1 • R2n+2 = a'2  .............  • R3n = a'n
                               • Rbb = x1      • Rbb+1 = x2   ............   • Ree  = xn

                and when the program stops:      Rbb' = x'1   ;    Rbb'+1 = x'2   ;............;    Ree'  = x'n      ( These last 2 blocks of registers can't overlap )

Flags: F01          CF 01 = projection
                           SF 01 = symmetry.
Subroutines: /
 
 

  01  LBL "PSLN"
  02  STO N
  03  X<>Y
  04  STO M
  05  INT
  06  CHS
  07  LASTX
  08  FRC
  09   E3
  10  *
  11  +
  12  1
  13  +
  14  ENTER^
  15  STO O
  16  ST+ X
  17  ST+ Y
  18  .1
  19  %
  20  ST+ Z
  21  CLX
  22  STO Q
  23  RDN
  24  LBL 01
  25  RCL IND Y
  26  RCL IND Y
  27  *
  28  ST+ Q
  29  CLX
  30  SIGN
  31  -
  32  DSE Y
  33  GTO 01
  34  ST+ X
  35  STO P
  36  SIGN
  37  ST+ P
  38  ENTER^
  39  CLX
  40  LBL 02
  41  RCL IND M
  42  RCL IND Z
  43  -
  44  RCL IND P
  45  *
  46  +
  47  ISG Y
  48  CLX
  49  ISG P
  50  CLX
  51  ISG M
  52  GTO 02
  53  RCL Q
  54  /
  55  RCL O
  56  ST- P
  57  ST- P
  58  PI
  59  INT
  60  10^X
  61  /
  62  ISG X
  63  LBL 03
  64  RCL IND P
  65  RCL Z
  66  *
  67  RCL IND Y
  68  +
  69  STO IND N
  70  CLX
  71  SIGN
  72  ST+ N
  73  ST+ P
  74  RDN
  75  ISG X
  76  GTO 03
  77  FC? 01
  78  GTO 05
  79  RCL O
  80  ST- M
  81  ST- N
  82  LBL 04
  83  RCL IND N
  84  ST+ X
  85  RCL IND M
  86  -
  87  STO IND N
  88  ISG N
  89  CLX
  90  ISG M
  91  GTO 04
  92  LBL 05
  93  RCL M
  94  RCL N
  95  ENTER^
  96  DSE X
  97   E3
  98  /
  99  +
100  RCL O
101  ST- Z
102  -
103  CLA
104  END

 
   ( 168 bytes )
 
 

      STACK        INPUTS      OUTPUTS
           Y       bbb.eee(M)       bbb.eee(M)
           X           bbb'       bbb.eee(M')
           L             /             n

Example:      A(2;8;1;3)  ;  U(2;4;7;-5)  and  (H):  x + 2y + 3z + 6t = 0      Find the coordinates of M' and M"   if  M(4;7;1;9)

          2  STO 01            2  STO 05         1  STO 09             4  STO 13
          8  STO 02            4  STO 06         2  STO 10             7  STO 14
          1  STO 03            7  STO 07         3  STO 11             1  STO 15
          3  STO 04           -5  STO 08         6  STO 12             9  STO 16        ( control number = 13.016 )

   CF 01   13.016  ENTER^
                   17    XEQ "PSLN"  >>>>  17.020   and we recall registers  R17 thru R20 to get   M'(74;152;253;-177)

   SF 01   13.016  ENTER^
                   17        R/S             >>>>  17.020   and we recall registers  R17 thru R20 to get   M"(144;297;505;-363)
 

3°) Rotation
 

        a) 2-Dimensional Space
 

-Given  a point  A(xA;yA)  and an angle µ , "ROT2"  calculates  M'(x';y') if we know M(x;y)
-This program works in all angular modes.

                          M'(x';y')
                        /
                      /
                    /
                  /  µ
             A /-------------- M(x;y)              AM = AM'  and  ( AM;AM' ) = µ
 

Data Registers:     • R00 = µ        • R01 =  xA   • R02 = yA     ( these registers are to be initialized before executing "ROT2" )
Flags: /
Subroutines: /
 
 

01  LBL "ROT2"
02  RCL 01
03  -
04  RCL 00
05  RCL 02       
06  R^
07  -
08  P-R
09  RCL 00       
10  R^
11  P-R
12  X<> Z
13  -
14  RCL 02       
15  +
16  X<> Z
17  +
18  RCL 01       
19  +
20  END

 
  ( 31 bytes / SIZE 003 )
 
 

      STACK        INPUTS      OUTPUTS
           Y             y            y'
           X             x            x'

 
Example:    A(6;7)   µ = 21°   Find  M' if  M(4;3)

   21  STO 00   6  STO 01   7  STO 02   Set the HP-41 in DEG mode

   3  ENTER^
   4  XEQ "ROT2"  >>>>   5.566310945   X<>Y   2.548942395      whence    M'( 5.566310945 ; 2.548942395 )
 

        b) 3-Dimensional Space

-Given  M(x;y;z)  this program computes M'(x';y';z') = r(M)
  where  r is the rotation by an angle µ around an axis (L) passing through a point A(xA;yA;zA)  and parallel to a vector  U(a;b;c)
 
 

            U
                 |
                 | A
                 |
                 |
                 |    M'(x';y';z')                                     The vectors  NM and NM'  are both orthogonal to U  and lengths  NM and NM' are equal.
                 |                                                       The angle ( NM ; NM' ) = µ
                 |  /  µ
                 |/-------------- M(x;y;z)
                N

Data Registers:    • R00 = µ                                    ( registers R00 to R06 are to be initialized before executing "ROT3" )

                               • R01 =  xA      • R04 = a
                               • R02 =  yA      • R05 = b             R07 to R12: temp
                               • R03 =  zA      • R06 = c
Flags: /
Subroutine: "OPL3"  ( cf  1°) b-2) Orthogonal projection onto a line )
 
 

01  LBL "ROT3"
02  STO 07
03  RDN
04  STO 08
05  X<>Y
06  STO 09
07  X<>Y
08  R^
09  XEQ "OPL3"
10  STO 10
11  ST- 07
12  RDN
13  STO 11
14  ST- 08
15  X<>Y
16  STO 12
17  ST- 09
18  RCL 07
19  RCL 00
20  COS
21  *
22  ST+ 10
23  RCL 08
24  LASTX        
25  *
26  ST+ 11
27  RCL 09
28  LASTX
29  *
30  ST+ 12
31  RCL 00
32  SIN
33  RCL 04
34  X^2
35  RCL 05
36  X^2
37  RCL 06        
38  X^2
39  +
40  +
41  SQRT
42  /
43  RCL 05
44  RCL 09
45  *
46  RCL 06
47  RCL 08
48  *
49  -
50  *
51  ST+ 10
52  CLX
53  RCL 06        
54  RCL 07
55  *
56  RCL 04
57  RCL 09
58  *
59  -
60  *
61  ST+ 11
62  CLX
63  RCL 04
64  RCL 08
65  *
66  RCL 05        
67  RCL 07
68  *
69  -
70  *
71  RCL 12
72  +
73  RCL 11
74  RCL 10
75  END

 
  ( 97 bytes / SIZE 013 )
 
 

      STACK        INPUTS      OUTPUTS
           Z             z           z'
           Y             y           y'
           X             x           x'

Example:     µ = 24°    A(2;3;7)    U(4;6;9)     Find M' = r(M)   if  M(1;4;8)

  24  STO 00

    2  STO 01      4  STO 04
    3  STO 02      6  STO 05
    7  STO 03      9  STO 06         Set the HP-41 in DEG mode

     8  ENTER^
     4  ENTER^
     1  XEQ "ROT3"  >>>>  1.009250426   RDN   3.497956694   RDN   8.330584237

   whence   M'( 1.009250426 ; 3.497956694 ; 8.330584237 )
 

        c) n-Dimensional Space
 

-Though the word "rotation" has a more general meaning in n-dimensional spaces, "ROTN" computes  M' = r(M)
 where  r is the rotation by an angle µ in the plane (P) defined by a point A(a1;...;an) and 2 non-colinear vectors U(u1;...;un) , V(v1;...;vn)
 

                 |
                 |
                 |    M'(x'1;...;x'n)                                     The vectors  NM and NM'  are both parallel to the plane  (A;U;V)  and lengths  NM and NM' are equal.
                 |                                                           The angle ( NM ; NM' ) = µ
                 |  /  µ
                 |/-------------- M(x1;...;xn)
                N
                 |
                 |
                 |    M'1
                 |    /
                 |  /  µ                                                      M1 , M'1 are the orthogonal projections of  M , M' onto (P).
            A  |/-------------- M1                                 The vectors U , V , AM1 , AM'1 are in the plane (P)
               /   \                                                           The angle ( AM1 ; AM'1 ) = µ
             /       \ V
           / U
 

-The vertical dotted line actually symbolizes the (n-2) dimensional subspace (S) passing through A and orthogonal to (P).
-r may also be called a rotation by an angle µ "around" the subspace (S).
 

Data Registers:    • R00 = µ                        ( Registers R00 thru R3n and Rbb thru Ree  are to be initialized before executing "ROTN" )

                               • R01 = a1      • R02 = a2  ..................  • Rnn = an
                               • Rn+1 = u1    • Rn+2 = u2  ................  • R2n = un
                               • R2n+1 = v1  • R2n+2 = v2  ..............  • R3n = vn
                               • Rbb = x1      • Rbb+1 = x2   ............   • Ree  = xn

                and when the program stops:      Rbb' = x'1   ;    Rbb'+1 = x'2   ;............;    Ree'  = x'n      ( These last 2 blocks of registers can't overlap )

Flags: /
Subroutines: /
 
 

  01  LBL "ROTN"
  02  X<>Y
  03  STO M
  04  INT
  05  CHS
  06  LASTX
  07  FRC
  08   E3
  09  *
  10  +
  11  STO T
  12  +
  13   E3
  14  /
  15  +
  16  STO N
  17  SIGN
  18  +
  19  ENTER^
  20  ST+ X
  21  STO O
  22  .1
  23  %
  24  +
  25  +
  26  0
  27  STO P  
  28  LBL 01
  29  RCL IND O
  30  X^2
  31  ST+ P
  32  X<> L
  33  RCL IND Z
  34  *
  35  -
  36  DSE O
  37  DSE Y
  38  GTO 01
  39  RCL P
  40  ST/ Y
  41  CLX
  42  STO Q
  43  SIGN
  44  RCL O
  45  +
  46  STO O
  47  LASTX
  48  +
  49  LBL 02
  50  RCL IND O
  51  RCL Z
  52  *
  53  RCL IND Y
  54  +
  55  STO IND N
  56  X^2
  57  ST+ Q
  58  SIGN
  59  ST+ O
  60  +
  61  ISG N
  62  GTO 02
  63  DSE X
  64  PI
  65  INT
  66  /
  67  ST- N
  68  ST- O
  69  RCL N
  70  LASTX
  71  SIGN
  72  X<> Q
  73  SQRT
  74  LBL 03
  75  ST/ IND Y
  76  ISG Y
  77  GTO 03
  78  CLST
  79  LBL 04
  80  RCL IND M
  81  RCL IND Q
  82  -
  83  RCL IND O
  84  X<>Y
  85  *
  86  ST+ Y
  87  X<> L
  88  RCL IND N
  89  *
  90  ST+ Z
  91  CLX
  92  SIGN
  93  ST+ M
  94  ST+ O
  95  ST+ Q
  96  RDN
  97  ISG N
  98  GTO 04
  99  RCL P
100  SQRT
101  /
102  RCL Q       
103  DSE X
104  ST- M
105  ST- N
106  ST- O
107  CLX
108  RCL 00
109  X<>Y
110  P-R
111  LASTX
112  -
113  RCL 00
114  R^
115  P-R
116  ST- L
117  X<> L
118  ST- T
119  RDN
120  -
121  RCL P
122  SQRT
123  /
124  LBL 05
125  RCL IND O
126  RCL Y
127  *
128  RCL IND N
129  R^
130  ST* Y
131  RDN
132  +
133  RCL IND M
134  +
135  STO IND N
136  CLX
137  SIGN
138  ST+ M
139  ST+ O
140  RDN
141  ISG N
142  GTO 05
143  RCL M
144  RCL N
145  RCL O
146  DSE X
147  2
148  /
149  ST- Z
150  -
151  CLA
152  END

 
   ( 235 bytes )
 
 

      STACK        INPUTS      OUTPUTS
           Y       bbb.eee(M)       bbb.eee(M)
           X           bbb'       bbb.eee(M')
           L             /             n

Example:     µ = 24°    A(1;2;4;7;6)    U(3;1;4;2;5)   V(2;7;3;1;4)        Find M' = r(M)   if  M(4;6;1;2;3)

   24  STO 00

   1  STO 01             3  STO 06          2  STO 11                4  STO 16
   2  STO 02             1  STO 07          7  STO 12                6  STO 17
   4  STO 03             4  STO 08          3  STO 13                1  STO 18
   7  STO 04             2  STO 09          1  STO 14                2  STO 19
   6  STO 05             5  STO 10          4  STO 15                3  STO 20         ( control number = 16.020 )

  16.020  ENTER^
      21     XEQ "ROTN"   >>>>  ( in 15 seconds )  21.025   and we recall registers R21 to R25 to get:

   M'( 3.515304126 ; 4.098798832 ; 0.262179052 ; 1.768429201 ; 2.009053978 )
 

4°) Examples of a more complex Transformation:  Similarity
 

-A similarity preserves the ratios of distances:
 Tf is a similarity iff , for all points M , N      M'N' = k.MN  where  M' = Tf(M) ; N' = Tf(N) and k is a constant = ratio of magnification.
-In the 3 following examples, Tf is the product of an homothecy h ( homothetic center = the origin O  ;   M1 = h(M)  iff  OM1 = k.OM  ( vectorial identity )  )
  and an isometry Is:   Tf = hoIs
 

        a) 2-Dimensional Space
 

-Here,  k = 3 ( line 09 )
            Is = Rot            where R is the reflexion with respect to line (L): ax + by = c
                                          and t is the translation defined by vector U(a';b')              ( a translation consists of a constant offset )

Data Registers:     • R00 = c        • R01 = a    • R02 = b                       ( these 5 registers are to be initialized before executing "PS2" )
                                                       • R03 = a'    • R04 = b'
Flag: F01
Subroutine:  "OPS2"
 
 

 01  LBL "SIM2"
 02  SF 01
 03  XEQ "OPS2"
 04  RCL 04
 05  ST+ Z
 06  CLX
 07  RCL 03
 08  +
 09  3
 10  ST* Z
 11  *
 12  END

 
( 29 bytes / SIZE 005 )
 
 

      STACK        INPUTS      OUTPUTS
           Y             y            y'
           X             x            x'

Example:    (L): 3x + 4y = 9  U(4;-3)   Calculate  M'  if  M(6;1)

  9  STO 00   3  STO 01   4  STO 02   4  STO 03   -3  STO 04

  1  ENTER^
  6  XEQ "SIM2"   >>>>   20.64   RDN  -18.48    whence   M'(20.64;-18.48)
 

        b) 3-Dimensional Space
 

-Now,  Tf = hoIs  with  k = 2 ( line 11 ) , Is = rot
 where  r is the rotation by an angle µ around an axis (L) passing through a point A(xA;yA;zA)  and parallel to a vector  U(a;b;c)
 and t is the translation defined by the same vector U

Data Registers:    • R00 = µ                                    ( registers R00 to R06 are to be initialized before executing "ROT3" )

                               • R01 =  xA      • R04 = a
                               • R02 =  yA      • R05 = b             R07 to R12: temp
                               • R03 =  zA      • R06 = c
Flags: /
Subroutine:  "ROT3"
 
 

 01  LBL "SIM3"
 02  XEQ "ROT3"
 03  RCL 06
 04  ST+ T
 05  CLX
 06  RCL 05
 07  ST+ Z
 08  CLX
 09  RCL 04
 10  +
 11  2     
 12  ST* T
 13  ST* Z
 14  *
 15  END

 
( 33 bytes / SIZE 013 )
 
 

      STACK        INPUTS      OUTPUTS
           Z             z           z'
           Y             y           y'
           X             x           x'

Example:    µ = 49°   A(2,3,4)   U(2,4,8)      Compute  M'  if  M(1,4,7)

   49  STO 00

    2  STO 01      2  STO 04
    3  STO 02      4  STO 05
    4  STO 03      8  STO 06

   7  ENTER^
   4  ENTER^
   1  XEQ "SIM3"  >>>>   7.772478150   RDN   13.85810556   RDN   30.62782768    whence   M'( 7.772478150 ; 13.85810556 ; 30.62782768 )
 

        c) n-Dimensional Space
 

-The following program calculates  M'(x'1;...;x'n)  = Tf ( M(x1;...;xn)  )  where  Tf = hotoR  is the product ( composition ) of 3 transformations:

   h  is an homothecy  ( ratio = k ; homothetic center = the origin O )
   t  is a translation defined by a vector  V(v1;v2;....;vn)
  R  is the reflection with respect to an hyperplane  (H):  a1x1 + ......... +  anxn = b

Data Registers:    • R00 = b                        ( Registers R00 thru R2n+1  and  Rbb thru Ree  are to be initialized before executing "SIMN" )

                               • R01 = a1      • R02 = a2  ..................  • Rnn = an
                               • Rn+1 = v1    • Rn+2 = v2  ................  • R2n = vn    • R2n+1 = k
                               • Rbb = x1      • Rbb+1 = x2   ............   • Ree  = xn

                and when the program stops:      Rbb' = x'1   ;    Rbb'+1 = x'2   ;............;    Ree'  = x'n      ( These last 2 blocks of registers can't overlap )

Flag: F01
Subroutine: "OPSN"
 
 

 01  LBL "SIMN"
 02  SF 01
 03  XEQ "OPSN"
 04  LASTX
 05  ISG X
 06  CLX
 07  STO M
 08  LASTX
 09  +
 10  RDN
 11  RCL IND T
 12  STO T
 13  LBL 01
 14  CLX
 15  RCL IND M
 16  ST+ IND Y
 17  R^
 18  ST* IND Z
 19  RDN
 20  ISG M
 21  CLX
 22  ISG Y
 23  GTO 01
 24  X<> L
 25  -
 26  CLA
 27  END

 
   ( 53 bytes )
 
 

      STACK        INPUTS      OUTPUTS
           Y       bbb.eee(M)       bbb.eee(M)
           X           bbb'       bbb.eee(M')
           L             /            n

Example:    (H):  x + 2y + 3z + 6t = 10      V(2;5;2;-3)     k = 4     Find the coordinates of M'   if  M(4;7;1;9)

   10  STO 00

    1   STO 01   2  STO 02   3  STO 03   6  STO 04
    2   STO 05   5  STO 06   2  STO 07  -3  STO 08    4  STO 09

For instance,    4  STO 10   7  STO 11   1  STO 12   9  STO 13    ( control number = 10.013 )
and if we want to get M' in registers  R14 to R17:

   10.013  ENTER^
       14     XEQ "SIMN"   >>>>   14.017   ( in 6 seconds )   and recalling registers R14 to R17  we find:   M'( 13.6 ; 27.2 ; -19.2 ; -38.4 )

Note:

-If registers R2n+1 to R3n are already used by one of the transformations ( for instance: "ROTN" or "PSN" )
  you may wish to store k into register R3n+1 instead of R2n+1.
-In this case, simply add   LASTX  +   after line 09

-The last 3 programs are only 3 examples among numerous other geometric transformations ...
 

5°) Transformation >>>> Matrix
 

        a) 2-Dimensional Space
 

   M'(x';y')  may be calculated from M(x;y) by means of linear formulas:

     x' = ax + by + c
     y' = a'x + b'y + c'

-The following program computes and stores these 6 coefficients in registers R05 thru R10

Data Registers: Those used by the transformation itself which are to be initialized before executing "TM2"

                            and when the           R05 = a ; R07 = b ; R09 = c
                           program stops:       R06 = a' ; R08 = b' ; R10 = c'      ( R11: temp )

Flags: ?  ( for example: CF 01 for a projection , SF 01 for a reflexion ... )
Subroutines: The transformation itself
 
 

 01  LBL "TM2"
 02  ASTO 11
 03  CLST
 04  SIGN
 05  XEQ IND 11
 06  STO 05
 07  X<>Y
 08  STO 06
 09  CLST
 10  SIGN
 11  X<>Y
 12  XEQ IND 11
 13  STO 07
 14  X<>Y
 15  STO 08
 16  CLST
 17  XEQ IND 11
 18  STO 09
 19  ST- 05
 20  ST- 07
 21  X<>Y
 22  STO 10
 23  ST- 06
 24  ST- 08
 25  5.01002
 26  END

 
( 48 bytes / SIZE 012 )
 

Example:    Find the matrix of the projection onto line (L) 2x + 3y = 7 in the direction of the vector U(4;-3)

1°) We store the elements of the transformation into the proper registers:   7  STO 00   2  STO 01   3  STO 02   4  STO 03   -3  STO 04    CF 01 ( projection )
2°) We place the name of the corresponding program in the alpha register:  [alpha] "PS2" [alpha]
3°)  XEQ "TM2" >>>>  5.01002  = the control number of the matrix, and we get

           [ [   9      12    -28  ]          in registers      R05    R07   R09          respectively.     Thus:   x' = 9x + 12y -28   defines this projection.
             [  -6     -8      21   ] ]                              R06    R08   R10                                            y' = -6x -8y + 21

Note:   Do not use "OPS2A" which requires different inputs.
 

        b) 3-Dimensional Space
 

   M'(x';y';z')  may be calculated from M(x;y;z) by means of linear formulas:

     x' = ax + by + cz + d
     y' = a'x + b'y + c'z + d'
     z' = a"x + b"y + c"z + d"

-The following program computes and stores these 12 coefficients in registers R13 thru R24

Data Registers: Those used by the transformation itself which are to be initialized before executing "TM3"

                            and when the              R13 = a ;  R16 = b ;  R19 = c ;  R22 = d
                              program                   R14 = a' ; R17 = b' ;  R20 = c' ; R23 = d'
                                 stops:                    R15 = a" ; R18 = b" ; R21 = c" ; R24 = d"     ( R25: temp )

Flags: ?  ( for example: CF 01 for a projection , SF 01 for a reflexion ... )
Subroutines: The transformation itself
 
 

01  LBL "TM3"
02  ASTO 25
03  CLST
04  SIGN
05  XEQ IND 25
06  STO 13
07  RDN
08  STO 14
09  X<>Y
10  STO 15
11  CLST
12  SIGN
13  X<>Y
14  XEQ IND 25
15  STO 16
16  RDN
17  STO 17
18  X<>Y
19  STO 18
20  CLST
21  SIGN
22  X<> Z
23  XEQ IND 25
24  STO 19
25  RDN
26  STO 20
27  X<>Y
28  STO 21
29  CLST
30  XEQ IND 25
31  STO 22        
32  ST- 13
33  ST- 16
34  ST- 19
35  RDN
36  STO 23
37  ST- 14
38  ST- 17
39  ST- 20
40  X<>Y
41  STO 24        
42  ST- 15
43  ST- 18
44  ST- 21
45  13.02403
46  END

 
  ( 85 bytes / SIZE 026 )
 

Example:      Find the matrix defining the symmetry with respect to the plane (P) 2x + 3y + 7z = 4 in the direction of the vector U(-2;4;-1)

1°)  4  STO 00   2  STO 01   3  STO 02   7  STO 03   -2  STO 04   4  STO 05   -1  STO 06     SF 01 ( symmetry )
2°)  [alpha] "PS3" [alpha]
3°)  XEQ "TM3"  >>>>  13.02403  = control number of the matrix and we get:

           [ [   9    12    28   -16  ]                   R13   R16   R19   R22                     x' =   9x + 12y + 28z -16
             [ -16  -23  -56    32  ]        =         R14   R17   R20   R23        and        y' = -16x -23y -56z + 32          defines this symmetry.
             [   4      6    15    -8   ] ]                 R15   R18   R21   R24                      z' =   4x + 6y + 15z -8
 

        c) n-Dimensional Space
 

-M'(x'1,....,x'n)  may be computed from  M(x1,....,xn)   by the formulas:

            x'1 = a11.x1 + a12.x2 + ......... + a1n.xn + b1
            x'2 = a21.x1 + a22.x2 + ......... + a2n.xn + b2
             .................................................................
            x'n = an1.x1 + an2.x2 + ......... + ann.xn + bn

-"TMN" calculates and stores these n(n+1) coefficients into registers  R4n+3 thru Rn2+5n+2 ( in column order )

Data Registers:  R00 thru R3n  are used by the subroutine ( at least most of them , which are to be initialized before executing "TMN" )
                             R3n+1 = Tf name   R3n+2: temp   ;    R3n+3 to R4n+2 contain successively ( 1,0,....,0 ) .......( 0,......,0,1) ( 0,........,0)

    and when the program stops:          R4n+3 = a11  ................... Rn2+3n+3 = a1n      Rn2+4n+3 = b1
                                                          .........................................................................................
                                                         R5n+2 = an1  ................... Rn2+4n+2 = ann      Rn2+5n+2 = bn
Flags: ?   ( perhaps SF 01 for a reflexion , .... )
Subroutine:   The transformation itself ( "OPSN" "OPSLN" "PSN" "PSLN" "ROTN" ... )

-If you don't have an HP-41CX,
 replace line 51 by the 7 instructions:   STO Z   0   LBL 04   STO IND T   ISG T   GTO 04   RDN
      and line 25 by the 7 instructions:    STO Z   0   LBL 00   STO IND T   ISG T   GTO 00   RDN
 
 

01  LBL "TMN"
02  STO Y
03  3
04  *
05  1
06  +
07  ASTO IND X
08  1
09  +
10  RCL Y
11   E3
12  /
13  ISG X
14  STO IND Y
15  X<>Y
16  .1
17  %
18  +
19  +
20  ST+ Y
21  X<>Y
22  INT
23  LBL 01
24  X<>Y
25  CLRGX
26  1
27  -
28  RCL IND X  
29  X<>Y
30  ST+ Y
31  1
32  STO IND Z
33  +
34  ISG L
35  CLX
36  ST- L
37  R^
38  RCL IND L
39  RDN
40  XEQ IND T  
41  LASTX
42  +
43  INT
44  RCL Y
45  1
46  -
47  RDN
48  ISG IND T
49  GTO 01
50  X<>Y
51  CLRGX
52  STO Z
53  2
54  -
55  RDN
56  RCL IND T  
57  RDN
58  XEQ IND T
59  LBL 02
60  RCL X
61  LASTX
62  STO T
63  -
64  LBL 03
65  RCL IND Y  
66  ST- IND Y
67  X<> L
68  -
69  DSE Z
70  GTO 03
71  X<>Y
72  ISG X
73  GTO 02
74  ISG Y
75  X<> L
76   E5
77  /
78  +
79  END

 
  ( 122 bytes / SIZE n2+5n+3 )
 
 

      STACK        INPUTS      OUTPUTS
           X              n      bbb.eeenn

   where  bbb = 4n+3 ;  eee = n2+5n+2  ;  n = the dimension of the space = the number of rows of the matrix.
   bbb.eeenn  is the control number of the matrix.

Example:   Tf is the symmetry with respect to (H):  x + 2y + 3z + 6t = 10  parallel to the vector  V(2;4;7;-5)

1°)  10  STO 00    1  STO 01   2  STO 02    3  STO 03    6  STO 04    2  STO 05   4  STO 06    7  STO 07   -5  STO 08
       ( these numbers are used by "PSN" )
2°)  We place the name of the subroutine in the "alpha" register   [alpha]  PSN  [alpha]
3°)  We set flag F01 ( Tf is a symmetry )   SF 01
3°)  4  XEQ "TMN"  >>>>   24.04304    ( in 36 seconds )   and we get the matrix in registers R24 thru R43:

               -3     -8     -12    -24     40                   R24   R28   R32   R36   R40
               -8    -15    -24    -48     80         =        R25   R29   R33   R37   R41           respectively.
              -14   -28    -41    -84    140                  R26   R30   R34   R38   R42
               10     20     30      61   -100                 R27   R31   R35   R39   R43

-Thus, this symmetry may be defined by:

            x' = -3x - 8y - 12z - 24t + 40
            y' = -8x - 15y - 24z - 48t + 80
            z' = -14x - 28y - 41z - 84t + 140
            t' =  10x + 20y + 30z + 61t - 100

Note:

-"TMN" may of course be used with other subroutines than those listed above ( "OPSN" "PSN" ...etc... )
   but they must do the same modifications in the stack, i-e:
 

      STACK        INPUTS      OUTPUTS
           Y       bbb.eee(M)       bbb.eee(M)
           X           bbb'       bbb.eee(M')
           L             /             n

-However, it doesn't matter if they modify registers R3n+3 to R4n+2
-If you need, say 1, extra register:   R3n+1,   ( for instance to store a ratio of magnification ),  simply replace line 05  by  2
-If you need, say 2 extra registers:   R3n+1 and R3n+2 , replace line 05 by 3
-If you need n extra registers:    R3n+1 to R4n ( for instance to store the coordinates of a vector defining a translation ), replace line 03 by 4
-If you need 2n extra registers:  R3n+1 to R5n, replace line 03 by 5   ... and so on ...
 

6°) Product ( Composition ) of 2 Transformations
 

-If 2 mappings Tf1 and Tf2   are defined by their matrices, the following program computes the matrix of the product  Tf1oTf2
-The coefficients of the 1st matrix are to be stored into consecutive registers  in column order  and likewise for the 2nd matrix.

-These 2 arrays are represented by control numbers of the form:  bbb.eeenn1 and  bbb.eeenn2
  where  bbb is the first register , eee is the last register of the block and  nn = the number of rows     ( all bbb > 0   ;   eee - bbb + 1 = n(n+1)  )

-You also have to specify the first register of the product:   Rbbb3
 

Data Registers:   R00: temp    and  the  3n(n+1) registers of the 3 matrices.
Flags:  F10
Subroutines: /

-If you don't want to use register a, replace lines 56 and 40 with the 4 lines   RCL M   FRC   ISG X   INT   and delete line 14
 
 

01  LBL "COMP"
02  STO 00
03  STO O
04  RDN
05  STO N
06  SF 10
07  ISG X
08  CF 10
09  X<>Y
10  STO M
11  FRC
12  ISG X
13  INT
14  STO a
15  .1
16  %
17  ST- M
18  X<>Y
19  STO Q
20  DSE 00
21  LBL 01
22  CLX
23  STO P 
24  RCL M
25  RCL N
26  LBL 02
27  RCL IND Y  
28  RCL IND Y
29  *
30  ST+ P
31  CLX
32  SIGN
33  +
34  ISG Y
35  GTO 02
36  SIGN
37  ST+ 00
38  ST+ M          
39  CLX
40  RCL a
41  X^2
42  RCL 00
43  RCL O
44  -
45  X<Y?
46  FS? 10
47  X<0?
48  GTO 03
49  RCL IND T
50  ST+ P
51  LBL 03
52  X<> P
53  STO IND 00 
54  DSE Q
55  GTO 01
56  RCL a
57  STO Q
58  ST- M
59  ISG N
60  GTO 01
61  1
62  %
63  RCL 00
64  +
65   E3
66  /
67  RCL O          
68  +
69  CLA
70  END

 
  ( 118 bytes )
 
 

      STACK        INPUTS      OUTPUTS
           Z       bbb.eeenn1             /
           Y       bbb.eeenn2             /
           X          bbb3      bbb.eeenn3

Example1:   Find the matrix of the composition of

   s1  defined by  x' = 0.8 x - 0.6 y + 0.4    and  s2  defined by    x' = -0.8 x - 0.6 y - 1.2
                          y' = -0.6 x - 0.8 y + 1.2                                   y' = -0.6 x + 0.8 y - 0.4

-Let's store these 12 coefficients, for instance:

                      [ [  0.8  -0.6   0.4 ]    into  R01   R03   R05     and    [ [ -0.8   -0.6   -1.2 ]    into  R07   R09   R11    respectively.
                        [ -0.6  -0.8   1.2 ] ]         R02   R04   R06                [ -0.6     0.8   -0.4 ] ]         R08   R10   R12
                                                        ( control number = 1.00602 )                                       ( control number = 7.01202 )

-Then,       1.00602  ENTER^
                 7.01202  ENTER^
                      13      XEQ "COMP" >>>>  13.01803  ( in 9 seconds )  and we get the coefficients of  s1os2  in registers R13 to R18

                      [ [ -0.28  -0.96  -0.32 ]       =     R13  R15  R17     respectively
                        [  0.96  -0.28    2.24 ] ]     =     R14  R16  R18

-Actually,    s1 is the reflexion with respect to (L): x + 3y = 2  and   s2  is the reflexion with respect to  (L'): 3x + y = -2
-Therefore, s1os2  is the rotation r by the angle 2µ around the point A(-1;1)
 where µ = 53.1301024° = the angle between (L) and (L') and  A = the point of intersection of (L) and (L') as states a well known theorem.
 

Example2:    This program may also be used to compute the coordinates of M' = Tf (M)

-For example, if M(2;5) and r is the rotation above ( its coefficients in registers R13 thru R18 )   Let's store  2 and 5 into registers R21 R22 respectively and:

    13.01802  ENTER^
    21.02202  ENTER^
         25        XEQ "COMP"  >>>>  25.02602    and we find in registers R25 and R26    M'( -5.68 ; 2.76 )

-Remark that the control number of M  must be  21.02202 and not  21.022   ( bbb.eeenn and not bbb.eee  )

-In general, this product is not commutative.
 

7°) Reciprocal of a Transformation
 

-  Tf is defined by the formulas:

      x'1 = a11.x1 + a12.x2 + ......... + a1n.xn + b1
      x'2 = a21.x1 + a22.x2 + ......... + a2n.xn + b2
      .................................................................
      x'n = an1.x1 + an2.x2 + ......... + ann.xn + bn
 

-"INVTF" computes a'i,j and  b'i  with

    x1 = a'11.x'1 + a'12.x'2 + ......... + a'1n.x'n + b'1     i-e the coefficients of   Tf -1
    x2 = a'21.x'1 + a'22.x'2 + ......... + a'2n.x'n + b'2
      .................................................................
    xn = a'n1.x'1 + a'n2.x'2 + ......... + a'nn.x'n + b'n
 

Data Registers:        R00: temp       ( Registers R01 thru Rn2+n  are to be initialized before executing "INVTF" )

                                •  R01 = a1,1      •  Rn+1 = a1,2   .......................................   •  Rn2-n+1 = a1,n  •  Rn2+1 = b1
                                •  R02 = a2,1      •  Rn+2 = a2,2   .......................................   •  Rn2-n+2 = a2,n  •  Rn2+2 = b2
                                       .....................................................................................................................................
                                •  Rnn = an,1      •  R2n  =  an,2   ........................................   •  Rn2 = an,n         •  Rn2+n = bn

   and when the program stops,  R00 = det A  and  R01 thru Rn2+n  contain the coefficients of the reciprocal ( in column order )
   ( Rn2+n+1 to R2n2+n are used for temporary data storage: in fact a'i,j are also stored in these registers )

Flag:  ( F01 )
Subroutine:  "LS"  ( cf "Linear and non-linear systems for the HP-41" )

-If you don't have an HP-41CX,  replace line 13 by   0   LBL 00   STO IND Y   ISG Y   GTO 00   CLX   RCL Z   X^2   -   ( 9 lines )
 
 

01  LBL "INVTF"
02  ENTER^
03  X^2
04  ENTER^
05  ST+ X
06  LASTX
07  ST+ Z
08  +
09   E3
10  /
11  +
12  ISG X
13  CLRGX  
14  X<>Y
15  1
16  +
17   E5
18  /
19  +
20  SIGN
21  LBL 01
22  STO IND L  
23  ISG L
24  GTO 01
25  LASTX
26  FRC
27   E-5
28  -
29  1
30  +
31   E-7
32  XEQ "LS"     
33  LASTX
34  FRC
35  ENTER^
36  ISG X
37  INT
38  STO Z
39  X^2
40  X<>Y
41   E3
42  *
43  INT
44  LBL 02
45  RCL IND X
46  STO IND Z  
47  RDN
48  DSE X
49  DSE Y
50  GTO 02
51  1
52  CHS
53  LBL 03
54  ST* IND Y  
55  DSE Y
56  DSE T
57  GTO 03
58  END

 
  ( 96 bytes / SIZE 2n2+n+1 )
 
 

      STACK        INPUTS      OUTPUTS
           X              n             -1

 
Example:      Tf is defined by

    x' = x + y + z + 4
    y' = x + 2y +3z + 1       Find  the reciprocal transformation.
    z' = x + 3y + 6z + 8

-Store

     1   1   1   4                R01   R04   R07   R10
     1   2   3   1       in      R02   R05   R08   R11      respectively
     1   3   6   8                R03   R06   R09   R12

-Then    3  XEQ "INVTF"   >>>>  ( 28 seconds )  -1   and we get

         3   -3   1  -17
        -3   5  -2   23    in the same registers   ( and R00 = det A = 1 ). Thus:
         1  -2   1   -10

    x =  3x' - 3y + z - 17
    y = -3x' + 5y' -2z' + 23   define  the reciprocal.
    z =   x' - 2y' + z' - 10

Notes:

-Meaningless results will be obtained if the matrix A = [ ai,j ]  has no inverse ( check that  det A is significantly different from 0 in register R00 )
-We must have n < 13.
 

8°) A Few Tests
 

        a) Projection ? Symmetry ?
 

-Let  Tf  defined by the formulas:

     x'1 = a11.x1 + a12.x2 + ......... + a1n.xn + b1
     x'2 = a21.x1 + a22.x2 + ......... + a2n.xn + b2
      .................................................................
     x'n = an1.x1 + an2.x2 + ......... + ann.xn + bn

-"PS?" tests if this transformation is a projection or a symmetry

Data Registers:        R00: temp       ( Registers R01 thru Rn2+n  are to be initialized before executing "PS?" )

                                •  R01 = a1,1      •  Rn+1 = a1,2   .......................................   •  Rn2-n+1 = a1,n  •  Rn2+1 = b1
                                •  R02 = a2,1      •  Rn+2 = a2,2   .......................................   •  Rn2-n+2 = a2,n  •  Rn2+2 = b2
                                       .....................................................................................................................................
                                •  Rnn = an,1      •  R2n  =  an,2   ........................................   •  Rn2 = an,n         •  Rn2+n = bn

Flags:  F00          If flag F00 is still set when the program stops, Tf is a projection or a constant mapping.
             F03         If flag F03 is still set when the program stops, Tf is a symmetry.
Subroutines:  /

-If you don't want to use register a, replace lines 78 , 55 and 20 with the 5 lines   RCL M   FRC   ISG X   CLX   INT   and delete line 06
 
 

01  LBL "PS?"     
02  SF 00
03  SF 03
04  ENTER^
05  STO O
06  STO a
07  X^2
08  LASTX
09   E5
10  /
11  +
12  STO M
13  +
14  STO N
15  INT
16  STO 00
17  LBL 01
18  CLX
19  STO P 
20  RCL a
21  X^2
22  RCL 00
23  X<=Y?
24  GTO 01
25  RCL IND 00
26  STO P  
27  LBL 01
28  RCL M
29  RCL N
30  LBL 02
31  RCL IND Y
32  RCL IND Y
33  *
34  ST+ P
35  CLX
36  SIGN
37  -
38  DSE Y
39  GTO 02
40  X<> P
41  RCL IND 00
42  RCL Y
43  -
44  ABS
45   E-7   
46  X<=Y?
47  CF 00
48  X<> Z
49  RCL 00
50  1
51  ST- M
52  -
53  ENTER^
54  STO 00        
55  RCL a
56  ST/ Z
57  MOD
58  X<>Y
59  INT
60  -
61  ABS
62  CHS
63  X=0?
64  SIGN
65  X<0?
66  CLX
67  -
68  ABS
69   E-7  
70  X<=Y?
71  CF 03
72  FC? 00
73  FS? 03
74  X<0?
75  GTO 03        
76  DSE O
77  GTO 01
78  RCL a
79  STO O
80  ST+ M
81  DSE N
82  GTO 01
83  LBL 03
84  CLA
85  END

 
  ( 135 bytes / SIZE n2+n+1 )
 
 

      STACK        INPUTS      OUTPUTS
           X              n             /

Example1:   A mapping is given by

     x' = 9x + 12y + 28z -16
     y' = -16x -23y -56z +32
     z' = 4x + 6y +15z - 8

-We store

         9    12     28   -16              R01   R04   R07   R10
      -16   -23   -56    32      in     R02   R05   R08   R11      respectively
        4      6      15    -8               R03   R06   R09   R12

-Then      3  XEQ "PS?"   >>>>   28 seconds later,  flag F00 is clear and flag F03  is set:   the transformation is a symmetry but not a projection.

Example2:

      x' = 9x + 12y -28        store         9   12   -28        in        R01   R03   R05      respectively
      y' = -6x - 8y + 21                       -6   -8     21                  R02   R04   R06

and      2   XEQ "PS?"  >>>>  13   seconds later,   flag F00 is set and flag F03  is clear:   the transformation is projection but not a symmetry.

-If Flags F00 and F03 are clear, the mapping is neither a projection nor a symmetry.
-If both flags are set, the mapping = Identity.
-Actually, this program computes the elements of  TfoTf:
  If  TfoTf = Id  we have a symmetry
  If  TfoTf = Tf  we have a projection or a constant.
-This program can test up to a  17x18 matrix.
 

        b) Isometry ?
 

-Let  Tf  defined by the formulas:

      x'1 = a11.x1 + a12.x2 + ......... + a1n.xn + b1
      x'2 = a21.x1 + a22.x2 + ......... + a2n.xn + b2
      .................................................................
      x'n = an1.x1 + an2.x2 + ......... + ann.xn + bn

-"PS?" tests if this transformation is an isometry (  i-e  if it preserves the distances )

Data Registers:        R00: temp    ( Registers R01 thru Rn2  are to be initialized before executing "ISO?" )  Registers Rn2+1 to Rn2+n are actually unused.

                                •  R01 = a1,1      •  Rn+1 = a1,2   .......................................   •  Rn2-n+1 = a1,n  •  Rn2+1 = b1
                                •  R02 = a2,1      •  Rn+2 = a2,2   .......................................   •  Rn2-n+2 = a2,n  •  Rn2+2 = b2
                                       .....................................................................................................................................
                                •  Rnn = an,1      •  R2n  =  an,2   ........................................   •  Rn2 = an,n         •  Rn2+n = bn

Flags:  F02:    If flag F02 is still set when the program stops, Tf is an isometry.
Subroutines:  /

-If you don't want to use register a, replace lines 55 and 34 with the 5 lines   RCL M   FRC   ISG X   CLX   INT   and delete line 04
 
 

01  LBL "ISO?"  
02  SF 02
03  STO O
04  STO a
05  X^2
06  STO 00
07  LASTX
08   E5
09  /
10  +
11  STO M
12  STO N
13  LBL 01
14  CLX
15  STO P 
16  RCL M
17  RCL N
18  LBL 02
19  RCL IND Y
20  RCL IND Y
21  *
22  ST+ P
23  DSE Y
24  RDN
25  DSE Y
26  GTO 02
27  X<> P
28  RCL 00
29  1
30  ST- M
31  -
32  ENTER^
33  STO 00       
34  RCL a
35  ST/ Z
36  MOD
37  X<>Y
38  INT
39  -
40  ABS
41  CHS
42  X=0?
43  SIGN
44  X<0?
45  CLX
46  -
47  ABS
48   E-7
49  X<=Y?
50  CF 02
51  X<=Y?
52  GTO 03       
53  DSE O
54  GTO 01
55  RCL a
56  STO O
57  ST+ M
58  SIGN
59  ST- N
60  RCL 00       
61  X#0?
62  GTO 01
63  LBL 03
64  CLA
65  END

 
  ( 104 bytes / SIZE n2+1 )
 
 

      STACK        INPUTS      OUTPUTS
           X              n             /

Example:     A mapping is given by

     x' = 0.8.x - 0.6.y +1       we         0.8  -0.6    1    in   R01  R03  R05    ( in fact, registers R05 & R06 are unused )
     y' = 0.6.x + 0.8.y +2     store       0.6    0.8    2          R02  R04  R06

-Then      2  XEQ "ISO?"   >>>>  6 seconds later, Flag F02 is still set:  we have an isometry ( actually a rotation )

-This program works up to n = 17.
 

        c) Similarity ?
 

-Let  Tf  defined by the formulas:

      x'1 = a11.x1 + a12.x2 + ......... + a1n.xn + b1
      x'2 = a21.x1 + a22.x2 + ......... + a2n.xn + b2
      .................................................................
      x'n = an1.x1 + an2.x2 + ......... + ann.xn + bn

-"SIM?" tests if this transformation is a similarity (  i-e  if it preserves the ratios of distances )

Data Registers:        R00: temp       ( Registers R01 thru Rn2  are to be initialized before executing "SIM?" )    Registers Rn2+1 to Rn2+n are actually unused.

                                •  R01 = a1,1      •  Rn+1 = a1,2   .......................................   •  Rn2-n+1 = a1,n  •  Rn2+1 = b1
                                •  R02 = a2,1      •  Rn+2 = a2,2   .......................................   •  Rn2-n+2 = a2,n  •  Rn2+2 = b2
                                       .....................................................................................................................................
                                •  Rnn = an,1      •  R2n  =  an,2   ........................................   •  Rn2 = an,n         •  Rn2+n = bn

Flags:  F02:    If flag F02 is still set when the program stops, Tf is a similarity.
Subroutines:  /

-If you don't want to use register a, replace lines 41 and 13 with the 5 lines   RCL M   FRC   ISG X   CLX   INT   and delete line 04
 
 

01  LBL "SIM?"
02  SF 02
03  STO O
04  STO a
05  X^2
06  STO 00
07  LASTX
08   E5
09  /
10  +
11  STO M
12  STO N
13   E99
14  STO P
15  CHS
16  STO Q
17  LBL 01
18  RCL M
19  RCL N
20  ENTER^
21  CLX
22  LBL 02
23  RCL IND Z
24  SIGN
25  CLX
26  RCL IND Z
27  ST* L
28  X<> L
29  DSE Z
30  +
31  DSE Z
32  GTO 02
33  +
34  RCL 00
35  ENTER^
36  SIGN
37  ST- M
38  -
39  ENTER^
40  STO 00
41  RCL a
42  ST/ Z
43  MOD
44  X<>Y
45  INT
46  X=Y?
47  GTO 03      
48  R^
49  ABS
50  PI 
51  CHS
52  10^X
53  X^2
54  X<Y?
55  CF 02
56  X<Y?
57  GTO 05
58  GTO 04
59  LBL 03
60  X<> P
61  R^
62  X>Y?
63  X<>Y
64  STO P
65  X<> Q
66  R^
67  X<Y?
68  X<>Y
69  STO Q
70  LBL 04      
71  DSE O
72  GTO 01
73  RCL a
74  STO O
75  ST+ M
76  SIGN
77  ST- N
78  RCL 00
79  X#0?
80  GTO 01
81  RCL Q      
82  RCL P
83  RCL Y
84  RCL Y
85  -
86  5 E-7
87  X<Y?
88  CF 02
89  R^
90  R^
91  +
92  2
93  /
94  SQRT
95  LBL 05
96  CLA
97  END

 
  ( 151 bytes / SIZE n2+1 )
 
 

      STACK        INPUTS      OUTPUTS
           X              n             k

  where k = the ratio of magnification  ( if Flag F02 is still set at the end )

Example:     Tf   is given by

     x' =   7.68.x - 6.4.y - 0.24.z + 9.28
     y' = -4.24.x - 4.8.y - 7.68.z - 3.04
     z' =  -4.8.x   - 6.y  +  6.4.z  + 19.2

-We store

          7.68    -6.4     -0.24     9.28                R01   R04   R07   R10
        -4.24    -4.8     -7.68   -3.04      into     R02   R05   R08   R11      respectively     ( Registers R10 to R12 are actually unused )
         -4.8      -6         6.4      19.2                 R03   R06   R09   R12

   3  XEQ "SIM?"   >>>>  10  ( execution time = 19 seconds ),  Flag F02 is still set:   Tf is a similarity and the ratio of magnification k = 10
 

-This program may also be used to test an isometry by comparing  k  with  1  ( if flag F02 is set )
-Up to 17x18 matrices can be dealt with.
 

9°) Matrix >>>> Transformation
 

        a) 2-Dimensional Space
 

-"MT2"  gives the specifications of a transformation Tf defined by the following formulas

     x' = ax + by + c
     y' = a'x + b'y + c'

-This program finds the projections, symmetries and isometries.
 

Data Registers:        • R01 = a    • R03 = b   • R05 = c                    ( these 6 registers are to be initialized before executing "MT2" )
                                   • R02 = a'   • R04 = b'   • R06 = c'

                     R00 and R07 to R19: temp
                     when the program stops,  R00 thru R04 contain the required data

Flags:  F00 F01 F02 F03 F10
Subroutines:  PS?   ISO?   COMP  and  LS  ( cf "linear and non-linear systems for the HP-41" )

-The append character is denoted  ~
-If you don't have an X-Functions Module, you may, for instance,
  replace all the REGMOVEs by  XEQ 14 and add the 21 following instructions after line 154

 RTN
 LBL 14
 INT
 LASTX
 FRC
  E3
 *
 INT
 ST- L
  E3
 ST* L
 LBL 15
 CLX
 RCL IND Z
 STO IND Y
 ISG Y
 CLX
 ISG Z
 CLX
 DSE L
 GTO 15

( This alternative is not necessarily the best! )
 
 

  01  LBL "MT2"
  02  14.001006
  03  STO 12
  04  7.000005
  05  STO 13
  06  1.014006
  07  REGMOVE
  08  2
  09  XEQ "PS?"
  10  FS? 00
  11  FC? 03
  12  GTO 00
  13  "ID"
  14  PROMPT
  15  LBL 00
  16  CF 01
  17  2
  18  XEQ "ISO?"
  19  FS? 02
  20  GTO 01
  21  FC? 00
  22  FS? 03
  23  GTO 00
 24  "TF NOT FOUND"
  25  PROMPT
  26  LBL 00
  27  XEQ 03
  28  XEQ 06
  29  RCL 12
  30  REGMOVE
  31  CLX
  32  FS? 03
  33  SIGN
  34  ST+ 01
  35  ST+ 04
  36  SIGN
  37  CHS
  38  XEQ 04
  39  RCL 01
  40  RCL 04
  41  +
  42  X=0?
  43  1/X
  44  RCL 03
  45  CHS
  46  STO 10
  47  1
  48  STO 11
  49  RCL 04
  50  X=0?
  51  GTO 00
  52  STO 10
  53  CLX
  54  STO 11
  55  LBL 00
  56  RCL 13
  57  REGMOVE          
  58  "PROJ"
  59  FS? 03
  60  "SYM"
  61  "~/L//V"
  62  PROMPT
  63  LBL 01
  64  XEQ 03
  65  RCL 01
  66  RCL 04
  67  +
  68  GTO IND X
  69  LBL 00
  70  RCL 19
  71  STO 02
  72  RCL 18
  73  STO 01
  74  "TRANS"
  75  PROMPT
  76  LBL 01
  77  14.01902
  78  STO Y
  79  6
  80  XEQ "COMP"      
  81  RCL 12
  82  REGMOVE
  83  2
  84  ST/ 10
  85  ST/ 11
  86  RCL 10
  87  ST- 05
  88  RCL 11
  89  ST- 06
  90  XEQ 03
  91  XEQ 06
  92  RCL 13
  93  REGMOVE
  94  "REFL/L"
  95  FC? 03
  96  "~*TRANS"
  97  PROMPT
  98  LBL 02
  99  RCL 06
100  STO 02
101  RCL 05
102  STO 01
103  RCL 15
104  RCL 14
105  R-P
106  RDN
107  STO 00
108  "ROT"
109  PROMPT
110  LBL 03
111  1
112  CHS
113  ST+ 01
114  ST+ 04
115  LBL 04
116  ST* 05
117  ST* 06
118  1.00602
119   E-7
120  XEQ "LS"
121  6
122  LBL 05
123  RCL IND X          
124  ABS
125   E-7 
126  X<=Y?
127  GTO 00
128  CLX
129  STO IND Z          
130  LBL 00
131  X<> Z
132  DSE X
133  GTO 05
134  RTN
135  LBL 06
136  RCL 05
137  STO 07
138  RCL 01
139  STO 08
140  RCL 03
141  STO 09
142  RCL 04
143  X=0?
144  RTN
145  RCL 06
146  STO 07
147  CLX
148  STO 08
149  SIGN
150  STO 09
151  END
 

 
   ( 314 bytes / SIZE 020 )
 

Example1:     Tf  is defined by

      x' = 9x + 12y -28      store    9   12   -28     in     R01   R03   R05      respectively
      y' = -6x - 8y + 21                -6  -8     21             R02   R04   R06

   XEQ "MT2"  >>>>   ( in 35 seconds )    "PROJ/L//V"   meaning we have a projection onto a line (L) in the direction of a vector V

                with (L):  1 x + 1.5 y = 3.5   the coefficients  1   1.5   3.5   in registers  R01   R02   R00  respectively
                 and  V( -4/3 ; 1 )  in registers  R03  R04  respectively

Example2:

     x' = 17x + 24y - 56      store    17   24   -56    in    R01  R03  R05    respectively
     y' = -12x - 17y + 42               -12  -17   42           R02  R04  R06

   XEQ "MT2"  >>>>  ( 35 seconds )   "SYM/L//V"   Tf is a symmetry with respect to line (L) in the direction of vector V

                with (L):  1 x + 1.5 y = 3.5   the coefficients  1   1.5   3.5   in registers  R01   R02   R00  respectively
                 and  V( -4/3 ; 1 )  in registers  R03  R04  respectively

Example3:

      x' = 0.28x - 0.96y + 2.16     these 6 coefficients are stored into R01 to R06  ( in column order )
      y' = -0.96x -0.28y + 2.88

   XEQ "MT2"  >>>>  ( 51 seconds )    "REFL/L"     Tf is a reflexion with respect to line (L):  1 x + 4/3 y = 3   ( in registers R01  R02  R00 respectively )

Example4:

      x' = 0.28x - 0.96y - 1.84     these 6 coefficients are stored into R01 to R06  ( in column order )
      y' = -0.96x -0.28y + 5.88

   XEQ "MT2"  >>>>  ( 41 seconds )   "REFL/L*TRANS"     Tf is the product of a reflexion / a line (L) and a translation defined by U parallel to (L)

              (L): 1 x + 4/3 y = 3  ( in R01  R02  R00 )    and  U( -4 ; 3 )  in registers R03  R04

Example5:

      x' = 0.8x - 0.6y + 2.2     we store these 6 numbers in R01 to R06
      y' = 0.6x + 0.8y - 0.6

   XEQ "MT2"  >>>>   ( 24 seconds )   "ROT"    Tf is a rotation by an angle µ around a point A    µ is in R00 and the coordinates of A in R01 and R02

                Here,   µ = 36.86989765  and  A( 2 ; 3 )

Example6:

       x' = x + 3    store     1   0   3     into   R01 thru R06
       y' = y + 7                 0   1   7

   XEQ "MT2"  >>>>  ( 17 seconds )     "TRANS"    Tf is a translation defined by a vector U    Here  U(3;7)  is registers  R01 and R02

-Likewise, with    x' = x      and      1   0   0      in R01 to R06     XEQ "MT2"  displays  "ID"  in 14 seconds but these transformations are trivial!
                           y' = y                  0   1   0

Example7:

       x' = 2x + 3y + 1     in this case, the HP-41 displays "TF NOT FOUND"  after 7 seconds:  Tf is neither a symmetry nor a projection nor an isometry!
       y' = 3x + 4y + 7
 

Remarks:

-Examples 3 to 6 illustrate all the possible isometries in a 2-dimensional Euclidean space.
-A central symmetry is equivalent to a rotation by 180°
-The HP-41 displays "DATA ERROR" ( line 43 )  if Tf is constant ( a = b = a' = b' = 0 ).
-You may also replace line 42-43 with  X#0?  GTO 00  RCL 19  STO 02  RCL 18  STO 01  "CST"  PROMPT  LBL 00
-Every similarity can be expressed as the product of an homothecy ( arbitrary center, hereafter we choose the origin O ) and an isometry.
 Therefore, we can use "SIM?"  first and then "MT2" if a similarity has been found.

For instance:

       x' =  2.8x - 9.6y - 18.4
       y' = -9.6x - 2.8y + 58.8

    1°)   Store these 6 numbers into R01 to R06
    2°)   2  XEQ "SIM?"  >>>>  Flag F02 is still set at the end and we have k = 10 ( ratio of magnification )
    3°)  Divide the contents of registers R01 to R06 by k  ( ST/ 01  ST/ 02  ST/ 03  ST/ 04  ST/ 05  ST/ 06 )
    4°)  XEQ "MT2"  >>>>  we find the results of example 4 above

-Thus this transformation is the product of 3 transformations:    Tf = hosot   where
 
     h is an homothecy ( homothetic center = the origin O ; ratio of magnification = 10 )
     s is the reflexion with respect to (L): x + 4/3 y = 3
     t is the translation defined by the vector U(-4;3)

-It's not difficult to modify "MT2" to take all similarities into account, but it costs several bytes:
-Change line 18 by XEQ "SIM?" ,add

    ST/ 01  ST/ 02  ST/ 03  ST/ 04  ST/ 05  ST/ 06
    ST/ 14  ST/ 15  ST/ 16  ST/ 17  ST/ 18  ST/ 19  STO 20  2  XEQ "PS?"  after line 63 ,

  and modify the text lines if  k is different from 1.
 

        b) 3-Dimensional Space
 

-"MT3"  determines the characteristics of a transformation Tf defined by the formulas

     x' = ax + by + cz + d
     y' = a'x + b'y + c'z + d'
     z' = a"x + b"y + c"z + d"

-This program identifies the projections, symmetries and isometries.
 

Data Registers:        ( Registers R01 thru R12 are to be initialized before executing "MT3" )

                                   • R01 = a    • R04 = b   • R07 = c     • R10 = d
                                   • R02 = a'   • R05 = b'   • R08 = c'    • R11 = d'
                                   • R03 = a"   • R06 = b"  • R09 = c"    • R12 = d"

                     R00 and R13 to R37: temp
                     when the program stops,  R00 thru R09 contain the solution.

Flags:  F00 F01 F02 F03 F06 F07 F10
Subroutines:  PS?   ISO?   COMP  and  LS  ( cf "linear and non-linear systems for the HP-41" )
 

Note:

-If you don't have an X-Functions Module, you may, for instance,
  replace all the REGMOVEs by  XEQ 14 and add the 21 following instructions after line 358

 RTN
 LBL 14
 INT
 LASTX
 FRC
  E3
 *
 INT
 ST- L
  E3
 ST* L
 LBL 15
 CLX
 RCL IND Z
 STO IND Y
 ISG Y
 CLX
 ISG Z
 CLX
 DSE L
 GTO 15

-The "append" character is denoted  ~  in this listing.
-If Tf is a constant mapping ( a = a' = a" = b = b' = b" = c = c' = c" = 0 ), the HP-41 displays "DATA ERROR"  ( line 38 )
-Lines 37-38 may be replaced by
  X<=Y?  GTO 00  RCL 34  STO 03  RCL 33  STO 02  RCL 32  STO 01  "CST"  PROMPT  LBL 00
-But is it really worthwhile?
 
 

  01  LBL "MT3"
  02  23.001012
  03  STO 35
  04  13.00001
  05  STO 36
  06  23.03403
  07  STO 37
  08  1.023012
  09  REGMOVE
  10  3
  11  XEQ "PS?"
  12  FS? 00
  13  FC? 03
  14  GTO 00
  15  "ID"
  16  PROMPT
  17  LBL 00
  18  CF 01
  19  3
  20  XEQ "ISO?"
  21  FS? 02
  22  GTO 01
  23  FC? 00
  24  FS? 03
  25  GTO 00
26  "TF NOT FOUND"
  27  PROMPT
  28  LBL 00
  29  XEQ 07
  30  SF 07
  31  2
  32  RCL 01
  33  RCL 05
  34  RCL 09
  35  +
  36  +
  37  X>Y?
  38  ACOS  
  39  X=Y?   
  40  CF 07   
  41  X=Y?    
  42  XEQ 05
  43  FC? 07
  44  XEQ 06
  45  FS? 07
  46  XEQ 04
  47  RCL 35
  48  REGMOVE
  49  CLX
  50  FS? 03
  51  SIGN
  52  ST+ 01
  53  ST+ 05
  54  ST+ 09
  55  SIGN
  56  CHS
  57  XEQ 08
  58  FS? 07
  59  XEQ 06
  60  FS? 07
  61  GTO 00
  62  RCL 07
  63  STO 22
  64  RCL 04
  65  STO 21
  66  RCL 01
  67  STO 20
  68  X#0?
  69  GTO 00
  70  SIGN
  71  STO 21
  72  RCL 08
  73  STO 22
  74  RCL 05
  75  X#0?
  76  GTO 00
  77  STO 21
  78  SIGN
  79  STO 22
  80  LBL 00
  81  RCL 36
  82  REGMOVE         
  83  "PROJ"
  84  FS? 03
  85  "SYM"
  86  FS? 07
  87  "~/P//V"
  88  FC?C 07
  89  "~/L//P"
  90  PROMPT
  91  LBL 01
  92  XEQ 07
  93  RCL 01
  94  RCL 05
  95  RCL 09
  96  +
  97  +
  98  GTO IND X
  99  LBL 00
100  RCL 34
101  STO 03
102  RCL 33
103  STO 02
104  RCL 32
105  STO 01
106  "TRANS"
107  PROMPT
108  LBL 01
109  RCL 37
110  STO Y
111  8
112  XEQ "COMP"
113  RCL 35
114  REGMOVE
115  2
116  ST/ 17
117  ST/.18
118  ST/ 19
119  RCL 17
120  ST- 10
121  RCL 18
122  ST- 11
123  RCL 19
124  ST- 12
125  XEQ 07
126  XEQ 04
127  RCL 36
128  REGMOVE
129  "REFL/P"
130  FC? 03
131  "~*TRANS"
132  PROMPT
133  LBL 02
134  XEQ 06
135  RCL 35
136  REGMOVE         
137  RCL 10
138  RCL 17
139  *
140  RCL 11
141  RCL 18
142  *
143  +
144  RCL 12
145  RCL 19
146  *
147  +
148  RCL 17
149  STO 20
150  X^2
151  RCL 18
152  STO 21
153  X^2
154  RCL 19
155  STO 22
156  X^2
157  +
158  +
159  /
160  ST* 20
161  ST* 21
162  ST* 22
163  RCL 20
164  ST- 10
165  RCL 21
166  ST- 11
167  RCL 22
168  ST- 12
169  XEQ 07
170  XEQ 05
171  CF 06
172  LBL 10
173  RCL 36
174  REGMOVE
175  CLX
176  STO 10
177  RCL 04
178  X=0?
179  ISG 10
180  CLX
181  RCL 10
182  RCL 24
183  *
184  RCL 30
185  +
186  STO 12
187  RCL 06
188  *
189  RCL 10
190  RCL 25
191  *
192  RCL 31
193  STO 14
194  +
195  RCL 05
196  *
197  -
198  RCL 10               
199  ST* Y
200  RCL 23
201  ST+ 14
202  *
203  RCL 29
204  +
205  RCL 05
206  *
207  RCL 04
208  RCL 12
209  *
210  -
211  +
212  SIGN
213  RCL 14
214  RCL 27
215  +
216  1
217  FS? 06
218  CHS
219  -
220  2
221  /
222  ACOS
223  *
224  STO 00
225  FS?C 06
226  RTN
227  RCL 07
228  ABS
229  RCL 08
230  ABS
231  RCL 09
232  ABS
233  +
234  +
235   E-7
236  "ROT"
237  X<=Y?
238  "~*TRANS"
239  PROMPT
240  LBL 03
241  XEQ 05
242  FC? 03
243  GTO 00
244  RCL 36
245  REGMOVE
246  "CENTR SYM"
247  PROMPT
248  LBL 00
249  RCL 37
250  STO Y
251  1
252  XEQ "COMP"     
253  XEQ 07
254  XEQ 06
255  SF 06
256  XEQ 10
257  RCL 01
258  RCL 04
259  *
260  RCL 02
261  RCL 05
262  *
263  +
264  RCL 03
265  RCL 06
266  *
267  +
268  STO 07
269  "ROT*REFL/P"
270  PROMPT
271  LBL 04
272  RCL 10
273  STO 13
274  RCL 07
275  STO 16
276  RCL 04
277  STO 15
278  RCL 01
279  STO 14
280  X#0?
281  RTN
282  SIGN
283  STO 15
284  RCL 08
285  STO 16
286  RCL 11
287  STO 13
288  RCL 05
289  X#0?
290  RTN
291  STO 15
292  SIGN
293  STO 16
294  RCL 12
295  STO 13
296  RTN
297  LBL 05
298  RCL 10
299  STO 14
300  RCL 11
301  STO 15
302  RCL 12
303  STO 16
304  RTN
305  LBL 06
306  RCL 07
307  STO 17
308  RCL 08
309  STO 18
310  1
311  CHS
312  STO 19
313  RCL 09
314  X=0?
315  RTN
316  STO 17
317  CLX
318  STO 18                
319  STO 19
320  RCL 01
321  X=0?
322  RTN
323  STO 18
324  RCL 04
325  CHS
326  STO 17
327  RTN
328  LBL 07
329  1
330  CHS
331  ST+ 01
332  ST+ 05
333  ST+ 09
334  LBL 08
335  ST* 10
336  ST* 11
337  ST* 12
338  1.01203
339   E-7
340  XEQ "LS"
341  12
342  LBL 09
343  RCL IND X
344  ABS
345   E-7
346  X<=Y?
347  GTO 00
348  CLX
349  STO IND Z
350  LBL 00
351  X<> Z
352  DSE X
353  GTO 09
354  END

 
   ( 665 bytes / SIZE 038 )

 
-In the following examples, the matrix

             a    b    c    d   is given and      R01  R04  R07  R10
    M =  a'   b'   c'   d'    it is to be         R02  R05  R08  R11   respectively before executing "MT3".
             a"  b"   c"  d"   stored into        R03  R06  R09  R12

-The numbers  a , a' , b , b' , ... etc ... in the solutions are of course different from the initial coefficients
 

Example1:

          -11  -18  -42  24
  M =  -2    -2    -7    4     XEQ "MT3"  >>>>  "PROJ/P//V"  ( 68 seconds )  Tf is a projection onto a plane (P) in the direction of vector V
            4     6    15  -8

            (P): ax + by + cz = d     with  a , b , c , d  in registers  R01  R02  R03  R00   respectively
     and  V( a',b',c')                    with  a' , b' , c'     in registers  R04  R05  R06

-In this example:   (P): x + 1.5 y + 3.5 z = 2         ( or if you prefer:   2x + 3y + 7z = 4 )
                   and    V(3;1/2;-1)                             ( or if you prefer:    V'(6;1;-2) )
 

Example2:

            -23  -36  -84   48
    M =  -4    -5   -14    8     XEQ "MT3"  >>>>  "SYM/P//V"  ( 68s )  Tf is a symmetry with respect to a plane (P) in the direction of vector V
              8    12    29  -16

              (P): ax + by + cz = d     with  a , b , c , d  in registers  R01  R02  R03  R00   respectively
       and  V( a',b',c')                    with  a' , b' , c'     in registers  R04  R05  R06

-In this example:   (P): x + 1.5 y + 3.5 z = 2         ( or if you prefer:   2x + 3y + 7z = 4 )
                   and    V(3;1/2;-1)                             ( or if you prefer:    V'(6;1;-2) )
 

Example3:

             12   2  -4   -46
    M =  18   3   -6   -74     XEQ "MT3"  >>>>  "PROJ/L//P" ( 70s )    Tf is a projection onto a line (L) in the direction of a vectorial plane (P)
             42   7 -14  -175

             (L) is determined by one point  A(xA,yA,zA)  in registers R01 R02 R03  and one vector U(a,b,c)  in registers  R04 R05 R06
             (P) is given by one of its equations:  a'x + b'y + c'z = 0  where  a' , b' , c'  are in R07 R08 R09

-Here,     A(4,1,0)    U(-2/7,-3/7,-1)       ( or if you prefer:  U'(2,3,7) )
     and    (P): x +y/6 - z/3 = 0                    or 6x + y - 2z = 0
 

Example4:

              23   4   -8    -92
     M =  36   5   -12  -148   XEQ "MT3"  >>>> "SYM/L//P" ( 70s ) Tf is a symmetry with respect to a line (L) in the direction of a vectorial plane (P)
              84  14  -29  -350

             (L) is determined by one point  A(xA,yA,zA)  in registers R01 R02 R03  and one vector U(a,b,c)  in registers  R04 R05 R06
             (P) is given by one of its equations:  a'x + b'y + c'z = 0  where  a' , b' , c'  are in R07 R08 R09

-Here,     A(4,1,0)    U(-2/7,-3/7,-1)       ( or if you prefer:  U'(2,3,7) )
     and    (P): x +y/6 - z/3 = 0                    or 6x + y - 2z = 0
 

Example5:

                1   0   0   2
    M =     0   1   0   3      XEQ "MT3"  >>>>  "TRANS"   ( 34s )    Tf is a translation   defined by a vector U(a,b,c)  in registers R01  R02  R03
                0   0   1   4

-In this example,  U(2,3,4)
-If the last column is  0 0 0  ( instead of  2 3 4 ) , the HP-41 displays "ID"
 

Example6:

                0.64   -0.48   -0.6    1.08
      M =  -0.48    0.36   -0.8    1.44         XEQ "MT3" >>>>  "REFL/P"  ( 102s  )  Tf is a reflexion with respect to a plane (P)
               -0.6     -0.8       0      1.8

            (P): ax + by + cz = d     with  a , b , c , d  in registers  R01  R02  R03  R00   respectively

-Here,   (P):  x + 4y/3 +5z/3 = 3      ( or 3x + 4y + 5z = 9 )
 

Example7:

                 0.64   -0.48   -0.6    5.08
       M =  -0.48    0.36   -0.8    3.44           XEQ "MT3" >>>>  "REFL/P*TRANS"  ( 77s  )
                -0.6     -0.8       0     -2.2

       Tf is the product of a reflexion with respect to a plane (P) and a translation defined by a vector U parallel to (P)

            (P): ax + by + cz = d     with  a , b , c , d  in registers  R01  R02  R03  R00   respectively
      and  U(a',b',c')                    with  a' , b' , c' in R04  R05  R06

-Here,   (P):  x + 4y/3 +5z/3 = 3      ( or 3x + 4y + 5z = 9 )
  and      U(4,2,-4)
 

Example8:

                 -0.56672    -0.16896    0.8064     3.64032
      M =      0.79104    -0.38528    0.4752     2.57376      XEQ "MT3"   >>>>  "ROT"   ( 66s )   Tf is a rotation by an angle µ around an axis (L)
                   0.2304        0.9072      0.352      -3.1824

-The angle µ is in register R00
-(L) is defined by one point  A(xA,yA,zA)  in registers R01 R02 R03  and one vector U(a,b,c)  in registers  R04 R05 R06

-Here,   µ = -143.1301024°   ( if the HP-41 is in DEG mode )     A(2,3,0)  and U(-0.45 , -0.6 , -1 )

  or if you prefer, after multiplying  U by  -20: U'(9,12,20)   and  µ = 143.1301024°

Note:   Don't forget to change the sign of µ if you multiply the coordinates of U by a negative number!
 

Example9:

                 -0.56672    -0.16896    0.8064     5.89032
      M =      0.79104    -0.38528    0.4752     5.57376      XEQ "MT3"   >>>>  "ROT*TRANS"   ( 66s )
                   0.2304        0.9072      0.352       1.8176

          Tf is the product of a rotation by an angle µ around an axis (L) and a translation defined by a vector V parallel to (L)

-The angle µ is in register R00
-(L) is defined by one point  A(xA,yA,zA)  in registers R01 R02 R03  and one vector U(a,b,c)  in registers  R04 R05 R06
-The vector V(a',b',c') is in registers R07  R08  R09

-Here,   µ = -143.1301024°
           (L) is determined by  A(2,3,0)  and  U(-0.45 , -0.6 , -1 )
    and  V(2.25;3;5)
 

Example10:

                  -1   0   0   4
       M =     0  -1   0   6      XEQ "MT3"  >>>>  "CENTR SYM"   ( 70s )   Tf is a central symmetry with respect to A
                   0   0  -1   8

-The point  A(xA,yA,zA)  is in registers  R01 R02 R03

-Here, we have   A(-2;-3;-4)
 

Example11:

                  0.38528    -0.1344     0.91296    -2.0192
       M =   -0.9024        0.152       0.4032       2.736             XEQ "MT3"    >>>>    "ROT*REFL/P"   ( 92s )
                  0.19296     0.9792      0.06272     0.4256

         Tf is the product of a rotation by an angle µ around an axis (L) and a reflexion with respect to a plane (P) orthogonal to (L)

-The angle µ is in register R00
-(L) is defined by the point  A(xA,yA,zA)  in registers R01 R02 R03  and one vector U(a,b,c)  in registers  R04 R05 R06
-(P) is defined by the equation  ax + by + cz = d       ( d is in R07 )

-Note that A is the unique "fixed point" of the transformation ( Tf(A) = A ):
 A is the intersection of (P) and (L)

-In this example:     µ = 36.86989765      A(2;3;4)    U(3/4;15/16;-1)      (P): 3x/4 + 15y/16 - z = 5/16
                                                     or if you prefer:    U'(12;15;-16)         (P): 12x + 15y - 16z = 5
 

 Example12:

                   1   1   1   4
     M =       1   2   3   1         XEQ "MT3"  >>>>  "TF NOT FOUND"  ( 8s )  Tf is neither a projection, nor a symmetry nor an isometry.
                   1   3   6   8
 
 

Remarks:

-Examples 5 to 11 illustrate all the possible isometries in a 3-dimensional Euclidean space.
-An axial symmetry is equivalent to a rotation by 180° around this axis.
-If you want to detemine the characteristics of a similarity:

    1°)  Key in   3  XEQ "SIM?"    if Flag F02 is still set at the end,  X = k = the ratio of magnification
    2°)  Press  ST/ 01  ST/ 02  ST/ 03  ST/ 04  ST/ 05  ST/ 06  ST/ 07  ST/ 08  ST/ 09  ST/ 10  ST/ 11  ST/ 12
    3°)  XEQ "MT3"

-If the HP-41 finds an isometry  Is , the original transformation Tf  verifies
 Tf = hoIs  where h is an homothecy  ( homothetic center = the origin O ; k = ratio of magnification )

-You may also replace line 20 by XEQ "SIM?"

   add  ST/ 01  ST/ 02  ST/ 03  ST/ 04  ST/ 05  ST/ 06  ST/ 07  ST/ 08  ST/ 09  ST/ 10  ST/ 11  ST/ 12
           ST/ 23  ST/ 24  ST/ 25  ST/ 26  ST/ 27  ST/ 28  ST/ 29  ST/ 30  ST/ 31  ST/ 32  ST/ 33  ST/ 34  STO 38  3  XEQ "PS?"  after line 91

   and modify the text lines if  k # 1
-However, choosing the homothetic center = O is not necessarily the best choice!

-In "MT2" and "MT3", the coefficients are replaced by zero if they are smaller than 10-7  ( in absolute value )
-You can replace E-7 by another small positive number.
 

        c) n-Dimensional Space
 

-The general case is extremely complex and we give only one ( easy ) example:

  Tf is defined by

      x' = 9x + 12y + 16z + 28t - 36
      y' = 4x + 7y + 8z + 14t - 18             find the characteristics of this transformation.
      z' = 20x + 30y + 41z + 70t - 90
      t' = -16x - 24y - 32z - 55t + 72
 

1°)  Store these 20 coefficients ( in column order ) into registers R01 to R20
2°)  4  XEQ "PS?"  >>>>  when the program stops,  Flag F00 is clear , Flag F03 is set:  Tf is a symmetry
3°)  4  XEQ "ISO?" >>>> when the program stops,  Flag F02 is clear: Tf is not an isometry
4°)  To find the fixed points, subtract 1 to registers R01 R06 R11 R16   ( the diagonal elements )
                                          multiply registers R17 R18 R19 R20 by -1  ( the last column )

    and we solve this system:  1.02004  ENTER^   E-7  XEQ "LS"       ( cf "linear and non-linear systems for the HP-41" )

    The array is now

       1    1.5   2   3.5   4.5
       0      0    0    0      0        whence the set of fixed points is the hyperplane (H): x + 1.5y + 2z + 3.5t = 4.5   or  2x + 3y + 4z + 7t = 9
       0      0    0    0      0
       0      0    0    0      0

5°)  Since Tf is a symmetry, let's find an eigenvector corresponding to the eigenvalue -1  ( we would choose 0 if Tf were a projection )
      We restore the 16 original coefficients into R01 to R16   ( the last column is unused here or may be replaced by 0 )
      we subtract -1 ( i-e we add 1 ) to the diagonal elements:  1  ST+ 01  ST+ 06  ST+ 11  ST+ 16
      and   1.01604  ENTER^   E-7   XEQ "LS"  the matrix becomes

       1   0   0   0.5                         x + 0.5t = 0
       0   1   0   0.25    meaning       y + 0.25t = 0    for any eigenvector  V(x,y,z,t)  corresponding to -1
       0   0   1   1.25                       z + 1.25t = 0
       0   0   0   0

-Setting arbitrarily   t = -4  we get   x = 2 ; y = 1 ; z = 5

-Therefore,  Tf is the symmetry with respect to the hyperplane (H): 2x + 3y +4z + 7t = 9  in the direction of the vector V(2,1,5,-4)

Note:

-There are so many other cases that writing a general "MTN" program seems almost impossible...
 

Reference:

[1]  J.M. Ferrard , "Mathez la HP-48 G/GX" , D3I Diffusion ,    ISBN 2-908791-12-9  ( in French )