getting rid of "e" in x,y,z coordinates

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
Old 01 January 2004   #1
getting rid of "e" in x,y,z coordinates

Wondering if someone could help me out with a Format problem. I'm printing out points to a file, but I don't want the exponential printed out. I've notice this occuring with very small numbers in Max. For example, [-86.6734,6.41911e-007,16.7711] where the y component in the list has an exponent. I was hoping there was some easy command to get rid of this exponent and force the number to print out in decimal form, but I haven't found anything. I was wondering if someone could point me in the right direction. Am I missing something big here?

I'm currently using a simple loop to decide if the number is smaller than a certain amount (let's say .00001 for example) if the number is smaller than that, then print out "0" in place of the exponential number.

if MyPoint.y < .00001 do
MyPoint.y = 0
print MyPoint.y

Surely, there must be an easier way than this. Or is everyone else using a loop to convert their exponential numbers. Anyone know of a way to completely convert without losing any precision in the exponential number given different exponential values. Say a function that takes [7.24311e-008, 6.41911e-007, 12] and converts to [0.000000724311, 0.00000641911, 12]. Any help would be greatly appreciated. Thanks.
Old 01 January 2004   #2
Why bother printing it out differently? You can read it back in fine like that, it makes it easier to read and it makes the file smaller.

You can have your characters photoreal, fast or cheap. Pick two.
Old 01 January 2004   #3
Hi playmesumch00ns. The output file isn't being read back into 3ds Max. The file is going to an external renderer. I'm using a renderman renderer. Far as I know, you can't put that 'e' in the rib file. That's why the exponential form has to be changed to a decimal form without the "e". Any ideas on how to do this?

Last edited by artistx : 01 January 2004 at 03:05 PM.
Old 01 January 2004   #4
What programming language/functions are you using to print the numbers?
Old 01 January 2004   #5
Hello Stew. I guess I should post in the Maxscript area. (it was a late night post and wasn't thinking too well).

I'm using the getKnotPoint function to grab the particular point that I need. Then I'm merely getting the nth component of the point(i.e. MyPoint.y). I'm using Maxscript's "Format" to output the x,y,z components of a point. I'm not using anything but Maxscript to work with the point data. Do others use additional languages as well to solve this exponent problem?

Last edited by artistx : 02 February 2004 at 04:50 AM.
Old 01 January 2004   #6
It's been a while since I worked with MaxScript, and I didn't touch "Format". However, what you need is to tell it to format the number with a fixed number of decimal points, that's how it works in most other languages. I had the exact same problem when writing an exporter in Python, and well, at least in Python it'd be "fpformat.fix(vert.Y(),8)" what creates a string representation of a float without exponential notation. I'm pretty confident that MaxScript has a similar function.
Old 01 January 2004   #7
Maxscript doesn't have any control over precision so everything is single point precision. For this reason I'm not sure it's really cut out for a rib exporter since you would probably in some cases prefer to deal with double precision. In most cases it may not make a difference though but it's something to keep in mind.
I would also just round these numbers to 0 as these near 0 numbers are typically 0 but return these numbers due to precision errors. Since there are no number formating methods inside maxscript itself you'll have to do the formating yourself. Although an extension may exist that will do this and if there is it would be worth using. To do it by hand you would have to first test to see if the value contains an e. This would work for extreamly tiny and extremely large numbers. But testing for an e would mean converting to a string which you don't want to do unless you have to b/c it's slow. So I would suggest that you look to see how many digits max will take before it changes the formatting and do < and > tests on numbers since that woudl be much faster than converting to a string and doing string operations. Once it passes that logical statement you'll need to convert the number to a string and use string operations to seperate the mantissa and exponent and then reconstruct the proper number with all the digits.
Old 01 January 2004   #8
Quote: Originally posted by RealThing
Since there are no number formating methods inside maxscript itself you'll have to do the formating yourself.

Is it just me or does using MaxScript really feel like this: ?
Old 01 January 2004   #9
Actually maxscript has alot more higher level functions compared to MEL. But if you factor in that most of the time you have an artist and not a TD using it often times it is like banging your head. Overall maxscript isn't too bad. I find it usefull anyhow.
Old 01 January 2004   #10
Last time I was using MaxScript, it really felt like a slap-on solution. None of the scripts I recorded with the script recorder would execute properly, they all required hand-editing. And many of the things I needed were poorly documented. Of course, I guess the fact that it's not as popular as MEL is one reason why there are not as many tutorials for it. And the problems I had with the LISP (?) syntax is nothing I could blame discreet for.
Old 02 February 2004   #11
Thank you so much RealThing for replying. You stated what I was afraid of, concerning the single/double precision issue. Like you said, it wouldn't make a big difference in most cases, but in really really really large or small scenes it could come into play. One of these days I'm just going to have to take time and learn the Max SDK. It didn't take me long to construct my cute little export script though, and I've always feared it would take double or triple the time to do similar things in C++ and the SDK. I guess I'll just stick to cutting off the extremely small values and converting them to zero or the maximum limit number (like you suggested).

Thanks for the code bit Stew. Even though it's in Python, it's a similar setup, that code gives me an idea on how to use a converter function in Maxscript.
Old 02 February 2004   #12
Most RIB files can have exponent format. In fact using Mtor I have often seen RIB files which have more precision than from MEL. I would definitely try it first - it might depend which renderer you are using. Exponent format is pretty standard.


Quote: Originally posted by artistx
Hi playmesumch00ns. The output file isn't being read back into 3ds Max. The file is going to an external renderer. I'm using a renderman renderer. Far as I know, you can't put that 'e' in the rib file. That's why the exponential form has to be changed to a decimal form without the "e". Any ideas on how to do this?
Old 02 February 2004   #13
Hello rendermaniac. Hmm. Perhaps I don't have to worry about converting after all. I didn't know exponential form was commonly acceptable for RIB files.
Old 02 February 2004   #14
I don't know if this has been answered, but the E denotes scientic notation. If you want to convert into the decimal place then you need to multiply the number to the left of the e by 10 to the power denoted by the number to the right of the e. This usually results in either a huge or super small number. So if you are writing a program to write the rib files it would be as simple as reading the text string and grabing everything to the left and right of the e and inserting them into variables and plugin them into the function to generate a decimal number.

I hope this helped, good luck.
"Game developers are like simple chemicals. (No, not because they're cheap and smelly.) In the right combination, they can make miracles. Screw up the mix, and you can blow up a city." - How to Screw Up a Perfectly Good Game Company in Ten Easy Steps,
Old 02 February 2004   #15
Thanks OC-NightHawk for replying. Yeah, I was also thinking along those lines. Build a function that:
1. finds the "e" in the number,
2. looks to see if there's a negative number (and acting appropriately),
3.grabbing the number(s) after e,
4. and finally inserting that number into a multiplication equation which then spits out the new number which is no longer in scientific notation.

Well, that's the general idea atleast.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 01:50 PM.

Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.