File: balance.c

package info (click to toggle)
acm 5.0-23.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 8,364 kB
  • ctags: 4,793
  • sloc: ansic: 42,444; makefile: 706; cpp: 293; perl: 280; sh: 198
file content (144 lines) | stat: -rw-r--r-- 3,176 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include <math.h>
#include <stdio.h>
#include <Vlib.h>

#undef printf

/*
 *   ----------------  z = 0 in body coordinates
 *      ^
 *      |	r{m,n}.z	(constant)
 *      v
 *      o	gear attachment point
 *      ^
 *      |	c{m,n}.z	strut extension  (0 - c{m,n}Max)
 *      v
 *      ^
 *      |	G{m,n}		strut + tire length  (constant)
 *      v
 *   ----------------  ground
 *
 */


struct balance_data {
	double	weight;	/* weight for this test */
	VPoint	rm;	/* rest main gear ground contact point (input),
			   rest main gear attachment point (output) */
	VPoint	rn;	/* rest nose gear ground contact point (input),
			   rest nose gear attachment point (output) */
	double	cm, cn;	/* rest extension values of each strut */
	double	cmMax, cnMax;	/* maximum extension values of each strut */
	double	Gm, Gn; /* strut + tire lengths */
	double	Km, Kn;	/* string constants (output) */
	double  Gpz;	/* the old "grounding point" Z value */
	};

void
balance (s)
struct balance_data *s;
{

	double	theta, cosTheta, sinTheta;
	double	Fmz, Fnz;

/*
 *  Determine the rest pitch angle of the aircraft body
 */

	theta = - atan2 (s->rn.z - s->rm.z, s->rn.x - s->rm.x);
	cosTheta = cos(theta);
	sinTheta = sin(theta);

	printf ("Theta = %f degrees (positive down)\n", theta * 180.0 / M_PI);

/*
 *  Determine correct rm/rn values
 */
	s->rn.z = s->rn.z - s->Gn - s->cn;
	s->rm.z = s->rm.z - s->Gm - s->cm;

/*
 *  Determine spring constants
 */

	Fmz = (s->weight * s->rn.x) / (s->rn.x - s->rm.x);
	Fnz = s->weight - Fmz;

	s->Km = Fmz / (s->cmMax - s->cm);
	s->Kn = Fnz / (s->cnMax - s->cn);

/*
 *  Determine the initial grounding point
 */

	s->Gpz = s->rm.x * sinTheta + (s->rm.z + s->Gm + s->cm) * cosTheta;

}

main()
{

	struct balance_data s;

/*
 *  Wheel contact locations for the aircraft fully loaded at rest.
 */

	VSetPoint (s.rn, 4.1165, 0.0, 2.029);
	VSetPoint (s.rm, -0.3489, 4.0118, 2.0299);

/*
 *  Gross weight
 */

	s.weight = 1450 + 300;

/*
 *  Maximum oleo extension lengths
 */

	s.cnMax = 0.5;
	s.cmMax = 0.5;

/*
 *  The length of the wheel and lower landing gear strut
 */
	s.Gm = 1.0;
	s.Gn = 1.0;

/*
 *  Rest oleo extension; must be less than cnMax or cmMax; usually about
 *  half the max value.
 */

	s.cm = 0.20;
	s.cn = 0.25;

	printf ("Input:\n");
	printf ("nose   contact = %lf  %lf  %lf\n", s.rn.x, s.rn.y, s.rn.z);
	printf ("main's contact = %lf  %lf  %lf\n", s.rm.x, s.rm.y, s.rm.z);
	printf ("Weight = %lf\n", s.weight);

	balance(&s);

	printf ("\nOutput:\n");
	printf ("rm = %lf,  %lf,  %lf\n", s.rm.x, s.rm.y, s.rm.z);
	printf ("rn = %lf,  %lf,  %lf\n", s.rn.x, s.rn.y, s.rn.z);
	printf ("Km = %lf\n", s.Km);
	printf ("Kn = %lf\n", s.Kn);
	printf ("Grounding point (z) = %lf\n", s.Gpz);
	printf ("\n\"inventory\" form:\n\n");
	printf ("\tRm\t\t{%lg,  %lg,  %lg}\n", s.rm.x, s.rm.y, s.rm.z);
	printf ("\tRn\t\t{%lg,  %lg,  %lg}\n", s.rn.x, s.rn.y, s.rn.z);
	printf ("\tKm\t\t%lg\n", s.Km);
	printf ("\tKn\t\t%lg\n", s.Kn);
	printf ("\tGm\t\t%lg\n", s.Gm);
	printf ("\tGn\t\t%lg\n", s.Gn);
	printf ("\tCmMax\t\t%lg\n", s.cmMax);
	printf ("\tCnMax\t\t%lg\n", s.cnMax);
	printf ("\tGroundingPoint\t{0.0, 0.0, %lg}\n", s.Gpz);

	exit (0);
}