{"id":29,"date":"2006-09-28T21:09:43","date_gmt":"2006-09-28T20:09:43","guid":{"rendered":"http:\/\/stuphi.co.uk\/wordpress\/?page_id=29"},"modified":"2006-10-01T09:47:56","modified_gmt":"2006-10-01T08:47:56","slug":"convert-script","status":"publish","type":"page","link":"https:\/\/stuphi.co.uk\/wordpress\/?page_id=29","title":{"rendered":"Convert Script"},"content":{"rendered":"<pre><code>#!\/usr\/bin\/perl\r\n\r\n# Open a file that contains x + y values of airfoil section\r\nopen F, \"\r\n\r\n# Read file into an array of lines. Chomp off the newline\r\nwhile (){\r\n  chomp;\r\n  push @a, $_;\r\n}\r\n\r\n# Open an output file for povray vertices's\r\nopen O, \">vertices.inc\" or die \"Could not open output file!\";\r\n\r\n# Based on the size of the array, calculate the number of\r\n# vertice vectors we are going to create and print to file\r\n$n = ($#a + 1)*2;\r\nprint O \"$n\";\r\n\r\n# Iterate the array and output section in Pov friendly vectors\r\n# This will be the root section\r\nfor $i (0 .. $#a){\r\n  ($x, $y) = split(' ', $a[$i]);\r\n  print O \",\\n<$x, $y, 0>\";\r\n}\r\n\r\n# Do it again, this time scale for tip section\r\nfor $i (0 .. $#a){\r\n  ($x, $y) = split(' ', $a[$i]);\r\n  $x = ($x * 0.5)+1.5;\r\n  $y = ($y * 0.5);\r\n  print O \",\\n<$x, $y, 2>\";\r\n}\r\n\r\n# Close our files\r\nclose F;\r\nclose O;\r\n\r\n# Open a new file for the faces\r\nopen O, \">faces.inc\" or die \"Could not open output file!\";\r\n$k1 = 0;\r\n\r\n# Number of faces based on number of vertices's, and print\r\n# to file.\r\n$o = $n-2;\r\nprint O \"$o\";\r\n\r\n# Create povray faces for use in mesh object\r\nwhile ($k1 < ($n\/2)-1){\r\n  $k2 = $k1+61;\r\n  $k3 = $k1+1;\r\n  $k4 = $k1+62;\r\n  print O \",\\n<$k1, $k2, $k3>\";\r\n  print O \",\\n<$k2, $k3, $k4>\";\r\n  $k1 = $k1+1;\r\n}\r\n\r\n# Close output file\r\nclose O;\r\n\r\n###########################################################\r\n#                   TODO\r\n# 1. Create end cap face\r\n# 2. Calculate Face normals and vertex normals\r\n#    so that smooth triangles can be used\r\n# 3. Generate a complete closed mesh so that it can\r\n#    be used in CSG's\r\n# 4. Add options to aid different sections to be created\r\n# 5. Add options for length, taper, sweep, washout, etc.\r\n# 6. Write in C\r\n# 7. Release under GPL\r\n#\r\n###########################################################<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#!\/usr\/bin\/perl # Open a file that contains x + y values of airfoil section open F, &#8221; # Read file into an array of lines. Chomp off the newline while (){ chomp; push @a, $_; } # Open an output &hellip; <a href=\"https:\/\/stuphi.co.uk\/wordpress\/?page_id=29\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":27,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/stuphi.co.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/29"}],"collection":[{"href":"https:\/\/stuphi.co.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/stuphi.co.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/stuphi.co.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stuphi.co.uk\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=29"}],"version-history":[{"count":0,"href":"https:\/\/stuphi.co.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/29\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/stuphi.co.uk\/wordpress\/index.php?rest_route=\/wp\/v2\/pages\/27"}],"wp:attachment":[{"href":"https:\/\/stuphi.co.uk\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=29"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}