/* File: EulerAngle.java CVS Info: $Id: EulerAngle.java,v 1.2 1998/01/27 18:44:12 mcgredo Exp $ Compiler: jdk 1.3 */ package mil.navy.nps.dis; import mil.navy.nps.util.*; // General-purpose utilities import mil.navy.nps.disEnumerations.*; // Enumerations for DIS import java.lang.*; import java.util.*; import java.io.*; /** * Representation of an entity's orientation. * *@version 1.0 *@author Don McGregor (http://www.npsnet.org/~mcgredo) * *
* "Don't ask, don't tell" does NOT apply here. We can ask any entity * about its orientation.
* *
sizeOf = 12 bytes
.
*/
public final int sizeOf = 12; // object is 12 bytes long
/**
*Constructs an new Entity Identifier, with initial values initiated to 0.
*/
public EulerAngle()
{
// default constructor
psi = 0;
theta = 0;
phi = 0;
return;
}
/**
*Constructs an new EulerAngle Record, with variables values passed by parameters.
*
*@param pPsi the rotation about z by angle
*@param pTheta the rotation about y by angle
*@param pPhi the rotation about x by angle
*/
public EulerAngle(float pPsi, float pTheta, float pPhi)
{
psi = pPsi;
theta = pTheta;
phi = pPhi;
return;
}
public Object clone()
{
EulerAngle newEulerAngle = new EulerAngle(psi, theta, phi);
return newEulerAngle;
}
public void serialize(DataOutputStream outputStream)
{
// write out the data to an output stream. Order is important here, since
// it needs to conform to the DIS standard.
//super.serialize(outputStream); // No need to call super, since no ivars are in our direct superclass
try
{
outputStream.writeFloat(psi);
outputStream.writeFloat(theta);
outputStream.writeFloat(phi);
}
catch (IOException ioError)
{
throw new
RuntimeException("Exception in EulerAngle. Error writing to wire.");
}
}
public void deSerialize(DataInputStream pInputStream)
{
try
{
psi = pInputStream.readFloat();
theta = pInputStream.readFloat();
phi = pInputStream.readFloat();
}
catch (IOException ioError)
{
throw new
RuntimeException("Exception in EulerAngle. Error reading from wire.");
}
}
public int length()
{
return sizeOf; // EntityTypes are this long, always.
}
public void printValues(int indentLevel, PrintStream printStream)
{
// print the values of the object out, with correct level of
// indentation on the page.
StringBuffer indent = ProtocolDataUnit.getPaddingOfLength(indentLevel);
int idx, superclassIndent = indentLevel;
printStream.println(indent + "EulerAngle psi: " + psi);
printStream.println(indent + "EulerAngle theta: " + theta);
printStream.println(indent + "EulerAngle phi: " + phi);
return;
}
// Accessor methods
public void setValues(float pPsi, float pTheta, float pPhi)
{ psi = pPsi;
theta = pTheta;
phi = pPhi;
}
public float getPsi()
{ return psi;
}
public void setPsi(float pPsi)
{psi = pPsi;
}
public float getTheta()
{ return theta;
}
public void setTheta(float pTheta)
{theta = pTheta;
}
public float getPhi()
{ return phi;
}
public void setPhi(float pPhi)
{phi = pPhi;
}
} // end of class EulerAngle