Most Processing folks use a

__ PVector__ merely as a mean to store 2 or 3 values and nothing more.

Here's a mini

__ PVectorD__ storage

class which only stores and retrieves its

**x**,

**y**,

**z** fields.

It accepts a wide range of data types; including

__ Array__,

__ PVector__,

int and

float:

P.S.: Suffix all your numerical literals w/

d, like

*4.5d* to assure a better precision.

Processing's pre-processor suffix all fractional literals w/

f, forcing them to be

float instead.

PVectorD.java:

/**
* Mini PVector Class Storage for Doubles (v1.01)
* by GoToLoop (2013/Aug)
*
* http://forum.processing.org/topic/can-pvector-work-with-doubles
*/
class PVectorD {
double x, y, z;
PVectorD(double xx, double yy) {
set(xx, yy);
}
PVectorD(double xx, double yy, double zz) {
set(xx, yy, zz);
}
PVectorD(PVector p) {
set(p);
}
PVectorD(int[] a) {
set(float(a));
}
PVectorD(float[] a) {
set(a);
}
PVectorD(double[] a) {
set(a);
}
void clear() {
x = y = z = 0;
}
void set(double xx, double yy) {
x = xx;
y = yy;
}
void set(double xx, double yy, double zz) {
x = xx;
y = yy;
z = zz;
}
void set(PVector p) {
x = p.x;
y = p.y;
z = p.z;
}
void set(int[] a) {
set(float(a));
}
void set(float[] a) {
final int len = a.length;
if (len > 0) x = a[0];
if (len > 1) y = a[1];
if (len > 2) z = a[2];
}
void set(double[] a) {
final int len = a.length;
if (len > 0) x = a[0];
if (len > 1) y = a[1];
if (len > 2) z = a[2];
}
PVectorD get() {
return new PVectorD(x, y, z);
}
PVector toPVector() {
return new PVector((float) x, (float) y, (float) z);
}
double[] toArray() {
return new double[] {
x, y, z
};
}
String toString() {
return "[ " + x + ", " + y + ", " + z + " ]";
}
}