If you think the Android project webots-remote-control listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package org.black_mesa.webots_remote_control.communication_structures;
/*www.java2s.com*/import java.io.Serializable;
/**
* Instruction class for a Webots camera.
*
* @author Ilja Kroonen
*
*/publicfinalclass CameraInstruction implements Serializable {
privatestaticfinallong serialVersionUID = -1401919642170517372L;
privatefinal Type mType;
privatefinaldouble[] mArgs;
privateenum Type {
MOVE, TURN, PITCH
}
private CameraInstruction(final Type type, finaldouble[] args) {
mType = type;
mArgs = args;
}
/**
* Creates a move CameraInstruction.
*
* @param right
* Distance of the movement along the right vector.
* @param up
* Distance of the movement along the up vector.
* @param forward
* Distance of the movement along the forward vector.
* @return Resulting instance.
*/publicstatic CameraInstruction move(finaldouble right, finaldouble up, finaldouble forward) {
double[] args = { right, up, forward };
returnnew CameraInstruction(Type.MOVE, args);
}
/**
* Creates a turn CameraInstruction.
*
* @param angle
* Angle of the turn (rad).
* @return Resulting instance.
*/publicstatic CameraInstruction turn(finaldouble angle) {
double[] args = { angle };
returnnew CameraInstruction(Type.TURN, args);
}
/**
* Creates a pitch CameraInstruction.
*
* @param angle
* Angle of the turn (rad).
* @return Resulting instance.
*/publicstatic CameraInstruction pitch(finaldouble angle) {
double[] args = { angle };
returnnew CameraInstruction(Type.PITCH, args);
}
@Override
public String toString() {
switch (mType) {
case MOVE:
return mType + "(" + mArgs[0] + "," + mArgs[1] + "," + mArgs[2] + ")";
case TURN:
return mType + "(" + mArgs[0] + ")";
case PITCH:
return mType + "(" + mArgs[0] + ")";
}
return null;
}
}