public static float[] createPerspectiveMatrix (int fieldOfViewVertical, float aspectRatio, float minimumClearance, float maximumClearance) { double fieldOfViewInRad = fieldOfViewVertical * Math.PI / 180.0; return new float[] {(float)(Math.tan(fieldOfViewInRad) / aspectRatio), 0, 0, 0, 0, (float)(1 / Math.tan(fieldOfViewVertical * Math.PI / 180.0)), 0, 0, 0, 0, (minimumClearance + maximumClearance) / (minimumClearance - maximumClearance), -1, 0, 0, 2 * minimumClearance * maximumClearance / (minimumClearance - maximumClearance), 0}; }
public static float[] createPerspectiveMatrix (int fieldOfViewVertical, float aspectRatio, float minimumClearance, float maximumClearance) { double fieldOfViewInRad = fieldOfViewVertical * Math.PI / 180.0; return new float[] {(float)(Math.tan(fieldOfViewInRad) / aspectRatio), 0, 0, 0, 0, (float)(1 / Math.tan(fieldOfViewVertical * Math.PI / 180.0)), 0, 0, 0, 0, (minimumClearance + maximumClearance) / (minimumClearance - maximumClearance), -1, 0, 0, 2 * minimumClearance * maximumClearance / (minimumClearance - maximumClearance), 0}; }
@Override public void setSize(int width, int height) { this.width = width; this.height = height; this.locationZ = (float) (width / 2f / Math.tan((Math.PI / 180) * (55f / 2f))); }
private static float toTangent(float arcInDegrees) { if (arcInDegrees < 0 || arcInDegrees > 90) { throw new IllegalArgumentException("Arc must be between 0 and 90 degrees"); } return (float) Math.tan(Math.toRadians(arcInDegrees / 2)); }
private float calculateFieldOfViewInYDirection(float aspect) { boolean landscapeMode = aspect > 1; if (landscapeMode) { double halfFovX = FIELD_OF_VIEW_DEGREES / 2; double tanY = Math.tan(Math.toRadians(halfFovX)) / aspect; double halfFovY = Math.toDegrees(Math.atan(tanY)); return (float) (halfFovY * 2); } else { return FIELD_OF_VIEW_DEGREES; } } }
private static float toTangent(float arcInDegrees) { if (arcInDegrees < 0 || arcInDegrees > 90) { throw new IllegalArgumentException("Arc must be between 0 and 90 degrees"); } return (float) Math.tan(Math.toRadians(arcInDegrees / 2)); }
@Override protected ExprEval eval(double param) { return ExprEval.of(Math.tan(param)); } }
/** * Returns a random real number from the Cauchy distribution. * * @return a random real number from the Cauchy distribution. */ public static double cauchy() { return Math.tan(Math.PI * (uniform() - 0.5)); }
/** * Return a real number with a Cauchy distribution. * * @return a real number with a Cauchy distribution */ public static double cauchy() { return Math.tan(Math.PI * (uniform() - 0.5)); }
Camera.Parameters p = camera.getParameters(); int zoom = p.getZoomRatios().get(p.getZoom()).intValue(); Camera.Size sz = p.getPreviewSize(); double aspect = (double) sz.width / (double) sz.height; double thetaV = Math.toRadians(p.getVerticalViewAngle()); double thetaH = 2d * Math.atan(aspect * Math.tan(thetaV / 2)); thetaV = 2d * Math.atan(100d * Math.tan(thetaV / 2d) / zoom); thetaH = 2d * Math.atan(100d * Math.tan(thetaH / 2d) / zoom);
/** * Take Tangent of a */ @Override protected DoubleWritable doEvaluate(DoubleWritable a) { result.set(Math.tan(a.get())); return result; }
private static Matrix4f createPerspectiveProjectionMatrix(float fov, float zNear, float zFar) { float aspectRatio = (float) Display.getWidth() / Display.getHeight(); float fovY = (float) (2 * Math.atan2(Math.tan(0.5 * fov * TeraMath.DEG_TO_RAD), aspectRatio)); return MatrixUtils.createPerspectiveProjectionMatrix(fovY, aspectRatio, zNear, zFar); }
public static DoubleValue cot( AnyValue in ) { if ( in instanceof NumberValue ) { return doubleValue( 1.0 / Math.tan( ((NumberValue) in).doubleValue() ) ); } else { throw needsNumbers( "cot()" ); } }
public static DoubleValue tan( AnyValue in ) { if ( in instanceof NumberValue ) { return doubleValue( Math.tan( ((NumberValue) in).doubleValue() ) ); } else { throw needsNumbers( "tan()" ); } }
@Description("tangent") @ScalarFunction @SqlType(StandardTypes.DOUBLE) public static double tan(@SqlType(StandardTypes.DOUBLE) double num) { return Math.tan(num); }
private static double zoomAngle(double degrees, int zoom) { double theta = Math.toRadians(degrees); return 2d * Math.atan(100d * Math.tan(theta / 2d) / zoom); } Camera.Parameters p = camera.getParameters(); int zoom = p.getZoomRatios().get(p.getZoom()).intValue(); double thetaH = zoomAngle(p.getHorizontalViewAngle(), zoom); double thetaV = zoomAngle(p.getVerticalViewAngle(), zoom);
public Value tan() throws KettleValueException { if ( isNull() ) { return this; } if ( isNumeric() ) { setValue( Math.tan( getNumber() ) ); } else { throw new KettleValueException( "Function TAN only works on a number" ); } return this; }
@Test public void testVectorTan() throws HiveException { VectorizedRowBatch b = getVectorizedRowBatchDoubleInDoubleOut(); DoubleColumnVector resultV = (DoubleColumnVector) b.cols[1]; b.cols[0].noNulls = true; VectorExpression expr = new FuncTanDoubleToDouble(0, 1); expr.evaluate(b); Assert.assertEquals(Math.tan(0.5d), resultV.vector[4]); }
private Point2D makeControlPoint(final double endX, final double endY, final Circle circle, final int numSegments, int direction) { final double controlPointDistance = (4.0 / 3.0) * Math.tan(Math.PI / (2 * numSegments)) * circle.getRadius(); final Point2D center = new Point2D(circle.getCenterX(), circle.getCenterY()); final Point2D end = new Point2D(endX, endY); Point2D perp = rotate(center, end, direction * Math.PI / 2.); Point2D diff = perp.subtract(end); diff = diff.normalize(); diff = scale(diff, controlPointDistance); return end.add(diff); }