0 votes

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.

in Engine by (56 points)

Are you trying to display a graph of values in a way they can be all seen on screen?

That is not mandatory no, just spread out based on minimal decimal gains.

I don't understand the problem actually, it looks a bit abstract. What is the question?

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.

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.

That, and a bit more, got us to where we needed. Thanks a ton!

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.