GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-bea8435a9e
ortho.c
Go to the documentation of this file.
1 /* ortho.c CCMATH mathematics library source code.
2  *
3  * Copyright (C) 2000 Daniel A. Atkinson All rights reserved.
4  * This code may be redistributed under the terms of the GNU library
5  * public license (LGPL). ( See the lgpl.license file for details.)
6  * ------------------------------------------------------------------------
7  */
8 #include "ccmath.h"
9 static double tpi = 6.28318530717958647;
10 
11 void ortho(double *e, int n)
12 {
13  int i, j, k, m;
14 
15  double *p, *q, c, s, a, unfl(void);
16 
17  for (i = 0, p = e; i < n; ++i) {
18  for (j = 0; j < n; ++j) {
19  if (i == j)
20  *p++ = 1.;
21  else
22  *p++ = 0.;
23  }
24  }
25  for (i = 0, m = n - 1; i < m; ++i) {
26  for (j = i + 1; j < n; ++j) {
27  a = tpi * unfl();
28  c = cos(a);
29  s = sin(a);
30  p = e + n * i;
31  q = e + n * j;
32  for (k = 0; k < n; ++k) {
33  a = *p * c + *q * s;
34  *q = *q * c - *p * s;
35  *p++ = a;
36  ++q;
37  }
38  }
39  }
40 }
void ortho(double *e, int n)
Definition: ortho.c:11
double unfl(void)
Definition: unfl.c:10