/* File: EntityCoordinate.java CVS Info: $Id: EntityCoordinate.java,v 1.2 1998/01/27 18:44:06 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.*; /** * Entity coordinate system. * *@version 1.0 *@author Don McGregor (http://www.npsnet.org/~mcgredo) * *
Location: *
Web: * http://www.web3d.org/WorkingGroups/vrtp/mil/navy/nps/dis/EntityCoordinate.java * *
or locally: * ~/mil/navy/nps/dis/EntityCoordinate.java * *
Hierarchy Diagram: *
* *
Summary: *
Location with respect to a particular entity shall be specified with respect to three orthogonal axes * whose origin shall be the center of the bounding volume of the entity excluding its articulated * and attached parts. * *
Explanation: *
The EntityCoordinate class describes a position in 32-bit x,y,z coordinates relative * to the entity's own coordinate system. The other major position class is "WorldCoordinate", * which describes the position in 64-bit x, y, z "world" coords.

* *

Note: *
This is not really a record on its own for DIS, but simply a vector. * *
History: *
16Dec96 /Don McGregor /New *
10Mar97 /Don McGregor /Cleaned up for javadoc *
16Apr97 /Don McGregor /PrintStream passed to printValues *
12Aug97 /Don McGregor /elaborated printValues *
8Dec97 /Ronan Fauglas /changes for documentation templates + complements in documentation *
11Dec97 /Ronan Fauglas /changes access methods names from "variable()" to "getVariable()" *
17Dec97 /Ronan Fauglas /bug fixes: changed sizeOf from 24 to 12 * *
References: *
DIS Data Dictionary: Entity Coordinate Vector Record *
DIS specification : IEEE 1278.1, 5.3.33.1 * *@see PduElement *@see SerializationInterface *@see LinearAcceleration *@see LinearVelocity *@see WorldCoordinate */ public class EntityCoordinate extends PduElement { /** *First coordinate of the entity, along X axis */ protected float x; // x-position /** *Second coordinate of the entity, along Y axis */ protected float y; // y-position /** *Third coordinate of the entity, along Z axis */ protected float z; // z-position /** *Constant value--size of a Entity Position Record; here :sizeOf = 12 bytes. */ public final int sizeOf = 12; // object is 12 bytes long /** *Constructs an new EntityCoordinate Object; the entity is at the origin. */ public EntityCoordinate() { // default constructor x = 0; y = 0; z = 0; return; } public EntityCoordinate(float pX, float pY, float pZ) { x = pX; y = pY; z = pZ; return; } public Object clone() { EntityCoordinate newEntityCoordinate = new EntityCoordinate(x, y, z); return newEntityCoordinate; } 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(x); outputStream.writeFloat(y); outputStream.writeFloat(z); } catch (IOException ioError) { throw new RuntimeException("Exception in EntityCoordinate. Error writing to wire."); } } public void deSerialize(DataInputStream pInputStream) { try { x = pInputStream.readFloat(); y = pInputStream.readFloat(); z = pInputStream.readFloat(); } catch (IOException ioError) { throw new RuntimeException("Exception in EntityCoordinate. 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 + "EntityCoordinate x: " + x); printStream.println(indent + "EntityCoordinate y: " + y); printStream.println(indent + "EntityCoordinate z: " + z); return; } // Accessor methods public float getX() { return x; } public void setX(float pX) {x = pX; } public float getY() { return y; } public void setY(float pY) {y = pY; } public float getZ() { return z; } public void setZ(float pZ) {z = pZ; } } // end of class EntityCoordinate