#!/usr/bin/python3 """ a simple script to take in airfoil data from http://airfoiltools.com and convert it into inch data points which could be put into a CAD program. use like so: python convert-airfoil.py airfoil.dat 45 where airfoil.dat is the file full of airfoil points, and 45 is the number of inches (or whatever unit, this script is units-agnostic) you want the chord-line to be. """ import sys def read_points(filename): """ open up filename and read in the data points """ data = [] with open(filename) as fp: filedata = fp.readlines() for line in filedata: x, y = line.split() data.append((x,y)) return data def scale_data(data, length): """ scale up all our data to the requested length """ scaled_data = [] for item in data: new_x = float(item[0]) * float(length) new_y = float(item[1]) * float(length) scaled_data.append((new_x, new_y)) return scaled_data def main(): data = read_points(sys.argv[1]) scaled_data = scale_data(data, sys.argv[2]) for item in scaled_data: print('x: {}, y: {}'.format(item[0], item[1])) if __name__ == '__main__': main()