modified: SpatialOmicsCoord.py
[GalaxyCodeBases.git] / c_cpp / etc / calc / cscript / 4dsphere.calc
blob9bfc35f925e5fab79e23e69c9bfa35a9cbb90f32
1 #!/usr/local/src/cmd/calc/calc -q -s -f
2 /*
3  * 4dsphere - determine if 6 points lie on the surface of a sphere in R^4
4  *
5  * usage:
6  *      4dsphere x0 y0 z0 w0 x1 y1 z1 w1 ... x5 y5 z5 w5
7  *
8  *      x0 y0 z0 w0     point 0 in R^4
9  *      x1 y1 z1 w1     point 1 in R^4
10  *      ...             ...
11  *      x5 y5 z5 w5     point 5 in R^4
12  *
13  * Copyright (C) 2001  Landon Curt Noll
14  *
15  * Calc is open software; you can redistribute it and/or modify it under
16  * the terms of the version 2.1 of the GNU Lesser General Public License
17  * as published by the Free Software Foundation.
18  *
19  * Calc is distributed in the hope that it will be useful, but WITHOUT
20  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
22  * Public License for more details.
23  *
24  * A copy of version 2.1 of the GNU Lesser General Public License is
25  * distributed with calc under the filename COPYING-LGPL.  You should have
26  * received a copy with calc; if not, write to Free Software Foundation, Inc.
27  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
28  *
29  * @(#) $Revision: 30.1 $
30  * @(#) $Id: 4dsphere.calc,v 30.1 2007/03/16 11:12:11 chongo Exp $
31  * @(#) $Source: /usr/local/src/bin/calc/cscript/RCS/4dsphere.calc,v $
32  *
33  * Under source code control:   2001/05/03 19:02:03
34  * File existed as early as:    2001
35  *
36  * chongo <was here> /\oo/\     http://www.isthe.com/chongo/
37  * Share and enjoy!  :-)        http://www.isthe.com/chongo/tech/comp/calc/
38  */
41  * parse args
42  */
43 argc = argv();
44 if (argc != 25) {
45     fprintf(files(2), "usage: %s x0 y0 z0 w0 x1 y1 z1 w1 ... x5 y5 z5 w5\n",
46         argv(0));
47     exit;
49 x0 = eval(argv(1));
50 y0 = eval(argv(2));
51 z0 = eval(argv(3));
52 w0 = eval(argv(4));
53 x1 = eval(argv(5));
54 y1 = eval(argv(6));
55 z1 = eval(argv(7));
56 w1 = eval(argv(8));
57 x2 = eval(argv(9));
58 y2 = eval(argv(10));
59 z2 = eval(argv(11));
60 w2 = eval(argv(12));
61 x3 = eval(argv(13));
62 y3 = eval(argv(14));
63 z3 = eval(argv(15));
64 w3 = eval(argv(16));
65 x4 = eval(argv(17));
66 y4 = eval(argv(18));
67 z4 = eval(argv(19));
68 w4 = eval(argv(20));
69 x5 = eval(argv(21));
70 y5 = eval(argv(22));
71 z5 = eval(argv(23));
72 w5 = eval(argv(24));
75  * verbose output setup
76  */
77 print "(":x0:",":y0:",":z0:",":w0:") ":;
78 print "(":x1:",":y1:",":z1:",":w1:") ":;
79 print "(":x2:",":y2:",":z2:",":w2:") ":;
80 print "(":x3:",":y3:",":z3:",":w3:") ":;
81 print "(":x4:",":y4:",":z4:",":w4:") ":;
82 print "(":x5:",":y5:",":z5:",":w5:") ":;
85  *
86  * Given the 5 points:
87  *
88  *      (x0,y1,z1,w1)
89  *      (x1,y1,z1,w1)
90  *      (x2,y2,z2,w2)
91  *      (x3,y3,z3,w3)
92  *      (x4,y4,z4,w4)
93  *      (x5,y5,z5,w5)
94  *
95  * we can determine if they lie in the surface of 4D sphere in R^4 if the
96  * following matrix is 0:
97  *
98  *      | x0^2+y0^2+z0^2+w0^2   x0      y0      z0      w0      1 |
99  *      | x1^2+y1^2+z1^2+w1^2   x1      y1      z1      w1      1 |
100  *      | x2^2+y2^2+z2^2+w2^2   x2      y2      z2      w2      1 |     = 0
101  *      | x3^2+y3^2+z3^2+w3^2   x3      y3      z3      w3      1 |
102  *      | x4^2+y4^2+z4^2+w4^2   x4      y4      z4      w4      1 |
103  *      | x5^2+y5^2+z5^2+w5^2   x5      y5      z5      w5      1 |
104  */
105 if ((w0*(-x1*(-y2*(-z4*(z5^2+y5^2+x5^2+w5^2)
106     -z3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2) +
107     (z4^2+y4^2+x4^2+w4^2)*z5+ (z3^2+y3^2+x3^2+w3^2)*(z4-z5))
108     +y3*((z4^2+y4^2+x4^2+w4^2)*z5-z4*(z5^2+y5^2+x5^2+w5^2))
109     +z2*(-y4*(z5^2+y5^2+x5^2+w5^2)
110     -y3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2)
111     +y5*(z4^2+y4^2+x4^2+w4^2) + (y4-y5)*(z3^2+y3^2+x3^2+w3^2))
112     -z3*(y5*(z4^2+y4^2+x4^2+w4^2) -y4*(z5^2+y5^2+x5^2+w5^2)) +
113     (z2^2+y2^2+x2^2+w2^2)*(y4*z5+y3*(z4-z5) -y5*z4- (y4-y5)*z3) -
114     (z3^2+y3^2+x3^2+w3^2)*(y4*z5-y5*z4)) +y1*(-x2*(-z4*(z5^2+y5^2+x5^2+w5^2)
115     -z3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2) +
116     (z4^2+y4^2+x4^2+w4^2)*z5+ (z3^2+y3^2+x3^2+w3^2)*(z4-z5))
117     +x3*((z4^2+y4^2+x4^2+w4^2)*z5-z4*(z5^2+y5^2+x5^2+w5^2))
118     +z2*(-x4*(z5^2+y5^2+x5^2+w5^2)
119     -x3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2) +x5*(z4^2+y4^2+x4^2+w4^2)
120     + (x4-x5)*(z3^2+y3^2+x3^2+w3^2)) -z3*(x5*(z4^2+y4^2+x4^2+w4^2)
121     -x4*(z5^2+y5^2+x5^2+w5^2)) + (z2^2+y2^2+x2^2+w2^2)*(x4*z5+x3*(z4-z5)
122     -x5*z4- (x4-x5)*z3) - (z3^2+y3^2+x3^2+w3^2)*(x4*z5-x5*z4))
123     -x2*(-y3*((z4^2+y4^2+x4^2+w4^2)*z5-z4*(z5^2+y5^2+x5^2+w5^2))
124     +z3*(y5*(z4^2+y4^2+x4^2+w4^2) -y4*(z5^2+y5^2+x5^2+w5^2))
125     + (z3^2+y3^2+x3^2+w3^2)*(y4*z5-y5*z4))
126     +y2*(-x3*((z4^2+y4^2+x4^2+w4^2)*z5-z4*(z5^2+y5^2+x5^2+w5^2))
127     +z3*(x5*(z4^2+y4^2+x4^2+w4^2) -x4*(z5^2+y5^2+x5^2+w5^2)) +
128     (z3^2+y3^2+x3^2+w3^2)*(x4*z5-x5*z4)) -z1*(-x2*(-y4*(z5^2+y5^2+x5^2+w5^2)
129     -y3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2) +y5*(z4^2+y4^2+x4^2+w4^2)
130     + (y4-y5)*(z3^2+y3^2+x3^2+w3^2)) +x3*(y5*(z4^2+y4^2+x4^2+w4^2)
131     -y4*(z5^2+y5^2+x5^2+w5^2)) +y2*(-x4*(z5^2+y5^2+x5^2+w5^2)
132     -x3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2)
133     +x5*(z4^2+y4^2+x4^2+w4^2) + (x4-x5)*(z3^2+y3^2+x3^2+w3^2))
134     -y3*(x5*(z4^2+y4^2+x4^2+w4^2) -x4*(z5^2+y5^2+x5^2+w5^2)) -
135     (x4*y5-x5*y4)*(z3^2+y3^2+x3^2+w3^2) + (x4*y5+x3*(y4-y5) -x5*y4-
136     (x4-x5)*y3)*(z2^2+y2^2+x2^2+w2^2)) -z2*(-x3*(y5*(z4^2+y4^2+x4^2+w4^2)
137     -y4*(z5^2+y5^2+x5^2+w5^2)) +y3*(x5*(z4^2+y4^2+x4^2+w4^2)
138     -x4*(z5^2+y5^2+x5^2+w5^2)) + (x4*y5-x5*y4)*(z3^2+y3^2+x3^2+w3^2))
139     + (z1^2+y1^2+x1^2+w1^2)*(x2*(y4*z5+y3*(z4-z5) -y5*z4-
140     (y4-y5)*z3) -x3*(y4*z5-y5*z4) -y2*(x4*z5+x3*(z4-z5) -x5*z4-
141     (x4-x5)*z3) +y3*(x4*z5-x5*z4) - (x4*y5-x5*y4)*z3+
142     (x4*y5+x3*(y4-y5) -x5*y4- (x4-x5)*y3)*z2) +
143     (z2^2+y2^2+x2^2+w2^2)*(x3*(y4*z5-y5*z4) -y3*(x4*z5-x5*z4) +
144     (x4*y5-x5*y4)*z3)) -x0*(-w1*(-y2*(-z4*(z5^2+y5^2+x5^2+w5^2)
145     -z3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2) +
146     (z4^2+y4^2+x4^2+w4^2)*z5+ (z3^2+y3^2+x3^2+w3^2)*(z4-z5))
147     +y3*((z4^2+y4^2+x4^2+w4^2)*z5-z4*(z5^2+y5^2+x5^2+w5^2))
148     +z2*(-y4*(z5^2+y5^2+x5^2+w5^2)
149     -y3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2)
150     +y5*(z4^2+y4^2+x4^2+w4^2) + (y4-y5)*(z3^2+y3^2+x3^2+w3^2))
151     -z3*(y5*(z4^2+y4^2+x4^2+w4^2) -y4*(z5^2+y5^2+x5^2+w5^2)) +
152     (z2^2+y2^2+x2^2+w2^2)*(y4*z5+y3*(z4-z5) -y5*z4- (y4-y5)*z3) -
153     (z3^2+y3^2+x3^2+w3^2)*(y4*z5-y5*z4)) -y1*(w2*(-z4*(z5^2+y5^2+x5^2+w5^2)
154     -z3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2) +
155     (z4^2+y4^2+x4^2+w4^2)*z5+ (z3^2+y3^2+x3^2+w3^2)*(z4-z5))
156     -w3*((z4^2+y4^2+x4^2+w4^2)*z5-z4*(z5^2+y5^2+x5^2+w5^2))
157     -z2*(-w4*(z5^2+y5^2+x5^2+w5^2)
158     -w3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2) +w5*(z4^2+y4^2+x4^2+w4^2)
159     + (w4-w5)*(z3^2+y3^2+x3^2+w3^2)) +z3*(w5*(z4^2+y4^2+x4^2+w4^2)
160     -w4*(z5^2+y5^2+x5^2+w5^2)) + (z2^2+y2^2+x2^2+w2^2)*(-w4*z5-w3*(z4-z5)
161     +w5*z4+ (w4-w5)*z3) - (z3^2+y3^2+x3^2+w3^2)*(w5*z4-w4*z5))
162     -w2*(-y3*((z4^2+y4^2+x4^2+w4^2)*z5-z4*(z5^2+y5^2+x5^2+w5^2))
163     +z3*(y5*(z4^2+y4^2+x4^2+w4^2) -y4*(z5^2+y5^2+x5^2+w5^2))
164     + (z3^2+y3^2+x3^2+w3^2)*(y4*z5-y5*z4))
165     -y2*(w3*((z4^2+y4^2+x4^2+w4^2)*z5-z4*(z5^2+y5^2+x5^2+w5^2))
166     -z3*(w5*(z4^2+y4^2+x4^2+w4^2) -w4*(z5^2+y5^2+x5^2+w5^2)) +
167     (z3^2+y3^2+x3^2+w3^2)*(w5*z4-w4*z5)) +z1*(w2*(-y4*(z5^2+y5^2+x5^2+w5^2)
168     -y3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2) +y5*(z4^2+y4^2+x4^2+w4^2)
169     + (y4-y5)*(z3^2+y3^2+x3^2+w3^2)) -w3*(y5*(z4^2+y4^2+x4^2+w4^2)
170     -y4*(z5^2+y5^2+x5^2+w5^2)) -y2*(-w4*(z5^2+y5^2+x5^2+w5^2)
171     -w3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2)
172     +w5*(z4^2+y4^2+x4^2+w4^2) + (w4-w5)*(z3^2+y3^2+x3^2+w3^2))
173     +y3*(w5*(z4^2+y4^2+x4^2+w4^2) -w4*(z5^2+y5^2+x5^2+w5^2)) -
174     (w5*y4-w4*y5)*(z3^2+y3^2+x3^2+w3^2) + (-w4*y5-w3*(y4-y5) +w5*y4+
175     (w4-w5)*y3)*(z2^2+y2^2+x2^2+w2^2)) +z2*(w3*(y5*(z4^2+y4^2+x4^2+w4^2)
176     -y4*(z5^2+y5^2+x5^2+w5^2)) -y3*(w5*(z4^2+y4^2+x4^2+w4^2)
177     -w4*(z5^2+y5^2+x5^2+w5^2)) + (w5*y4-w4*y5)*(z3^2+y3^2+x3^2+w3^2))
178     + (z1^2+y1^2+x1^2+w1^2)*(w2*(y4*z5+y3*(z4-z5) -y5*z4-
179     (y4-y5)*z3) -w3*(y4*z5-y5*z4) +y2*(-w4*z5-w3*(z4-z5)
180     +w5*z4+ (w4-w5)*z3) -y3*(w5*z4-w4*z5) + (w5*y4-w4*y5)*z3-
181     (-w4*y5-w3*(y4-y5) +w5*y4+ (w4-w5)*y3)*z2) +
182     (z2^2+y2^2+x2^2+w2^2)*(w3*(y4*z5-y5*z4) +y3*(w5*z4-w4*z5) -
183     (w5*y4-w4*y5)*z3)) +y0*(-w1*(-x2*(-z4*(z5^2+y5^2+x5^2+w5^2)
184     -z3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2) +
185     (z4^2+y4^2+x4^2+w4^2)*z5+ (z3^2+y3^2+x3^2+w3^2)*(z4-z5))
186     +x3*((z4^2+y4^2+x4^2+w4^2)*z5-z4*(z5^2+y5^2+x5^2+w5^2))
187     +z2*(-x4*(z5^2+y5^2+x5^2+w5^2)
188     -x3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2)
189     +x5*(z4^2+y4^2+x4^2+w4^2) + (x4-x5)*(z3^2+y3^2+x3^2+w3^2))
190     -z3*(x5*(z4^2+y4^2+x4^2+w4^2) -x4*(z5^2+y5^2+x5^2+w5^2)) +
191     (z2^2+y2^2+x2^2+w2^2)*(x4*z5+x3*(z4-z5) -x5*z4- (x4-x5)*z3) -
192     (z3^2+y3^2+x3^2+w3^2)*(x4*z5-x5*z4)) -x1*(w2*(-z4*(z5^2+y5^2+x5^2+w5^2)
193     -z3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2) +
194     (z4^2+y4^2+x4^2+w4^2)*z5+ (z3^2+y3^2+x3^2+w3^2)*(z4-z5))
195     -w3*((z4^2+y4^2+x4^2+w4^2)*z5-z4*(z5^2+y5^2+x5^2+w5^2))
196     -z2*(-w4*(z5^2+y5^2+x5^2+w5^2)
197     -w3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2) +w5*(z4^2+y4^2+x4^2+w4^2)
198     + (w4-w5)*(z3^2+y3^2+x3^2+w3^2)) +z3*(w5*(z4^2+y4^2+x4^2+w4^2)
199     -w4*(z5^2+y5^2+x5^2+w5^2)) + (z2^2+y2^2+x2^2+w2^2)*(-w4*z5-w3*(z4-z5)
200     +w5*z4+ (w4-w5)*z3) - (z3^2+y3^2+x3^2+w3^2)*(w5*z4-w4*z5))
201     -w2*(-x3*((z4^2+y4^2+x4^2+w4^2)*z5-z4*(z5^2+y5^2+x5^2+w5^2))
202     +z3*(x5*(z4^2+y4^2+x4^2+w4^2) -x4*(z5^2+y5^2+x5^2+w5^2))
203     + (z3^2+y3^2+x3^2+w3^2)*(x4*z5-x5*z4))
204     -x2*(w3*((z4^2+y4^2+x4^2+w4^2)*z5-z4*(z5^2+y5^2+x5^2+w5^2))
205     -z3*(w5*(z4^2+y4^2+x4^2+w4^2) -w4*(z5^2+y5^2+x5^2+w5^2)) +
206     (z3^2+y3^2+x3^2+w3^2)*(w5*z4-w4*z5)) +z1*(w2*(-x4*(z5^2+y5^2+x5^2+w5^2)
207     -x3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2) +x5*(z4^2+y4^2+x4^2+w4^2)
208     + (x4-x5)*(z3^2+y3^2+x3^2+w3^2)) -w3*(x5*(z4^2+y4^2+x4^2+w4^2)
209     -x4*(z5^2+y5^2+x5^2+w5^2)) -x2*(-w4*(z5^2+y5^2+x5^2+w5^2)
210     -w3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2)
211     +w5*(z4^2+y4^2+x4^2+w4^2) + (w4-w5)*(z3^2+y3^2+x3^2+w3^2))
212     +x3*(w5*(z4^2+y4^2+x4^2+w4^2) -w4*(z5^2+y5^2+x5^2+w5^2)) -
213     (w5*x4-w4*x5)*(z3^2+y3^2+x3^2+w3^2) + (-w4*x5-w3*(x4-x5) +w5*x4+
214     (w4-w5)*x3)*(z2^2+y2^2+x2^2+w2^2)) +z2*(w3*(x5*(z4^2+y4^2+x4^2+w4^2)
215     -x4*(z5^2+y5^2+x5^2+w5^2)) -x3*(w5*(z4^2+y4^2+x4^2+w4^2)
216     -w4*(z5^2+y5^2+x5^2+w5^2)) + (w5*x4-w4*x5)*(z3^2+y3^2+x3^2+w3^2)) +
217     (z1^2+y1^2+x1^2+w1^2)*(w2*(x4*z5+x3*(z4-z5) -x5*z4- (x4-x5)*z3)
218     -w3*(x4*z5-x5*z4) +x2*(-w4*z5-w3*(z4-z5) +w5*z4+ (w4-w5)*z3)
219     -x3*(w5*z4-w4*z5) + (w5*x4-w4*x5)*z3- (-w4*x5-w3*(x4-x5) +w5*x4+
220     (w4-w5)*x3)*z2) + (z2^2+y2^2+x2^2+w2^2)*(w3*(x4*z5-x5*z4)
221     +x3*(w5*z4-w4*z5) - (w5*x4-w4*x5)*z3))
222     -w1*(-x2*(-y3*((z4^2+y4^2+x4^2+w4^2)*z5-z4*(z5^2+y5^2+x5^2+w5^2))
223     +z3*(y5*(z4^2+y4^2+x4^2+w4^2) -y4*(z5^2+y5^2+x5^2+w5^2))
224     + (z3^2+y3^2+x3^2+w3^2)*(y4*z5-y5*z4))
225     +y2*(-x3*((z4^2+y4^2+x4^2+w4^2)*z5-z4*(z5^2+y5^2+x5^2+w5^2))
226     +z3*(x5*(z4^2+y4^2+x4^2+w4^2) -x4*(z5^2+y5^2+x5^2+w5^2)) +
227     (z3^2+y3^2+x3^2+w3^2)*(x4*z5-x5*z4)) -z2*(-x3*(y5*(z4^2+y4^2+x4^2+w4^2)
228     -y4*(z5^2+y5^2+x5^2+w5^2)) +y3*(x5*(z4^2+y4^2+x4^2+w4^2)
229     -x4*(z5^2+y5^2+x5^2+w5^2)) + (x4*y5-x5*y4)*(z3^2+y3^2+x3^2+w3^2))
230     + (z2^2+y2^2+x2^2+w2^2)*(x3*(y4*z5-y5*z4)
231     -y3*(x4*z5-x5*z4) + (x4*y5-x5*y4)*z3))
232     +x1*(-w2*(-y3*((z4^2+y4^2+x4^2+w4^2)*z5-z4*(z5^2+y5^2+x5^2+w5^2))
233     +z3*(y5*(z4^2+y4^2+x4^2+w4^2) -y4*(z5^2+y5^2+x5^2+w5^2))
234     + (z3^2+y3^2+x3^2+w3^2)*(y4*z5-y5*z4))
235     -y2*(w3*((z4^2+y4^2+x4^2+w4^2)*z5-z4*(z5^2+y5^2+x5^2+w5^2))
236     -z3*(w5*(z4^2+y4^2+x4^2+w4^2) -w4*(z5^2+y5^2+x5^2+w5^2)) +
237     (z3^2+y3^2+x3^2+w3^2)*(w5*z4-w4*z5)) +z2*(w3*(y5*(z4^2+y4^2+x4^2+w4^2)
238     -y4*(z5^2+y5^2+x5^2+w5^2)) -y3*(w5*(z4^2+y4^2+x4^2+w4^2)
239     -w4*(z5^2+y5^2+x5^2+w5^2)) + (w5*y4-w4*y5)*(z3^2+y3^2+x3^2+w3^2))
240     + (z2^2+y2^2+x2^2+w2^2)*(w3*(y4*z5-y5*z4)
241     +y3*(w5*z4-w4*z5) - (w5*y4-w4*y5)*z3))
242     -y1*(-w2*(-x3*((z4^2+y4^2+x4^2+w4^2)*z5-z4*(z5^2+y5^2+x5^2+w5^2))
243     +z3*(x5*(z4^2+y4^2+x4^2+w4^2) -x4*(z5^2+y5^2+x5^2+w5^2))
244     + (z3^2+y3^2+x3^2+w3^2)*(x4*z5-x5*z4))
245     -x2*(w3*((z4^2+y4^2+x4^2+w4^2)*z5-z4*(z5^2+y5^2+x5^2+w5^2))
246     -z3*(w5*(z4^2+y4^2+x4^2+w4^2) -w4*(z5^2+y5^2+x5^2+w5^2)) +
247     (z3^2+y3^2+x3^2+w3^2)*(w5*z4-w4*z5)) +z2*(w3*(x5*(z4^2+y4^2+x4^2+w4^2)
248     -x4*(z5^2+y5^2+x5^2+w5^2)) -x3*(w5*(z4^2+y4^2+x4^2+w4^2)
249     -w4*(z5^2+y5^2+x5^2+w5^2)) + (w5*x4-w4*x5)*(z3^2+y3^2+x3^2+w3^2))
250     + (z2^2+y2^2+x2^2+w2^2)*(w3*(x4*z5-x5*z4) +x3*(w5*z4-w4*z5)
251     - (w5*x4-w4*x5)*z3)) -z0*(-w1*(-x2*(-y4*(z5^2+y5^2+x5^2+w5^2)
252     -y3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2) +y5*(z4^2+y4^2+x4^2+w4^2)
253     + (y4-y5)*(z3^2+y3^2+x3^2+w3^2)) +x3*(y5*(z4^2+y4^2+x4^2+w4^2)
254     -y4*(z5^2+y5^2+x5^2+w5^2)) +y2*(-x4*(z5^2+y5^2+x5^2+w5^2)
255     -x3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2)
256     +x5*(z4^2+y4^2+x4^2+w4^2) + (x4-x5)*(z3^2+y3^2+x3^2+w3^2))
257     -y3*(x5*(z4^2+y4^2+x4^2+w4^2) -x4*(z5^2+y5^2+x5^2+w5^2)) -
258     (x4*y5-x5*y4)*(z3^2+y3^2+x3^2+w3^2) + (x4*y5+x3*(y4-y5) -x5*y4-
259     (x4-x5)*y3)*(z2^2+y2^2+x2^2+w2^2)) -x1*(w2*(-y4*(z5^2+y5^2+x5^2+w5^2)
260     -y3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2) +y5*(z4^2+y4^2+x4^2+w4^2)
261     + (y4-y5)*(z3^2+y3^2+x3^2+w3^2)) -w3*(y5*(z4^2+y4^2+x4^2+w4^2)
262     -y4*(z5^2+y5^2+x5^2+w5^2)) -y2*(-w4*(z5^2+y5^2+x5^2+w5^2)
263     -w3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2)
264     +w5*(z4^2+y4^2+x4^2+w4^2) + (w4-w5)*(z3^2+y3^2+x3^2+w3^2))
265     +y3*(w5*(z4^2+y4^2+x4^2+w4^2) -w4*(z5^2+y5^2+x5^2+w5^2)) -
266     (w5*y4-w4*y5)*(z3^2+y3^2+x3^2+w3^2) + (-w4*y5-w3*(y4-y5) +w5*y4+
267     (w4-w5)*y3)*(z2^2+y2^2+x2^2+w2^2)) -w2*(-x3*(y5*(z4^2+y4^2+x4^2+w4^2)
268     -y4*(z5^2+y5^2+x5^2+w5^2)) +y3*(x5*(z4^2+y4^2+x4^2+w4^2)
269     -x4*(z5^2+y5^2+x5^2+w5^2)) + (x4*y5-x5*y4)*(z3^2+y3^2+x3^2+w3^2))
270     -x2*(w3*(y5*(z4^2+y4^2+x4^2+w4^2) -y4*(z5^2+y5^2+x5^2+w5^2))
271     -y3*(w5*(z4^2+y4^2+x4^2+w4^2) -w4*(z5^2+y5^2+x5^2+w5^2)) +
272     (w5*y4-w4*y5)*(z3^2+y3^2+x3^2+w3^2)) +y1*(w2*(-x4*(z5^2+y5^2+x5^2+w5^2)
273     -x3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2) +x5*(z4^2+y4^2+x4^2+w4^2)
274     + (x4-x5)*(z3^2+y3^2+x3^2+w3^2)) -w3*(x5*(z4^2+y4^2+x4^2+w4^2)
275     -x4*(z5^2+y5^2+x5^2+w5^2)) -x2*(-w4*(z5^2+y5^2+x5^2+w5^2)
276     -w3*(-z5^2+z4^2-y5^2+y4^2-x5^2+x4^2-w5^2+w4^2) +w5*(z4^2+y4^2+x4^2+w4^2)
277     + (w4-w5)*(z3^2+y3^2+x3^2+w3^2)) +x3*(w5*(z4^2+y4^2+x4^2+w4^2)
278     -w4*(z5^2+y5^2+x5^2+w5^2)) - (w5*x4-w4*x5)*(z3^2+y3^2+x3^2+w3^2)
279     + (-w4*x5-w3*(x4-x5) +w5*x4+ (w4-w5)*x3)*(z2^2+y2^2+x2^2+w2^2))
280     +y2*(w3*(x5*(z4^2+y4^2+x4^2+w4^2) -x4*(z5^2+y5^2+x5^2+w5^2))
281     -x3*(w5*(z4^2+y4^2+x4^2+w4^2) -w4*(z5^2+y5^2+x5^2+w5^2)) +
282     (w5*x4-w4*x5)*(z3^2+y3^2+x3^2+w3^2)) + (w3*(x4*y5-x5*y4) +x3*(w5*y4-w4*y5)
283     - (w5*x4-w4*x5)*y3)*(z2^2+y2^2+x2^2+w2^2) + (w2*(x4*y5+x3*(y4-y5)
284     -x5*y4- (x4-x5)*y3) -w3*(x4*y5-x5*y4) +x2*(-w4*y5-w3*(y4-y5)
285     +w5*y4+ (w4-w5)*y3) -x3*(w5*y4-w4*y5) + (w5*x4-w4*x5)*y3-
286     (-w4*x5-w3*(x4-x5) +w5*x4+ (w4-w5)*x3)*y2)*(z1^2+y1^2+x1^2+w1^2))
287     +z1*(-w2*(-x3*(y5*(z4^2+y4^2+x4^2+w4^2) -y4*(z5^2+y5^2+x5^2+w5^2))
288     +y3*(x5*(z4^2+y4^2+x4^2+w4^2) -x4*(z5^2+y5^2+x5^2+w5^2)) +
289     (x4*y5-x5*y4)*(z3^2+y3^2+x3^2+w3^2)) -x2*(w3*(y5*(z4^2+y4^2+x4^2+w4^2)
290     -y4*(z5^2+y5^2+x5^2+w5^2)) -y3*(w5*(z4^2+y4^2+x4^2+w4^2)
291     -w4*(z5^2+y5^2+x5^2+w5^2)) + (w5*y4-w4*y5)*(z3^2+y3^2+x3^2+w3^2))
292     +y2*(w3*(x5*(z4^2+y4^2+x4^2+w4^2) -x4*(z5^2+y5^2+x5^2+w5^2))
293     -x3*(w5*(z4^2+y4^2+x4^2+w4^2) -w4*(z5^2+y5^2+x5^2+w5^2)) +
294     (w5*x4-w4*x5)*(z3^2+y3^2+x3^2+w3^2)) + (w3*(x4*y5-x5*y4)
295     +x3*(w5*y4-w4*y5) - (w5*x4-w4*x5)*y3)*(z2^2+y2^2+x2^2+w2^2)) +
296     (z0^2+y0^2+x0^2+w0^2)*(-w1*(x2*(y4*z5+y3*(z4-z5) -y5*z4- (y4-y5)*z3)
297     -x3*(y4*z5-y5*z4) -y2*(x4*z5+x3*(z4-z5) -x5*z4- (x4-x5)*z3)
298     +y3*(x4*z5-x5*z4) - (x4*y5-x5*y4)*z3+ (x4*y5+x3*(y4-y5) -x5*y4-
299     (x4-x5)*y3)*z2) +x1*(w2*(y4*z5+y3*(z4-z5) -y5*z4- (y4-y5)*z3)
300     -w3*(y4*z5-y5*z4) +y2*(-w4*z5-w3*(z4-z5) +w5*z4+ (w4-w5)*z3)
301     -y3*(w5*z4-w4*z5) + (w5*y4-w4*y5)*z3- (-w4*y5-w3*(y4-y5) +w5*y4+
302     (w4-w5)*y3)*z2) -w2*(x3*(y4*z5-y5*z4) -y3*(x4*z5-x5*z4) +
303     (x4*y5-x5*y4)*z3) +x2*(w3*(y4*z5-y5*z4) +y3*(w5*z4-w4*z5) -
304     (w5*y4-w4*y5)*z3) -y1*(w2*(x4*z5+x3*(z4-z5) -x5*z4- (x4-x5)*z3)
305     -w3*(x4*z5-x5*z4) +x2*(-w4*z5-w3*(z4-z5) +w5*z4+ (w4-w5)*z3)
306     -x3*(w5*z4-w4*z5) + (w5*x4-w4*x5)*z3- (-w4*x5-w3*(x4-x5) +w5*x4+
307     (w4-w5)*x3)*z2) -y2*(w3*(x4*z5-x5*z4) +x3*(w5*z4-w4*z5) -
308     (w5*x4-w4*x5)*z3) + (w3*(x4*y5-x5*y4) +x3*(w5*y4-w4*y5) -
309     (w5*x4-w4*x5)*y3)*z2+ (w2*(x4*y5+x3*(y4-y5) -x5*y4- (x4-x5)*y3)
310     -w3*(x4*y5-x5*y4) +x2*(-w4*y5-w3*(y4-y5) +w5*y4+ (w4-w5)*y3)
311     -x3*(w5*y4-w4*y5) + (w5*x4-w4*x5)*y3- (-w4*x5-w3*(x4-x5) +w5*x4+
312     (w4-w5)*x3)*y2)*z1) - (z1^2+y1^2+x1^2+w1^2)*(-w2*(x3*(y4*z5-y5*z4)
313     -y3*(x4*z5-x5*z4) + (x4*y5-x5*y4)*z3) +x2*(w3*(y4*z5-y5*z4)
314     +y3*(w5*z4-w4*z5) - (w5*y4-w4*y5)*z3) -y2*(w3*(x4*z5-x5*z4)
315     +x3*(w5*z4-w4*z5) - (w5*x4-w4*x5)*z3) + (w3*(x4*y5-x5*y4)
316     +x3*(w5*y4-w4*y5) - (w5*x4-w4*x5)*y3)*z2)) == 0) {
317     print "are in the surface of a 4D sphere";
318 } else {
319     print "are NOT on a 4D sphere surface";