Using Nodeeditor and Python to process points from MoI
The purpose of these outline notes is to apply Python complex number math functions to the x and y coordinates of 2d, or 3d, points in the MoI top view. In this case, the z coordinates of the points are either ignored, or zero, but may be used in some other situation. The z value is included for future flexibility. The x values are real, and the y values are real, but are treated as imaginary. Complex number z = x + i*y.
Initial MoI geometry is a network, IntegrationDomain, of a score or so planar curves in the xy plane. Nodeeditor will be used. A new node, which incorporates modified LineWeb style code, will be used to array numerous points on each successive curve. A new node, SavePoint4.js, modeled on the MoI SavePoint script, will export the point coordinates to a CSV1 style text file, with a certain delimiter. The CSV1 file will have a typical CSV format. Each line is a list of 3 coordinates, and curveIndex, for one point. Format: x, y, z, cIdx where x, y, and z are real numbers, and cIdx is an integer which indexes each parent curve, and the new curves to be created later.
Next, in a separate Python program, ComplexTransformMap.py, will import the CSV1 file. Complex number functions in cMath, NumPy, and SciPy will be used.
For each curve index, the x and y values will be converted to the complex number class, essentially an (x, y) pair representing the complex number x + i*y. The appropriate complex number math will be applied to each (x, y) to create a new 3d point, (X, Y, Z, cIdx). Python will then Save (output) all of the (X, Y, Z, cIdx) points to a new CSV2 file, PatchPointNetwork, consisting of the same number of network curves to be created from the new points.
Next, in a separate node program, PatchProcessor, will import CSV2, with node CSV_File4, based upon Karstens Import/CSV_File node, converting the (X, Y, Z) points with matching curve index, into a new curve. All of the new curves will be a new network of curves, PatchNetwork. MoI Network command will be applied, to generate a surface Patch. Then Mirror and Symmetry operations are applied to the surface Patch, to generate the final result.
The hardest part is learning enough Python to write a short Python program.
Google search of "python csv import" yields lots of hits, as does "python csv export".
- Brian
|