# short array to float(angles)

This topic is 2920 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi,

I'm trying to work out how to convert the angles of a joint in a skelton that is stored in 3 shorts.
I've done a little reading and have found out it is common for 3D assets to store some of the data in shorts to save disk space etc.

The shorts(int16) have the following values.

[font="Times New Roman"]-6967, -6967, -22097[/font] (x,y,z)

These values when converted to double should equal these values.

[font="Times New Roman"]-90.00, -90.00, -55.00 (x,y,z)[/font]

I tried just converting them from shorts to float using the following code:
 inline double expandToFloat(short input) { return ((double)input) * 1000 / 32,767; } 
Which did not work correct. So I did a little more research and have come to the conclusion it has something to do with: atan2
But I've not been able to work it out / find any examples that seam to work correct.

And no this is not homework, I'm writing a converter that converts a binary format to .ma (Maya acsii)

Any help on this would be great, from documentation on how to do this or pointing in the right direction.

Thx Tom. (sorry if wrong section)

##### Share on other sites
http://zunzun.com/ allows you to find a fitting function to your data, it's easy and browser based. I'm interested in why the conversion isn't linear .

##### Share on other sites
That site looks useful, but I have no clue as to what I'm looking for

##### Share on other sites
2D Functions -> Function Finder, Text Data Editor, enter short value [space] double value on each line.

##### Share on other sites

2D Functions -> Function Finder, Text Data Editor, enter short value [space] double value on each line.

arr yer I get it, great website !

But as I'm looking for the x,y,z rotation of a joint should I not be looking in 3D functions ?

I tried my data with both 2D & 3D but didnt see any that came out correct.

Thanks for the help so far.

##### Share on other sites

[quote name='Mussi' timestamp='1319470186' post='4876332']
2D Functions -> Function Finder, Text Data Editor, enter short value [space] double value on each line.

arr yer I get it, great website !

But as I'm looking for the x,y,z rotation of a joint should I not be looking in 3D functions ?

I tried my data with both 2D & 3D but didnt see any that came out correct.

Thanks for the help so far.
[/quote]

You're looking for a relation between a short angle representation and a double angle representation. double = Func(short), so that's 2D, unless the value of a single component is derived from multiple components. Could you maybe post some more data points?

Also, where is this binary data coming from?

##### Share on other sites

[quote name='The Vaseline Slug' timestamp='1319478405' post='4876375']
[quote name='Mussi' timestamp='1319470186' post='4876332']
2D Functions -> Function Finder, Text Data Editor, enter short value [space] double value on each line.

arr yer I get it, great website !

But as I'm looking for the x,y,z rotation of a joint should I not be looking in 3D functions ?

I tried my data with both 2D & 3D but didnt see any that came out correct.

Thanks for the help so far.
[/quote]

You're looking for a relation between a short angle representation and a double angle representation. double = Func(short), so that's 2D, unless the value of a single component is derived from multiple components. Could you maybe post some more data points?

Also, where is this binary data coming from?
[/quote]

Here is another set of data.

[font="Times New Roman"]0.00, 90.00, 0.00
0, 23170, 0
[/font]
As you can see all 3 values are used in combination somehow to work out the angles.

Not like X = some_function(x);

The binary data I'm just getting from a hex editor, from one of my converted models (that's how I know what the angle should be)

Edit: I'm just using a debugger on the host application that loads the file, and I'm reversing the function that processes the angles.

Here is a snippet:

 v9 = atan2( 1.0 - (st.y * st.y + st.y * st.y) - v3, v4 + v4 - (st.z * st.x + st.z * st.x)); v5 = st.y * st.x + st.z * st.dunno; v10 = asin(v5 + v5); v6 = st.z * st.y; v1 = atan2( 1.0 - (st.x * st.x + st.x * st.x) - v3, st.x * st.dunno + st.x * st.dunno - (v6 + v6)); if ( PI - fabs(v9) < 0.001 ) v9 = 0.0; if ( PI - fabs(v1) < 0.001 ) v1 = 0.0; 

it's not that tidy as I'm converting asm to c++, will tidy up when fully working :/

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 11
• 9
• 11
• 15