1 /* Copyright (C) 1992-1998 The Geometry Center
2 * Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips
3 *
4 * This file is part of Geomview.
5 *
6 * Geomview is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * Geomview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Geomview; see the file COPYING. If not, write
18 * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
19 * USA, or visit http://www.gnu.org.
20 */
21
22 #if HAVE_CONFIG_H
23 # include "config.h"
24 #endif
25
26 #if 0
27 static char copyright[] = "Copyright (C) 1992-1998 The Geometry Center\n\
28 Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips";
29 #endif
30
31 /* routines for making sure matrix is orthogonal in Minkowski metric */
32 #include "3d.h"
33
34 /* row-orthogonalize an isometry of Minkowski space */
35 void
tuneup(Transform m1,int metric)36 tuneup(Transform m1, int metric)
37 {
38
39 HPt3SpaceNormalize((HPoint3 *)m1[0], metric);
40
41 HPt3SpaceGramSchmidt((HPoint3 *)m1[0], (HPoint3 *)m1[1], metric);
42 HPt3SpaceNormalize((HPoint3 *)m1[1], metric);
43
44 HPt3SpaceGramSchmidt((HPoint3 *)m1[0], (HPoint3 *)m1[2], metric);
45 HPt3SpaceGramSchmidt((HPoint3 *)m1[1], (HPoint3 *)m1[2], metric);
46 HPt3SpaceNormalize((HPoint3 *)m1[2], metric);
47
48 HPt3SpaceGramSchmidt((HPoint3 *)m1[0], (HPoint3 *)m1[3], metric);
49 HPt3SpaceGramSchmidt((HPoint3 *)m1[1], (HPoint3 *)m1[3], metric);
50 HPt3SpaceGramSchmidt((HPoint3 *)m1[2], (HPoint3 *)m1[3], metric);
51 HPt3SpaceNormalize((HPoint3 *)m1[3], metric);
52
53 }
54
55 /* following only works now with hyperbolic mode */
56 int
needstuneup(Transform m1)57 needstuneup(Transform m1)
58 {
59 int i,j;
60 float d;
61
62 for (i=0; i<4; ++i)
63 for (j=i; j<4; ++j)
64 {
65 d = m1[i][0] * m1[j][0] +
66 m1[i][1] * m1[j][1] +
67 m1[i][2] * m1[j][2] -
68 m1[i][3] * m1[j][3];
69 if (i == 3) d *= -1;
70 if (fabs ( d - ( i == j ) ) > .01 ) return (1);
71 }
72 return (0);
73 }
74