-
-//----------------------------------------------------------------------------------------------------------------------------------
-public class xyz { float x,y,z; // extends pVector; eliminate half of the functions
- xyz() {x=y=z=0;}
- xyz(Point p ) {x=p.x ; y=p.y; z=p.z;}
- xyz(xyz p ) {set(p); }
- xyz(float _x,float _y,float _z) {x=_x ; y=_y ; z=_z ;}
- void set(Point p ) {x=p.x ; y=p.y; z=p.z;}
- void set(xyz p ) {x=p.x ; y=p.y ; z=p.z ;}
- void set(float _x,float _y,float _z) {x=_x ; y=_y ; z=_z ;}
-
- void zoomX (float zx) {x = x*zx - mMax.x*(zx-1)/2; }
- void zoomY (float zy) {y = y*zy - mMax.y*(zy-1)/2; }
-
- float distance(xyz b) {return dist(x,y,z,b.x,b.y,b.z); }
- float distance(float _x, float _y) {return dist(x,y,_x,_y); }
- float dot (xyz b) {return x*b.x + y*b.y + z*b.z; }
- void add (xyz b) {x += b.x; y += b.y; z += b.z; }
- void add (float b) {x += b ; y += b ; z += b ; }
- void subtract(xyz b) {x -= b.x; y -= b.y; z -= b.z; }
- void scale (float b) {x *= b ; y *= b ; z *= b ; }
-
- void rotateZ (xyz o, float nSin, float nCos) {
- float nX = nCos*(x-o.x) - nSin*(y-o.y) + o.x;
- float nY = nSin*(x-o.x) + nCos*(y-o.y) + o.y;
- x = nX; y = nY;
- }
-
- void rotateX (xyz o, float nSin, float nCos) {
- float nY = nCos*(y-o.y) - nSin*(z-o.z) + o.y;
- float nZ = nSin*(y-o.y) + nCos*(z-o.z) + o.z;
- y = nY; z = nZ;
- }
-
- void rotateY (xyz o, float nSin, float nCos) {
- float nZ = nCos*(z-o.z) - nSin*(x-o.x) + o.z;
- float nX = nSin*(z-o.z) + nCos*(x-o.x) + o.x;
- z = nZ; x = nX;
- }
-
- void setRand () { x = random(mMax.x); y = random(mMax.y); z = random(mMax.z); }
- void setNorm () { x /= mMax.x; y /= mMax.y; z /= mMax.z; }
- void interpolate(float i, xyz d) { x = interp(i,x,d.x); y = interp(i,y,d.y); z = interp(i,z,d.z); }
-}