本文整理匯總了Java中java.lang.Math.toDegrees方法的典型用法代碼示例。如果您正苦於以下問題:Java Math.toDegrees方法的具體用法?Java Math.toDegrees怎麽用?Java Math.toDegrees使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.lang.Math
的用法示例。
在下文中一共展示了Math.toDegrees方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: Missile
import java.lang.Math; //導入方法依賴的package包/類
/**
* Intentional use is for friendly missiles.
* @param s Sprite
* @param side Friend or foe / true or false
* @param status Destroyed or not
* @param x starting x coordinate
* @param y starting y coordinate
* @param mouseX is mouse's x
* @param mouseY is mouse's y
*/
public Missile(String spriteLoc, boolean side, int x, int y, MainApplication app, int mouseX, int mouseY) {
program = app;
double theta =Math.toDegrees(Math.atan2((mouseY - y),(mouseX - x)));
roundedAngle = Math.abs((int)Math.round(theta/15)*15);
String spriteLoc2 = "Missiles/friendlyMissile_r" + roundedAngle + ".png";
// System.out.println("Theta = " + roundedAngle);
System.out.println(spriteLoc2);
sprite = SpriteStore.get().getSprite(spriteLoc2);
isFriendly = side;
isDestroyed = false;
this.x = x;
this.y = y;
radius = 10;
// if (isFriendly)
// radius *= -1;
double dx = mouseX - this.x;
double dy = mouseY - this.y;
angle = Math.abs(Math.toDegrees(Math.atan2(dy, dx)));
isHit = false;
this.hitbox = new GRectangle(x, y, Missile.WIDTH, Missile.HEIGHT); //TODO need to make the hit box reflect the orientation/size of the missile
this.sprite.scale(SCALE, SCALE);
System.out.print("x: " + mouseX + " y: " + mouseY + " a: " + angle + " rounded: " + theta + "\n");
//TODO remove, test only to generate the boxes for visual example
if(this.DEBUG_MODE == true){
this.debugHitbox = new GRect(x, y, Missile.WIDTH, Missile.HEIGHT);
}
}
示例2: yToLat
import java.lang.Math; //導入方法依賴的package包/類
public static double yToLat(double aY) {
return Math.toDegrees(Math.atan(Math.exp(aY / RADIUS)) * 2 - PI_DIV_2);
}
示例3: xToLon
import java.lang.Math; //導入方法依賴的package包/類
public static double xToLon(double aX) {
return Math.toDegrees(aX / RADIUS);
}