2 * Copyright © 2011 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
18 package org.altusmetrum.micropeak;
21 import org.altusmetrum.AltosLib.*;
22 import org.altusmetrum.altosuilib.*;
24 public class MicroStats {
43 for (double height : data.heights()) {
44 landed_height = height;
47 landed_time = data.time(t);
50 boolean above = false;
51 for (double height : data.heights()) {
52 if (height > landed_height + 10) {
55 if (above && height < landed_height + 2) {
57 landed_time = data.time(t);
69 for (double height : data.heights()) {
70 if (height > apogee_height) {
71 apogee_height = height;
72 apogee_time = data.time(t);
83 for (double accel : data.accels()) {
88 coast_time = data.time(t);
92 for (double height : data.heights()) {
94 coast_height = height;
101 void find_max_speed() {
104 for (double speed : data.speeds()) {
105 if (data.time(t) > apogee_time)
107 if (speed > max_speed)
113 void find_max_accel() {
117 for (double accel : data.accels()) {
118 if (data.time(t) > apogee_time)
120 if (accel > max_accel)
126 double boost_duration() {
130 double boost_height() {
134 double boost_speed() {
135 return coast_height / coast_time;
138 double boost_accel() {
139 return boost_speed() / boost_duration();
142 double coast_duration() {
143 return apogee_time - coast_time;
146 double coast_height() {
147 return apogee_height - coast_height;
150 double coast_speed() {
151 return coast_height() / coast_duration();
154 double coast_accel() {
155 return coast_speed() / coast_duration();
158 double descent_duration() {
159 return landed_time - apogee_time;
162 double descent_height() {
163 return apogee_height - landed_height;
166 double descent_speed() {
167 return descent_height() / descent_duration();
170 public MicroStats(MicroData data) {
181 public MicroStats() {
182 this(new MicroData());