find Point On Circle - Android Graphics

Android examples for Graphics:Path Point

Description

find Point On Circle

Demo Code

/*******************************************************************************
 * Copyright (c) 2011 MadRobot.//  w w w .  jav a 2 s  .  c o  m
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Contributors:
 *  Elton Kent - initial API and implementation
 ******************************************************************************/
//package com.java2s;
import android.graphics.PointF;

public class Main {
    public static PointF findPointOnCircle(float radius,
            float angleInDegrees, PointF origin) {
        // Convert from degrees to radians via multiplication by PI/180
        float x = (float) (radius * Math.cos(angleInDegrees * Math.PI
                / 180F))
                + origin.x;
        float y = (float) (radius * Math.sin(angleInDegrees * Math.PI
                / 180F))
                + origin.y;
        return new PointF(x, y);
    }
}

Related Tutorials