Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / Negative Zero issue

Author
Message
jd_zoo
5
Years of Service
User Offline
Joined: 12th May 2018
Location: Nova Scotia
Posted: 3rd Jan 2021 15:52
Trying to rotate simple cube between 0 and 180 degrees. No problem to catch it at 180 and reverse, but when gets back to origin I am consistently getting a negative 0 angle and it is proving extremely difficult to remedy.

My current though process, as I go for another tea break here, is that I should start with the cube rotated 90deg so I am only using 90/270 and stay away from zero. But that is not dealing with my trigonometry shortcomings so if anyone has any suggestions I'm all ears.
jd_zoo
5
Years of Service
User Offline
Joined: 12th May 2018
Location: Nova Scotia
Posted: 3rd Jan 2021 16:29
Might be just me, but I found a difference b/w setting the object rotation as 0 compared to 0.0

This made a difference:
SetObjectRotation(myCube, GetObjectAngleX(myCube), GetObjectAngleY(myCube), 0.0)

This is what I had pre-tea break:
SetObjectRotation(myCube, GetObjectAngleX(myCube), GetObjectAngleY(myCube), 0)

Now it doesn't get stuck at zero, I need to get in better habit of using a decimal place when it comes to floating points.
n00bstar
20
Years of Service
User Offline
Joined: 9th Feb 2004
Location: Montreal, Canada.
Posted: 11th Jan 2021 13:51
Floats can get a little fuzzy. If you're getting -0 as a result to whatever you're doing, it means you have some crap left beyond the decimal point because -0 is mathematically impossible. For example, -0.00001 will read as -0. It IS a good habit to add .0 to floats when passing whole numbers to it.

It's one of those bad habits that's easy to fall into because most of the time you will not get such problems, but when you do....it can take a while to debug

Also...15:52 to 16:39... that's a long tea break my friend
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 14th Jan 2021 01:57
Yeah cut your decimal points down or avoid going beyond zero. Or abs can always check a variable before u increment or set it also and modify it before changing it.

Login to post a reply

Server time is: 2024-04-20 09:56:21
Your offset time is: 2024-04-20 09:56:21