Buam / nolimits2-csv-exporter

CSV exporter for NoLimits 2: https://www.nolimitscoaster.com
5 stars 3 forks source link

Issue with scientific notation for small numbers incl. workaround #7

Open tijssen opened 1 year ago

tijssen commented 1 year ago

Hi Buam,

First of all, thanks a lot for sharing! The tool works great.

The issue: See for instance this line from some arbitrary output, which contains invalid characters:

335 -31.8093 30.3035 -23.1769 0 0 0 0.7943 0.4254 -0.4336 -0.0234 -0.9997 -6.53E-

Clearly, UpY is approximately equal to one, and since the Up-vector is normalized, UpX and UpZ should be small/approximately equal to zero. Indeed, UpX = -0.0234, which is small, but then UpZ = -6.53E-... I figure it should say UpZ = -6.53E-3, but the final 3 is being cut off while writing the file.

Consider also this line, which doesn't contain any invalid characters:

65 71.0326 7.7918 18.6999 0 0 0 0.7017 0.5541 -0.4477 0.1440 -0.9895 -9.4383

Even though there are no invalid characters, clearly there's still something wrong, because UpZ is larger than one, and hence the Up-vector cannot be normalized. In this case, I figure that the entire trailing E-3 is being cut off. I believe this is exactly what causes issue https://github.com/Buam/nolimits2-csv-exporter/issues/4.

The workaround: First clone my repo, https://github.com/tijssen/pycoaster. You will need SciPy and NumPy installed. Then copy the csv file in question into the pycoaster/-directory. Now create a Python file (e.g., test.py), in the same directory, and copy-paste the following (replace filename with the actual name of the csv file) and run it. It is also possible to increase/decrease the spacing between the vertices in the new file (using interpolation). If you're interested in this, let me know.

from pycoaster.curve import NoLimitsCurve

fname = "filename"

ga = NoLimitsCurve(fname + ".csv")
ga.save(fname + "_new.csv")

Tadaa, your csv is fixed!

crixtt commented 1 year ago

When I try to run the python file, it says, "from pycoaster.curve import NoLimitsCurve ModuleNotFoundError: No module named 'pycoaster'". How do I fix this?

tijssen commented 1 year ago

Hi there, make sure your folder structure is as follows:

pycoaster/
    pycoaster/
        __init__.py
        ...
    script.py

I.e., place your script inside the top-level folder. Then make sure you run the script from inside the top-level directory:

cd pycoaster
python3 script.py

Hope this helps.