Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Suggestion Camera rotation angle

Java Warlord
Joined
Nov 17, 2014
Messages
4,906
In the case that a randomly chosen angle is more than 359 or less than 0, instead of throwing an illegal argument exception, please add something like this:

Code:
public static boolean setYaw(final int a) {
    int b = a;
    while (b < 0 || b > 359) {
        b += b < 0 ? 359 : -359;
    }
}


Then use b for the angle.
 
Mod Automation
Joined
Jul 26, 2013
Messages
3,053
Not sure I like that. The responsibility for doing the arithmetic (which would be better done as "a % 360") is on the bot author. It's highly improper to setYaw(732) for example. I'll let @Cloud see what he thinks as well.
 
Java Warlord
Joined
Nov 17, 2014
Messages
4,906
Not sure I like that. The responsibility for doing the arithmetic (which would be better done as "a % 360") is on the bot author. It's highly improper to setYaw(732) for example. I'll let @Cloud see what he thinks as well.
"In the case that a randomly chosen angle"
By saying that I meant like when you add a kind of deviation to your current angle and move to this new value.
But modulo is indeed a better implementation, I didn't thought of that while writing the topic
 
Mod Automation
Joined
Jul 26, 2013
Messages
3,053
You can add all the deviation you want as long as you ensure it is within certain bounds [0, 359] before passing it to the setYaw method. I would recommend using recursion or a simple while loop that checks to make sure it complies.

P.S. Or just using the modulus hack lol.
 
Java Warlord
Joined
Nov 17, 2014
Messages
4,906
You can add all the deviation you want as long as you ensure it is within certain bounds [0, 359] before passing it to the setYaw method. I would recommend using recursion or a simple while loop that checks to make sure it complies.

P.S. Or just using the modulus hack lol.
Thats what im using currently :)
This implemention is not very important to me, it would just make things easier to read and to use...
 
Top