John W. Campbell
This is a simple class to store a vector. The vector data may be
converted between object and array forms. A method for calculating the
unit vector is included. Other methods using JdlVec objects are available
in the JdlUtils class of static methods. The JdlVec object is cloneable.
Constructor and methods:
Class Details
Accessible Fields
Constructors
Methods
- Package:
- Jdl.JdlLib;
- Class name:
- JdlVec
- Class definition:
- public class JdlVec
- Extends:
- Object
- Implements:
- Cloneable
- Actions:
- none
No fields with public, package or protected access defined.
Five constructors are available to construct a JdlVec object from an
array of double values, an array of float values or from individual
double or float value components or from another JdlVec object.
Constructors:
Constructor 1
Constructor 2
Constructor 3
Constructor 4
Constructor 5
Create a JdlVec vector object from an array of double values.
- Constructor Definition:
- public JdlVec (double[] vec)
- Parameters List:
- vec
- The vector elements in a 3 element double array.
Create a JdlVec vector object from its double value components.
- Constructor Definition:
- public JdlVec (double c1, double c2, double c3)
- Parameters List:
- c1
- The vector component 1.
- c2
- The vector component 2.
- c3
- The vector component 3.
Create a JdlVec vector object from an array of float values.
- Constructor Definition:
- public JdlVec (float[] vec)
- Parameters List:
- vec
- The vector elements in a 3 element float array.
Create a JdlVec vector object from its components
- Constructor Definition:
- public JdlVec (float c1, float c2, float c3)
- Parameters List:
- c1
- The vector component 1
- c2
- The vector component 2
- c3
- The vector component 3
Create a JdlVec vector object from another JdlVec object.
- Constructor Definition:
- public JdlVec (JdlVec v)
- Parameters List:
- v
- The JdlVec object from which to create a new vector object.
This section contains methods to return the vector data in double or
float arrays, to calculate its modulus or unit vector.
Methods:
Return in double array - getVectorArray
Return in float array - getVectorArray
Get unit vector - unitVector
Get modulus - modulus
List vector - listContents
List vector - listContents
Return the array elements in a 3 element double array.
- Method Definition:
- public void getVectorArray(double[] vec)
- Parameters List:
- vec
- 3 element double array in which the data are to be returned.
Return the array elements in a 3 element float array.
- Method Definition:
- public void getVectorArray(float[] vec)
- Parameters List:
- vec
- 3 element float array in which the data are to be returned.
Calculate the unit vector based on the given vector.
- Method Definition:
- public JdlVec unitVector()
- Parameters List:
- none
- Method Return:
-
The unit vector.
Calculate the Vector modulus.
- Method Definition:
- public double modulus()
- Parameters List:
- none
- Method Return:
-
The modulus.
This method lists the vector to the standard output stream.
- Method Definition:
- public void listContents()
- Parameters List:
- none
This method lists the annoated vector to the standard output stream.
- Method Definition:
- public void listContents(String str)
- Parameters List:
- str
- A string to identify the vector on the listing.
⇑ Up 2
⇑ Up 1
⇑ Top of this