List of usage examples for java.lang Math atan2
@HotSpotIntrinsicCandidate public static double atan2(double y, double x)
From source file:com.rapidminer.tools.expression.internal.function.AntlrParserTrigonometricTest.java
@Test public void atan2PositiveNegative() { try {/* w ww . jav a 2s. co m*/ Expression expression = getExpressionWithFunctionContext("atan2(10,-10)"); assertEquals(ExpressionType.DOUBLE, expression.getExpressionType()); assertEquals(Math.atan2(10, -10), expression.evaluateNumerical(), 1e-15); } catch (ExpressionException e) { assertNotNull(e.getMessage()); } }
From source file:com.appeaser.sublimepickerlibrary.timepicker.RadialTimePickerView.java
private int getDegreesFromXY(float x, float y, boolean constrainOutside) { // Ensure the point is inside the touchable area. final int innerBound; final int outerBound; if (mIs24HourMode && mShowHours) { innerBound = mMinDistForInnerNumber; outerBound = mMaxDistForOuterNumber; } else {//from w ww . j av a 2s .c o m final int index = mShowHours ? HOURS : MINUTES; final int center = mCircleRadius - mTextInset[index]; innerBound = center - mSelectorRadius; outerBound = center + mSelectorRadius; } final double dX = x - mXCenter; final double dY = y - mYCenter; final double distFromCenter = Math.sqrt(dX * dX + dY * dY); if (distFromCenter < innerBound || constrainOutside && distFromCenter > outerBound) { return -1; } // Convert to degrees. final int degrees = (int) (Math.toDegrees(Math.atan2(dY, dX) + Math.PI / 2) + 0.5); if (degrees < 0) { return degrees + 360; } else { return degrees; } }
From source file:org.navitproject.navit.NavitGraphics.java
protected void draw_image_warp(Paint paint, int count, int p0x, int p0y, int p1x, int p1y, int p2x, int p2y, Bitmap bitmap) {/* w w w. j av a2 s .co m*/ float width; float scale; float deltaY; float deltaX; float angle; Matrix matrix; if (count == 3) { matrix = new Matrix(); deltaX = p1x - p0x; deltaY = p1y - p0y; width = (float) (Math.sqrt((deltaX * deltaX) + (deltaY * deltaY))); angle = (float) (Math.atan2(deltaY, deltaX) * 180d / Math.PI); scale = width / bitmap.getWidth(); matrix.preScale(scale, scale); matrix.postTranslate(p0x, p0y); matrix.postRotate(angle, p0x, p0y); draw_canvas.drawBitmap(bitmap, matrix, paint); } }
From source file:com.rapidminer.tools.expression.internal.function.AntlrParserTrigonometricTest.java
@Test public void atan2NullNull() { try {//from w w w. ja v a2 s . c o m Expression expression = getExpressionWithFunctionContext("atan2(0,0)"); assertEquals(ExpressionType.DOUBLE, expression.getExpressionType()); assertEquals(Math.atan2(0, 0), expression.evaluateNumerical(), 1e-15); } catch (ExpressionException e) { assertNotNull(e.getMessage()); } }
From source file:com.rapidminer.tools.expression.internal.function.AntlrParserTrigonometricTest.java
@Test public void atan2NullNinety() { try {/*from ww w . j a va2s. c o m*/ Expression expression = getExpressionWithFunctionContext("atan2(0,90)"); assertEquals(ExpressionType.DOUBLE, expression.getExpressionType()); assertEquals(Math.atan2(0, 90), expression.evaluateNumerical(), 1e-15); } catch (ExpressionException e) { assertNotNull(e.getMessage()); } }
From source file:com.rapidminer.tools.expression.internal.function.AntlrParserTrigonometricTest.java
@Test public void atan2NinetyNull() { try {/*w ww . j ava 2 s. c o m*/ Expression expression = getExpressionWithFunctionContext("atan2(90,0)"); assertEquals(ExpressionType.DOUBLE, expression.getExpressionType()); assertEquals(Math.atan2(90, 0), expression.evaluateNumerical(), 1e-15); } catch (ExpressionException e) { assertNotNull(e.getMessage()); } }
From source file:com.rapidminer.tools.expression.internal.function.AntlrParserTrigonometricTest.java
@Test public void atan2NinetyNinety() { try {// w w w. j a v a2s . c om Expression expression = getExpressionWithFunctionContext("atan2(90,90)"); assertEquals(ExpressionType.DOUBLE, expression.getExpressionType()); assertEquals(Math.atan2(90, 90), expression.evaluateNumerical(), 1e-15); } catch (ExpressionException e) { assertNotNull(e.getMessage()); } }
From source file:com.rapidminer.tools.expression.internal.function.AntlrParserTrigonometricTest.java
@Test public void atan2NullPi() { try {/*from w ww .j ava 2 s. c om*/ Expression expression = getExpressionWithFunctionContext("atan2(0,pi)"); assertEquals(ExpressionType.DOUBLE, expression.getExpressionType()); assertEquals(Math.atan2(0, Math.PI), expression.evaluateNumerical(), 1e-15); } catch (ExpressionException e) { assertNotNull(e.getMessage()); } }
From source file:com.rapidminer.tools.expression.internal.function.AntlrParserTrigonometricTest.java
@Test public void atan2NinetyPi() { try {/*from ww w. ja v a 2s. c o m*/ Expression expression = getExpressionWithFunctionContext("atan2(90,pi)"); assertEquals(ExpressionType.DOUBLE, expression.getExpressionType()); assertEquals(Math.atan2(90, Math.PI), expression.evaluateNumerical(), 1e-15); } catch (ExpressionException e) { assertNotNull(e.getMessage()); } }
From source file:com.rapidminer.tools.expression.internal.function.AntlrParserTrigonometricTest.java
@Test public void atan2PiNull() { try {//from w ww . ja v a2 s. co m Expression expression = getExpressionWithFunctionContext("atan2(pi,0)"); assertEquals(ExpressionType.DOUBLE, expression.getExpressionType()); assertEquals(Math.atan2(Math.PI, 0), expression.evaluateNumerical(), 1e-15); } catch (ExpressionException e) { assertNotNull(e.getMessage()); } }