Unproject a screen coordinate (at depth 0) to 3D model coordinates.

@param x X
@param y Y
@param z Z
@param out output buffer
485607
public void unproject(double x, double y, double z, double[] out) {
    glu.gluUnProject(x, y, z, modelview, 0, projection, 0, viewp, 0, out, 0);
  }
1082899
@Override
	public void setFirstAxis(double x, double y, double z, double extent) {
		setFirstAxis(x, y, z, extent, CoordinateSystem3D.getDefaultCoordinateSystem());
	}
618709
public Vector3f transformProject(float x, float y, float z, Vector3f dest) {
        dest.x = x;
        dest.y = y;
        dest.z = z;
        return dest.mulProject(this);
    }
1017219
@Override
	public void setCenter(double x, double y, double z) {
		this.cxProperty.set(x);
		this.cyProperty.set(y);
		this.czProperty.set(z);
	}
83445
private void project3(double[] output) {
		int observationIndex = 0;
		for( int viewIndex = 0; viewIndex < structure.views.length; viewIndex++ ) {
			SceneStructureMetric.View view = structure.views[viewIndex];
			SceneStructureMetric.Camera camera = structure.cameras[view.camera];

			//=========== Project General Points in this View
			{
				SceneObservations.View obsView = observations.views[viewIndex];
				for (int i = 0; i < obsView.size(); i++) {
					obsView.get(i, observedPixel);
					SceneStructureMetric.Point worldPt = structure.points[observedPixel.index];
					worldPt.get(p3);

					SePointOps_F64.transform(view.worldToView, p3, cameraPt);

					camera.model.project(cameraPt.x, cameraPt.y, cameraPt.z, predictedPixel);

					int outputIndex = observationIndex * 2;
					output[outputIndex] = predictedPixel.x - observedPixel.x;
					output[outputIndex + 1] = predictedPixel.y - observedPixel.y;
					observationIndex++;
				}
			}

			//=========== Project Rigid Object Points in this View
			if( observations.viewsRigid != null )
			{
				SceneObservations.View obsView = observations.viewsRigid[viewIndex];
				for (int i = 0; i < obsView.size(); i++) {
					obsView.get(i,observedPixel);

					// Use lookup table to figure out which rigid object it belongs to
					int rigidIndex = structure.lookupRigid[observedPixel.index];
					SceneStructureMetric.Rigid rigid = structure.rigids[rigidIndex];
					// Compute the point's index on the rigid object
					int pointIndex = observedPixel.index - rigid.indexFirst;

					// Load the 3D location of point on the rigid body
					SceneStructureMetric.Point objectPt = rigid.points[pointIndex];
					objectPt.get(p3);

					// Tranform to world frame and from world to camera
					SePointOps_F64.transform(rigid.objectToWorld,p3, worldPt);
					SePointOps_F64.transform(view.worldToView,worldPt, cameraPt);

					// Project and compute residual
					camera.model.project(cameraPt.x, cameraPt.y, cameraPt.z, predictedPixel);

					int outputIndex = observationIndex*2;
					output[outputIndex  ] = predictedPixel.x - observedPixel.x;
					output[outputIndex+1] = predictedPixel.y - observedPixel.y;
					observationIndex++;
				}
			}
		}
	}
720057
public void setPosition(Vector3D v) {
		this.x = v.getX();
		this.y = v.getY();
		this.z = v.getZ();
	}
599825
public boolean process( int x , int y ) {
		visualToDepth.compute(x, y,distorted);

		int depthX = (int)distorted.x;
		int depthY = (int)distorted.y;

		if( depthImage.isInBounds(depthX,depthY) ) {
			// get the depth at the specified location
			double value = lookupDepth(depthX, depthY);

			// see if its an invalid value
			if( value == 0 )
				return false;

			// convert visual pixel into normalized image coordinate
			p2n.compute(x,y,norm);

			// project into 3D space
			worldPt.z = value*depthScale;
			worldPt.x = worldPt.z*norm.x;
			worldPt.y = worldPt.z*norm.y;

			return true;
		} else {
			return false;
		}
	}
794936
private double getValue(final double x, final double y, final double z,
            final Axis axis) {
        switch (axis) {
            case X:
                return x;
            case X_INVERTED:
                return -x;
            case Y:
                return y;
            case Y_INVERTED:
                return -y;
            case Z:
                return z;
            case Z_INVERTED:
                return -z;
            default:
                throw new IllegalArgumentException("Unsupported axis.");
        }
    }
