/* (non-Javadoc)
@see org.joml.Matrix4dc#perspectiveFov()
338283
public double perspectiveFov() {
        /*
         * Compute the angle between the bottom and top frustum plane normals.
         */
        double n1x, n1y, n1z, n2x, n2y, n2z;
        n1x = m03 + m01; n1y = m13 + m11; n1z = m23 + m21; // bottom
        n2x = m01 - m03; n2y = m11 - m13; n2z = m21 - m23; // top
        double n1len = Math.sqrt(n1x * n1x + n1y * n1y + n1z * n1z);
        double n2len = Math.sqrt(n2x * n2x + n2y * n2y + n2z * n2z);
        return Math.acos((n1x * n2x + n1y * n2y + n1z * n2z) / (n1len * n2len));
    }
281732
public Matrix4d mulOrthoAffine(Matrix4dc view, Matrix4d dest) {
        double nm00 = m00 * view.m00();
        double nm01 = m11 * view.m01();
        double nm02 = m22 * view.m02();
        double nm03 = 0.0;
        double nm10 = m00 * view.m10();
        double nm11 = m11 * view.m11();
        double nm12 = m22 * view.m12();
        double nm13 = 0.0;
        double nm20 = m00 * view.m20();
        double nm21 = m11 * view.m21();
        double nm22 = m22 * view.m22();
        double nm23 = 0.0;
        double nm30 = m00 * view.m30() + m30;
        double nm31 = m11 * view.m31() + m31;
        double nm32 = m22 * view.m32() + m32;
        double nm33 = 1.0;
        dest.m00 = nm00;
        dest.m01 = nm01;
        dest.m02 = nm02;
        dest.m03 = nm03;
        dest.m10 = nm10;
        dest.m11 = nm11;
        dest.m12 = nm12;
        dest.m13 = nm13;
        dest.m20 = nm20;
        dest.m21 = nm21;
        dest.m22 = nm22;
        dest.m23 = nm23;
        dest.m30 = nm30;
        dest.m31 = nm31;
        dest.m32 = nm32;
        dest.m33 = nm33;
        dest.properties = PROPERTY_AFFINE;
        return dest;
    }
636016
public static int readOrientationFromTIFF(InputStream is, int length) throws IOException {
    // read tiff header
    TiffHeader tiffHeader = new TiffHeader();
    length = readTiffHeader(is, length, tiffHeader);

    // move to the first IFD
    // offset is relative to the beginning of the TIFF data
    // and we already consumed the first 8 bytes of header
    int toSkip = tiffHeader.firstIfdOffset - 8;
    if (length == 0 || toSkip > length) {
      return 0;
    }
    is.skip(toSkip);
    length -= toSkip;

    // move to the entry with orientation tag
    length = moveToTiffEntryWithTag(is, length, tiffHeader.isLittleEndian, TIFF_TAG_ORIENTATION);

    // read orientation
    return getOrientationFromTiffEntry(is, length, tiffHeader.isLittleEndian);
  }
1156011
def perspective(src, scale, face_right)
      dest_cxt = Cairo::Context.new(Cairo::ImageSurface.new(src.width * scale, src.height))
      in_thickness = 1 # Take strip 1 pixel-width at a time
      out_thickness = 3 # Scale it to 3 pixels wider to cover any gaps
      (0..src.width).step(in_thickness) do |i|
        percentage = i / src.width.to_f
        i = src.width - i if face_right
        factor = scale + (percentage * (1.0 - scale)) # linear interpolation
        dest_cxt.save
        dest_cxt.translate 0, src.height / 2.0 * (1.0 - factor)
        dest_cxt.scale factor * scale, factor
        dest_cxt.set_source src, 0, 0
        dest_cxt.rounded_rectangle i, 0, out_thickness, src.height, 0, 0
        dest_cxt.fill
        dest_cxt.restore
      end
      return dest_cxt.target
    end
876614
public Matrix4x3f reflect(Vector3fc normal, Vector3fc point, Matrix4x3f dest) {
        return reflect(normal.x(), normal.y(), normal.z(), point.x(), point.y(), point.z(), dest);
    }
1196806
public Matrix4f reflection(Vector3fc normal, Vector3fc point) {
        return reflection(normal.x(), normal.y(), normal.z(), point.x(), point.y(), point.z());
    }
1190184
private void onPerspectiveChanged(@Observes PluginSaved event) {
        if (currentPerspectiveNavItem != null) {
            NavWorkbenchCtx navCtx = NavWorkbenchCtx.get(currentPerspectiveNavItem);
            String perspectiveId = navCtx.getResourceId();
            if (event.getPlugin().getName().equals(perspectiveId)) {
                openPerspective(currentPerspectiveNavItem);
            }
        }
    }
712020
public void setFundamental( DMatrixRMaj F , Point3D_F64 e2 ) {
		this.F = F;
		if( e2 != null )
			this.e2.set(e2);
		else {
			MultiViewOps.extractEpipoles(F,new Point3D_F64(),this.e2);
		}
	}
458438
public void setCamera2( double fx , double fy , double skew , double cx , double cy ) {
		PerspectiveOps.pinholeToMatrix(fx,fy,skew,cx,cy,K2);
		PerspectiveOps.invertPinhole(K2,K2_inv);
	}
