Thread: Inverting Axis
View Single Post
  #6   Spotlight this post!  
Unread 02-02-2015, 11:56
GeeTwo's Avatar
GeeTwo GeeTwo is online now
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,609
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Inverting Axis

Quote:
Originally Posted by notmattlythgoe View Post
You can also just place a - in front of it.

Code:
if (reversing) { //Put whatever code you use to detect if you're reversing here
     myMotor.set(-joystick.getYAxis()); //Set a motor to the inverse of the Y axis.
}
Quote:
Originally Posted by Ether View Post
Is this just a matter of aesthetics, or does it actually generate more efficient code?
I'm not sure about Java, but I do know that with traditional compilers, it is more efficient - changing the sign on a number is a much simpler operation, usually done in a single clock cycle. Unless the compiler is doing serious optimization, multiplying by -1 is a full floating-point multiply.

Last edited by GeeTwo : 02-02-2015 at 11:56. Reason: fix quote tag
Reply With Quote