Here you can find the source of cornersToWorldFile(Point2D[] esq, Dimension size)
public static double[] cornersToWorldFile(Point2D[] esq, Dimension size)
//package com.java2s; /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana * * Copyright (C) 2008 IVER T.I. and Generalitat Valenciana. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. *//*from w ww.j a v a 2s. c o m*/ import java.awt.Dimension; import java.awt.geom.Point2D; public class Main { public static double[] cornersToWorldFile(Point2D[] esq, Dimension size) { double a = 0, b = 0, c = 0, d = 0, e = 0, f = 0; double x1 = esq[0].getX(), y1 = esq[0].getY(); double x2 = esq[1].getX(), y2 = esq[1].getY(); double x3 = esq[2].getX(), y3 = esq[2].getY(); double x4 = esq[3].getX(), y4 = esq[3].getY(); // A: X-scale a = Math.abs(Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) / size.getWidth()); // E: negative Y-scale e = -Math.abs(Math.sqrt((x1 - x4) * (x1 - x4) + (y1 - y4) * (y1 - y4)) / size.getHeight()); // C, F: upper-left coordinates c = x1; f = y1; // B & D: rotation parameters b = (a * size.getWidth() + c - x3) / size.getHeight() * -1; d = (e * size.getHeight() + f - y3) / size.getWidth() * -1; double[] wf = { a, d, b, e, c, f }; return wf; } }