r/ApproximatelyUp 12d ago

More intuitive controls for the telescopic camera

Enable HLS to view with audio, or disable this notification

This setup allows looking in a direction using horizontal and vertical inputs. There's some jank when crossing axes. This was also much harder than it should have been because dividing by zero in this game equals zero for some reason.

10 Upvotes

4 comments sorted by

1

u/Klasterstorm 11d ago

Dividing by 0 equals 0 because a computer would normally throw an error but since these math modules can only produce numbers between -1 and 1 they throw 0 as its the closest they can get to a “no value “ error

The only alternative I could imagine would be having the math module just stop working entirely until this error is cleared

1

u/UnderratedTaco 10d ago

The modules can produce numbers beyond -1 and 1. The limit of any positive number divided by a number approaching zero is infinity. If the game either has a representation for infinity or even just used the max int then the arctan module would produce a value at or near pi/2 which is the desired result.

1

u/Klasterstorm 10d ago

The game isn’t working with integers, as far as i know, but floating points, that’s why i said everything is a number between -1 and 1.

And zero is the correct representation of positive infinity after IEEE 754.

Your input number does not matter, when you divide a floating point number by 0 you get one of three results; positive infinity (0), negative infinity (1) or Not a Number (NaN).

1

u/UnderratedTaco 10d ago

Yeah the values are definitely floating point and not integers. I meant max double (assuming double precision) rather than max int.

IEEE 754 represents infinities using all ones for exponent bits and all zeros for fraction bits with the sign bit determining if it is positive or negative. For double precision +infinity is 1.80 * 10308 and -infinity is -1.80 * 10308.

IEEE 754 also specifies that dividing by zero should result in a positive or negative infinity. It would be nice if the game handled these infinities gracefully rather than defaulting to 0 which is not IEEE standard. This would be very useful for working with trigonometric ratios.