Closed Joe-Joe-Joe-Joe closed 2 months ago
See #7. It should implement the functionality here. However, I'm wondering - if all of the curves are quadratics, is it the most accurate to evaluate the quadratics first and then use linear interpolation? Finding some method to somehow interpolate between polynomials themselves may be useful, although I'm not sure if that is necessary.
Currently using my MTE201 linear interpolation code method for both drag and Cd calculation. What I would ideally like is the ability to pass an arbitrary number of curves (specified by polynomials), and interpolate between them based on the input reference area. As an example, the current code looks like this, for 3 curves at 0%, 50%, and 100%:
Calculate and correct drag from curves ` /**@return drag force value based on curves produced by Ansys at fixed extensions
/ private static double lookup_drag(double fixed_extension, double velocity) { double drag; //System.out.println("vel input to drag calc:" + velocity + "m/s"); if (Math.abs(fixed_extension) < tol) { drag = (0.0035 velocity velocity) + (0.1317 velocity) - 5.0119; } else if (Math.abs(fixed_extension - 0.5) < tol) { drag = (0.0045 velocity velocity) + (0.1031 velocity) - 3.8231; } else { // fixed_extension == 1 drag = (0.006 velocity velocity) + (0.1038 velocity) - 4.2522; }
}`
Interpolate between curve values `double dx = 0.5; double y_1; double y_2; double x_1; if (extension > 0.5) { x_1 = 0.5; y_1 = lookup_drag(0.5, velocity); y_2 = lookup_drag(1, velocity); } else { // extension < 0.5 x_1 = 0; y_1 = lookup_drag(0, velocity); y_2 = lookup_drag(0.5, velocity); } System.out.println("y1: " + y_1 + " y2:" + y_2); drag = y_1 + (y_2-y_1) / dx (extension - x_1); drag = air_density(altitude) rocket_area(extension) * drag;