Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | jelly | |
Old Version | Published before Godot 3 was released. |
Perhaps more of a math question. Nevertheless, I am making a system that plots points from an outside source. Currently I am taking a base value plus the received value to set its Y coordinate. The problem comes from that data, which I have no control over. It comes back in the area of 1.117670 with most fluctuations occurring in the thousandths or ten thousandths.
Obviously if I attempt to add this value to the Y it won’t go anywhere as the game is getting a 1. What I am unsure of how to do is to scale it up based on some formula so that a discernible, preferably settable, space between each point can be seen.
Are you trying to display a graph of values in a way they can be all seen on screen?
Zylann | 2016-08-31 23:06
That is not mandatory no, just spread out based on minimal decimal gains.
jelly | 2016-09-01 01:35
I don’t understand the problem actually, it looks a bit abstract. What is the question?
Zylann | 2016-09-01 01:52
I need to move the graph points up and down by X amount based on a decimal change often in the ten-thousandths place.
All the values I get come like 1.117670, so if I tried to add that to the Y all the points would be the same distance apart because I am only adding by 1.
For example, and perhaps this would work I am not sure (of either the math or implementation), each ten-thousandths would be equal to five (or any number) pixels of movement either in the positive or negative Y, depending on the change.
jelly | 2016-09-01 15:41
I know that you can get the fractional part of a number with x-floor(x)
, then divide/multiply by pow(10, n)
and use modulo to get the value of a decimal in the integer part, but I’m still clueless about what you are trying to achieve.
Also, ten thousandths (1/10000) is very small for a floating point number (Godot uses floats by default), I’m not sure you’ll get enough precision.
Zylann | 2016-09-01 19:18
That, and a bit more, got us to where we needed. Thanks a ton!
jelly | 2016-09-03 03:12