2.5.8 - A Vector - JdlVec

John W. Campbell

2.5.8.1 Introduction

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

2.5.8.2 Class Details

Package:
Jdl.JdlLib;
Class name:
JdlVec
Class definition:
public class JdlVec
Extends:
Object
Implements:
Cloneable
Actions:
none

2.5.8.3 Accessible Fields

No fields with public, package or protected access defined.

2.5.8.4 Constructors

2.5.8.4.1 Introduction

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

2.5.8.4.2 Constructor 1

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.

2.5.8.4.3 Constructor 2

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.

2.5.8.4.4 Constructor 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.

2.5.8.4.5 Constructor 4

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

2.5.8.4.6 Constructor 5

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.

2.5.8.5 Methods

2.5.8.5.1 Introduction

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

2.5.8.5.2 Return in double array - getVectorArray

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.

2.5.8.5.3 Return in float array - getVectorArray

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.

2.5.8.5.4 Get unit vector - unitVector

Calculate the unit vector based on the given vector.

Method Definition:
public JdlVec unitVector()
Parameters List:
none
Method Return:
The unit vector.

2.5.8.5.5 Get modulus - modulus

Calculate the Vector modulus.

Method Definition:
public double modulus()
Parameters List:
none
Method Return:
The modulus.

2.5.8.5.6 List vector - listContents

This method lists the vector to the standard output stream.

Method Definition:
public void listContents()
Parameters List:
none

2.5.8.5.7 List vector - listContents

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