1004352
public Vector4f transformProject(float x, float y, float z, float w, Vector4f dest) {
        dest.x = x;
        dest.y = y;
        dest.z = z;
        dest.w = w;
        return dest.mulProject(this);
    }
379649
public Vector3f transformPosition(float x, float y, float z, Vector3f dest) {
        dest.x = x;
        dest.y = y;
        dest.z = z;
        return dest.mulPosition(this);
    }
433672
public Matrix4f unprojectRay(float winX, float winY, int[] viewport, Vector3f originDest, Vector3f dirDest) {
        float a = m00 * m11 - m01 * m10;
        float b = m00 * m12 - m02 * m10;
        float c = m00 * m13 - m03 * m10;
        float d = m01 * m12 - m02 * m11;
        float e = m01 * m13 - m03 * m11;
        float f = m02 * m13 - m03 * m12;
        float g = m20 * m31 - m21 * m30;
        float h = m20 * m32 - m22 * m30;
        float i = m20 * m33 - m23 * m30;
        float j = m21 * m32 - m22 * m31;
        float k = m21 * m33 - m23 * m31;
        float l = m22 * m33 - m23 * m32;
        float det = a * l - b * k + c * j + d * i - e * h + f * g;
        det = 1.0f / det;
        float im00 = ( m11 * l - m12 * k + m13 * j) * det;
        float im01 = (-m01 * l + m02 * k - m03 * j) * det;
        float im02 = ( m31 * f - m32 * e + m33 * d) * det;
        float im03 = (-m21 * f + m22 * e - m23 * d) * det;
        float im10 = (-m10 * l + m12 * i - m13 * h) * det;
        float im11 = ( m00 * l - m02 * i + m03 * h) * det;
        float im12 = (-m30 * f + m32 * c - m33 * b) * det;
        float im13 = ( m20 * f - m22 * c + m23 * b) * det;
        float im20 = ( m10 * k - m11 * i + m13 * g) * det;
        float im21 = (-m00 * k + m01 * i - m03 * g) * det;
        float im22 = ( m30 * e - m31 * c + m33 * a) * det;
        float im23 = (-m20 * e + m21 * c - m23 * a) * det;
        float im30 = (-m10 * j + m11 * h - m12 * g) * det;
        float im31 = ( m00 * j - m01 * h + m02 * g) * det;
        float im32 = (-m30 * d + m31 * b - m32 * a) * det;
        float im33 = ( m20 * d - m21 * b + m22 * a) * det;
        float ndcX = (winX-viewport[0])/viewport[2]*2.0f-1.0f;
        float ndcY = (winY-viewport[1])/viewport[3]*2.0f-1.0f;
        float px = im00 * ndcX + im10 * ndcY + im30;
        float py = im01 * ndcX + im11 * ndcY + im31;
        float pz = im02 * ndcX + im12 * ndcY + im32;
        float invNearW = 1.0f / (im03 * ndcX + im13 * ndcY - im23 + im33);
        float nearX = (px - im20) * invNearW;
        float nearY = (py - im21) * invNearW;
        float nearZ = (pz - im22) * invNearW;
        float invFarW = 1.0f / (im03 * ndcX + im13 * ndcY + im23 + im33);
        float farX = (px + im20) * invFarW;
        float farY = (py + im21) * invFarW;
        float farZ = (pz + im22) * invFarW;
        originDest.x = nearX; originDest.y = nearY; originDest.z = nearZ;
        dirDest.x = farX - nearX; dirDest.y = farY - nearY; dirDest.z = farZ - nearZ;
        return this;
    }
