1 #!/usr/local/src/cmd/calc/calc -q -s -f
3 * 4dsphere - determine if 6 points lie on the surface of a sphere in R^4
6 * 4dsphere x0 y0 z0 w0 x1 y1 z1 w1 ... x5 y5 z5 w5
8 * x0 y0 z0 w0 point 0 in R^4
9 * x1 y1 z1 w1 point 1 in R^4
11 * x5 y5 z5 w5 point 5 in R^4
13 * Copyright (C) 2001 Landon Curt Noll
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.
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.
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.
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 $
33 * Under source code control: 2001/05/03 19:02:03
34 * File existed as early as: 2001
36 * chongo <was here> /\oo/\ http://www.isthe.com/chongo/
37 * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
45 fprintf(files(2), "usage: %s x0 y0 z0 w0 x1 y1 z1 w1 ... x5 y5 z5 w5\n",
75 * verbose output setup
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:") ":;
95 * we can determine if they lie in the surface of 4D sphere in R^4 if the
96 * following matrix is 0:
98 * | x0^2+y0^2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*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";
319 print "are NOT on a 4D sphere surface";