Java Angle angle2pixels(double angle)

Here you can find the source of angle2pixels(double angle)

Description

Converts a value from visual angle to pixels on the standard display.

License

Open Source License

Parameter

Parameter Description
angle the visual angle in degrees

Return

the value in pixels

Declaration

public static double angle2pixels(double angle) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /** The viewing distance to the screen, in inches. */
    public static double viewingDistance = 30;
    /** The value of pixels per inch on the standard display. */
    public static double pixelsPerInch = 72;

    /**//w ww .j ava 2 s  . co  m
     * Converts a value from visual angle to pixels on the standard display.
     * 
     * @param angle
     *            the visual angle in degrees
     * @return the value in pixels
     */
    public static double angle2pixels(double angle) {
        return viewingDistance * Math.tan(deg2rad(angle)) * pixelsPerInch;
    }

    /**
     * Converts a value from degrees to radians.
     * 
     * @param degrees
     *            the value in degrees
     * @return the value in radians
     */
    public static double deg2rad(double degrees) {
        return degrees * (Math.PI / 180.0);
    }
}

Related

  1. angle(double x1, double y1, double x2, double y2)
  2. angle(double[] vec1, double[] vec2)
  3. angle(float x, float y, float x1, float y1)
  4. angle(float x1, float y1, float x2, float y2)
  5. angle2degree(double angle)
  6. angle360Limit(float angle)
  7. angleAdd(int i, final int i1)
  8. angleDistance(double angle1, double angle2)
  9. angleEquals(double angle1, double angle2, double epsilon)