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 {
42 for (MicroDataPoint point : data.points()) {
43 landed_height = point.height;
44 landed_time = point.time;
47 boolean above = false;
48 for (MicroDataPoint point : data.points()) {
49 if (point.height > landed_height + 10) {
52 if (above && point.height < landed_height + 2) {
54 landed_time = point.time;
64 for (MicroDataPoint point : data.points()) {
65 if (point.height > apogee_height) {
66 apogee_height = point.height;
67 apogee_time = point.time;
76 for (MicroDataPoint point : data.points()) {
77 if (point.accel < -9.8)
79 coast_time = point.time;
80 coast_height = point.height;
84 void find_max_speed() {
86 for (MicroDataPoint point : data.points()) {
87 if (point.time > apogee_time)
89 if (point.speed > max_speed)
90 max_speed = point.speed;
94 void find_max_accel() {
96 for (MicroDataPoint point : data.points()) {
97 if (point.time > apogee_time)
99 if (point.accel > max_accel)
100 max_accel = point.accel;
104 double boost_duration() {
108 double boost_height() {
112 double boost_speed() {
113 return coast_height / coast_time;
116 double boost_accel() {
117 return boost_speed() / boost_duration();
120 double coast_duration() {
121 return apogee_time - coast_time;
124 double coast_height() {
125 return apogee_height - coast_height;
128 double coast_speed() {
129 return coast_height() / coast_duration();
132 double coast_accel() {
133 return coast_speed() / coast_duration();
136 double descent_duration() {
137 return landed_time - apogee_time;
140 double descent_height() {
141 return apogee_height - landed_height;
144 double descent_speed() {
145 return descent_height() / descent_duration();
148 public MicroStats(MicroData data) {
159 public MicroStats() {
160 this(new MicroData());