List of usage examples for java.lang Math atan
public static double atan(double a)
From source file:com.rapidminer.tools.expression.internal.function.AntlrParserTrigonometricTest.java
@Test public void atanDouble() { try {//w w w.j av a2 s .co m Expression expression = getExpressionWithFunctionContext("atan(33.3)"); assertEquals(ExpressionType.DOUBLE, expression.getExpressionType()); assertEquals(Math.atan(33.3), expression.evaluateNumerical(), 1e-15); } catch (ExpressionException e) { assertNotNull(e.getMessage()); } }
From source file:com.rapidminer.tools.expression.internal.function.AntlrParserTrigonometricTest.java
@Test public void atanNegative() { try {// w w w . j av a 2 s . c o m Expression expression = getExpressionWithFunctionContext("atan(-10)"); assertEquals(ExpressionType.DOUBLE, expression.getExpressionType()); assertEquals(Math.atan(-10), expression.evaluateNumerical(), 1e-15); } catch (ExpressionException e) { assertNotNull(e.getMessage()); } }
From source file:com.rapidminer.tools.expression.internal.function.AntlrParserTrigonometricTest.java
@Test public void atanNinety() { try {//w w w. java2 s. c o m Expression expression = getExpressionWithFunctionContext("atan(90)"); assertEquals(ExpressionType.DOUBLE, expression.getExpressionType()); assertEquals(Math.atan(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 atanPi() { try {/*from ww w. j a v a2 s.com*/ Expression expression = getExpressionWithFunctionContext("atan(pi)"); assertEquals(ExpressionType.DOUBLE, expression.getExpressionType()); assertEquals(Math.atan(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 atanPiHalf() { try {//from ww w . j a v a2s . c om Expression expression = getExpressionWithFunctionContext("atan(pi/2)"); assertEquals(ExpressionType.DOUBLE, expression.getExpressionType()); assertEquals(Math.atan(Math.PI / 2), expression.evaluateNumerical(), 1e-15); } catch (ExpressionException e) { assertNotNull(e.getMessage()); } }
From source file:Geometry.java
/** * Return the geometry of an ellipse based on its four top points. * Integer domain. The method use the generic createEllipse() * method for the main task, and then transforms this according * to any rotation or skew defined by the given top points. * /*from www .j a v a 2s . c o m*/ * @param x X array of four top points of ellipse. * @param y Y array of four top points of ellipse. * @return Geometry of ellipse [x,y,x,y...]. */ public static int[] createEllipse(int[] x, int[] y) { // Center of ellipse int x0 = (x[0] + x[2]) / 2; int y0 = (y[0] + y[2]) / 2; // Angle between axis define skew double[] p0 = { (double) x0, (double) y0, 0.0 }; double[] p1 = { (double) x[0], (double) y[0], 0.0 }; double[] p2 = { (double) x[1], (double) y[1], 0.0 }; double axisAngle = Geometry.computeAngle(p0, p1, p2); // dx / dy double dx = Geometry.length(x0, y0, x[1], y[1]); double dy = Geometry.length(x0, y0, x[0], y[0]) * Math.sin(axisAngle); // Create geometry for unrotated / unsheared ellipse int[] ellipse = createEllipse(x0, y0, (int) Math.round(dx), (int) Math.round(dy)); int nPoints = ellipse.length / 2; // Shear if neccessary. If angle is close to 90 there is no shear. // If angle is close to 0 or 180 shear is infinite, and we set // it to zero as well. if (!Geometry.equals(axisAngle, Math.PI / 2.0, 0.1) && !Geometry.equals(axisAngle, Math.PI, 0.1) && !Geometry.equals(axisAngle, 0.0, 0.1)) { double xShear = 1.0 / Math.tan(axisAngle); for (int i = 0; i < nPoints; i++) ellipse[i * 2 + 0] += Math.round((ellipse[i * 2 + 1] - y0) * xShear); } // Rotate int ddx = x[1] - x0; int ddy = y0 - y[1]; double angle; if (ddx == 0 && ddy == 0) angle = 0.0; else if (ddx == 0) angle = Math.PI / 2.0; else angle = Math.atan((double) ddy / (double) ddx); double cosAngle = Math.cos(angle); double sinAngle = Math.sin(angle); for (int i = 0; i < nPoints; i++) { int xr = (int) Math .round(x0 + (ellipse[i * 2 + 0] - x0) * cosAngle - (ellipse[i * 2 + 1] - y0) * sinAngle); int yr = (int) Math .round(y0 - (ellipse[i * 2 + 1] - y0) * cosAngle - (ellipse[i * 2 + 0] - x0) * sinAngle); ellipse[i * 2 + 0] = xr; ellipse[i * 2 + 1] = yr; } return ellipse; }
From source file:org.apache.calcite.runtime.SqlFunctions.java
/** SQL <code>ATAN</code> operator applied to long values. */ public static double atan(long b0) { return Math.atan(b0); }
From source file:org.apache.calcite.runtime.SqlFunctions.java
/** SQL <code>ATAN</code> operator applied to BigDecimal values. */ public static double atan(BigDecimal b0) { return Math.atan(b0.doubleValue()); }
From source file:org.apache.calcite.runtime.SqlFunctions.java
/** SQL <code>ATAN</code> operator applied to double values. */ public static double atan(double b0) { return Math.atan(b0); }
From source file:radu.pidroid.Controller.java
@Override public void onMove(JoystickView view, double x, double y) { int newX = ((int) (x * 101)) / 20 * 20; int newY = ((int) (y * 101)) / 20 * -20; switch (view.getId()) { case R.id.cameraJoystickView: case R.id.largeCameraJoystickView: // If any of the pan/tilt positions have changed, tell PiDroid about it. if (cameraX != newX || cameraY != newY) { cameraX = newX;/* w w w .j a v a 2s. c om*/ cameraY = newY; mMessenger.updateCameraPosition(cameraX, cameraY); Log.d("Controller: onMove():", "cameraX = " + cameraX + ", cameraY = " + cameraY); } // if break; case R.id.directionJoystickView: // If there is a new roverSpeed, tell PiDroid about it. if (roverSpeed != newY) { roverSpeed = newY; mMessenger.updateRoverSpeed(roverSpeed); //Log.d("Controller: onMove():", "roverSpeed = " + roverSpeed); } // if // Compute the angle made by the joystick measured with respect to the trigonometric circle. if (newX > 0) newX = (int) (Math.toDegrees(Math.atan(Math.abs((double) newY / newX)))); else newX = (int) (Math.toDegrees(Math.atan(Math.abs((double) newX / newY))) + 90); // If there is a new turnAngle (or turning angle), tell PiDroid about it. if (turnAngle != newX) { turnAngle = newX; //Log.d("Controller: onMove():", "turn angle = " + turnAngle); mMessenger.updateRoverSpeed(roverSpeed); } // if break; } // switch }