Java examples for java.lang:Math Geometry
Converts an angle (in degrees, assuming 0 degrees is straight up, and clockwise is an increase in angle, and positive X is right) to an X location point.
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { int angle = 2; System.out.println(toX(angle)); }/*from w ww .j a v a 2 s.c om*/ /** * Converts an angle (in degrees, assuming 0 degrees is straight up, and * clockwise is an increase in angle, and positive X is right) to an X * location point. If this were used in conjunction with toY to generate * points for all angles from 0 to 360, the resulting shape would be a * circle with a radius of 1. * * @param angle * @return */ public static double toX(int angle) { return Math.sin(Math.toRadians(angle)); } }