333238
public void setCamera1( double fx , double fy , double skew , double cx , double cy ) {
		PerspectiveOps.pinholeToMatrix(fx,fy,skew,cx,cy,K1);
	}
257039
def _do_perspective_warp(c:FlowField, targ_pts:Points, invert=False):
    ""
    if invert: return _apply_perspective(c, _find_coeffs(targ_pts, _orig_pts))
    return _apply_perspective(c, _find_coeffs(_orig_pts, targ_pts))
1211513
public void update(Matrix4f projection, Matrix4f view) {
        // http://www.crownandcutlass.com/features/technicaldetails/frustum.html
        final float[] clip = projection.mul(view).toArray(true);
        // Extract the numbers for the RIGHT plane
        frustum[0][0] = clip[3] - clip[0];
        frustum[0][1] = clip[7] - clip[4];
        frustum[0][2] = clip[11] - clip[8];
        frustum[0][3] = clip[15] - clip[12];
        // Extract the numbers for the LEFT plane
        frustum[1][0] = clip[3] + clip[0];
        frustum[1][1] = clip[7] + clip[4];
        frustum[1][2] = clip[11] + clip[8];
        frustum[1][3] = clip[15] + clip[12];
        // Extract the BOTTOM plane
        frustum[2][0] = clip[3] + clip[1];
        frustum[2][1] = clip[7] + clip[5];
        frustum[2][2] = clip[11] + clip[9];
        frustum[2][3] = clip[15] + clip[13];
        // Extract the TOP plane
        frustum[3][0] = clip[3] - clip[1];
        frustum[3][1] = clip[7] - clip[5];
        frustum[3][2] = clip[11] - clip[9];
        frustum[3][3] = clip[15] - clip[13];
        // Extract the FAR plane
        frustum[4][0] = clip[3] - clip[2];
        frustum[4][1] = clip[7] - clip[6];
        frustum[4][2] = clip[11] - clip[10];
        frustum[4][3] = clip[15] - clip[14];
        // Extract the NEAR plane
        frustum[5][0] = clip[3] + clip[2];
        frustum[5][1] = clip[7] + clip[6];
        frustum[5][2] = clip[11] + clip[10];
        frustum[5][3] = clip[15] + clip[14];
        // Compute the position
        // http://www.opengl.org/discussion_boards/showthread.php/178484-Extracting-camera-position-from-a-ModelView-Matrix
        final Vector4f nPos = view.invert().getColumn(3);
        position = nPos.div(nPos.getW()).toVector3();
        // Invalidate the caches
        vertices = null;
        farPlane = -1;
        nearPlane = -1;
    }
51971
function ( focalLength ) {

		// see http://www.bobatkins.com/photography/technical/field_of_view.html
		var vExtentSlope = 0.5 * this.getFilmHeight() / focalLength;

		this.fov = THREE.Math.RAD2DEG * 2 * Math.atan( vExtentSlope );
		this.updateProjectionMatrix();

	}
638527
public synchronized Rect getFramingRectInPreview() {
    if (framingRectInPreview == null) {
      Rect framingRect = getFramingRect();
      if (framingRect == null) {
        return null;
      }
      Rect rect = new Rect(framingRect);
      Point cameraResolution = configManager.getCameraResolution();
      Point screenResolution = configManager.getScreenResolution();
      if (cameraResolution == null || screenResolution == null) {
        // Called early, before init even finished
        return null;
      }
      rect.left = rect.left * cameraResolution.x / screenResolution.x;
      rect.right = rect.right * cameraResolution.x / screenResolution.x;
      rect.top = rect.top * cameraResolution.y / screenResolution.y;
      rect.bottom = rect.bottom * cameraResolution.y / screenResolution.y;
      framingRectInPreview = rect;
    }
    return framingRectInPreview;
  }
164128
public <E extends LogEntry> void writeTrace(LogTrace<E> logTrace) throws PerspectiveException, IOException{
		if(logPerspective == LogPerspective.ACTIVITY_PERSPECTIVE)
			throw new PerspectiveException(PerspectiveError.WRITE_TRACE_IN_ACTIVITY_PERSPECTIVE);
		
		prepare();
		if(!headerWritten){
			write(logFormat.getFileHeader());
			headerWritten = true;
		}
		output.write(logFormat.getTraceAsString(logTrace));
	}
142443
private static float computeFocus(float viewSize, float drawableSize, float currentTranslation, float focusCoordinate) {
		if(currentTranslation > 0 && focusCoordinate < currentTranslation) {
			return currentTranslation;
		} else if(currentTranslation < viewSize - drawableSize && focusCoordinate > currentTranslation + drawableSize) {
			return drawableSize + currentTranslation;
		}

		return focusCoordinate;
	}
65578
public Matrix4d reflect(Quaterniondc orientation, Vector3dc point, Matrix4d dest) {
        double num1 = orientation.x() + orientation.x();
        double num2 = orientation.y() + orientation.y();
        double num3 = orientation.z() + orientation.z();
        double normalX = orientation.x() * num3 + orientation.w() * num2;
        double normalY = orientation.y() * num3 - orientation.w() * num1;
        double normalZ = 1.0 - (orientation.x() * num1 + orientation.y() * num2);
        return reflect(normalX, normalY, normalZ, point.x(), point.y(), point.z(), dest);
    }