975282
boolean remove(double x, double y, double z) {
		for(int i=0, j=0; i<this.numCoordsProperty.get() && j<this.numTypesProperty.get();) {
			switch(this.types[j]) {
			case MOVE_TO:
			case LINE_TO:
				if (x==this.coordsProperty[i].get() && y==this.coordsProperty[i+1].get() && z==this.coordsProperty[i+2].get()) {
					this.numCoordsProperty.set(this.numCoordsProperty.get()-3);
					this.numTypesProperty.set(this.numTypesProperty.get()-1);
					System.arraycopy(this.coordsProperty, i+3, this.coordsProperty, i, this.numCoordsProperty.get());
					System.arraycopy(this.types, j+1, this.types, j, this.numTypesProperty.get());
					this.isEmptyProperty = null;
					return true;
				}
				i += 3;
				++j;
				break;
			case CURVE_TO:
				if ((x==this.coordsProperty[i].get() && y==this.coordsProperty[i+1].get() && z==this.coordsProperty[i+2].get())
						||(x==this.coordsProperty[i+3].get() && y==this.coordsProperty[i+4].get() && z==this.coordsProperty[i+5].get())
						||(x==this.coordsProperty[i+6].get() && y==this.coordsProperty[i+7].get() && z==this.coordsProperty[i+8].get())) {
					this.numCoordsProperty.set(this.numCoordsProperty.get()-9);
					this.numTypesProperty.set(this.numTypesProperty.get()-1);
					System.arraycopy(this.coordsProperty, i+9, this.coordsProperty, i, this.numCoordsProperty.get());
					System.arraycopy(this.types, j+1, this.types, j, this.numTypesProperty.get());
					this.isEmptyProperty = null;
					this.isPolylineProperty = null;
					return true;
				}
				i += 9;
				++j;
				break;
			case QUAD_TO:
				if ((x==this.coordsProperty[i].get() && y==this.coordsProperty[i+1].get() && z==this.coordsProperty[i+2].get())
						||(x==this.coordsProperty[i+3].get() && y==this.coordsProperty[i+4].get() && z==this.coordsProperty[i+5].get())) {
					this.numCoordsProperty.set(this.numCoordsProperty.get()-6);
					this.numTypesProperty.set(this.numTypesProperty.get()-1);
					System.arraycopy(this.coordsProperty, i+6, this.coordsProperty, i, this.numCoordsProperty.get());
					System.arraycopy(this.types, j+1, this.types, j, this.numTypesProperty.get());
					this.isEmptyProperty = null;
					this.isPolylineProperty = null;
					return true;
				}
				i += 6;
				++j;
				break;
			case CLOSE:
				++j;
				break;
			default:
				break;
			}
		}
		return false;
	}
39414
@Override
	public void compute(int x, int y, Point2D_F64 out ) {
		// grab precomputed normalized image coordinate at canonical location
		Point3D_F64 v = vectors[y*outWidth+x];
		// move to requested orientation
		GeometryMath_F64.mult(R,v,n); // TODO make faster by not using an array based matrix

		// compute pixel coordinate
		tools.normToEquiFV(n.x,n.y,n.z,out);
	}
1037117
@Override
	public void setSecondAxis(double x, double y, double z, double extent) {
		setSecondAxis(x, y, z, extent, CoordinateSystem3D.getDefaultCoordinateSystem());
	}
592911
public void moveTo(double x, double y, double z) {
		if (this.numTypesProperty.get()>0 && this.types[this.numTypesProperty.get()-1]==PathElementType.MOVE_TO) {
			this.coordsProperty[this.numCoordsProperty.get()-3].set(x);
			this.coordsProperty[this.numCoordsProperty.get()-2].set(y);
			this.coordsProperty[this.numCoordsProperty.get()-1].set(z);
		}
		else {
			ensureSlots(false, 3);
			this.types[this.numTypesProperty.get()] = PathElementType.MOVE_TO;
			this.numTypesProperty.set(this.numTypesProperty.get()+1);

			this.coordsProperty[this.numCoordsProperty.get()].set(x);
			this.numCoordsProperty.set(this.numCoordsProperty.get()+1);

			this.coordsProperty[this.numCoordsProperty.get()].set(y);
			this.numCoordsProperty.set(this.numCoordsProperty.get()+1);

			this.coordsProperty[this.numCoordsProperty.get()].set(z);
			this.numCoordsProperty.set(this.numCoordsProperty.get()+1);
		}
		this.graphicalBounds = null;
		this.logicalBounds = null;
	}
964353
public void setPosition(double x, double y, double z) {
		this.x = x;
		this.y = y;
		this.z = z;
	}
1034435
public void getFeature3D( int feature , Point4D_F64 out ) {
		out.x = X.get(0,feature);
		out.y = X.get(1,feature);
		out.z = X.get(2,feature);
		out.w = X.get(3,feature);
	}