/* Copyright (C) 2004 - 2014 A.Vontobel  
 * Classes in drawj2d.bgd are derived from fachwerk.sourceforge.net, 2014
 *
 * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * The license is in LICENCE-GPL.txt.
 * If not, see http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
 */

package net.sf.drawj2d.bgd;

public class clHintergrundKreis {
    
    private double[] zentrum = new double[2];
    private double radius;
    
    clHintergrundKreis(double X, double Z, double radius) {
        zentrum[0] = X;
        zentrum[1] = Z;
        this.radius = radius;
    }

    /** Skaliert Hinterkreis.
     Warnung: Verzerrte Skalierung von Kreisen kann nur durch geometrisch
     gemittelten Kreis angenähert werden. */
    public boolean skaliere(double faktorx, double faktorz) {
        assert (Math.abs(faktorx) >= 1E-9);
        assert (Math.abs(faktorz) >= 1E-9);
        zentrum[0] = faktorx * zentrum[0];
        zentrum[1] = faktorz * zentrum[1];
        double faktor = Math.sqrt(Math.abs(faktorx * faktorz)); // geometrisches Mittel
        radius = faktor * radius;
        return true;
    }
    
    public void verschiebe(double dx, double dz) {
        zentrum[0] += dx;
        zentrum[1] += dz;
    }

    /** Rotiert im Uhrzeigersinn.
    * @param rot Rotation im Uhrzeigersinn, in Radianten */
    public void rotiere(double rot) {
        double X = zentrum[0];
        double Z = zentrum[1];
        zentrum[0] = X * Math.cos(rot) - Z * Math.sin(rot);
        zentrum[1] = X * Math.sin(rot) + Z * Math.cos(rot);
    }
    
    /** Gibt die Koordinate des Hintergrundpunktes zurück.
     */
    public double[] getZentrum() {
        return zentrum;
    }
    
    public double getRadius() {
        return radius;
    }
}
 

Ads help maintain this website.