List of usage examples for java.lang Math atan
public static double atan(double a)
From source file:es.emergya.geo.util.Lambert.java
/** * Initializes from projected coordinates (conic projection). Note that * reference ellipsoid used by Lambert is Clark * * @param eastNorth projected coordinates pair in meters * @param Xs false east (coordinate system origin) in meters * @param Ys false north (coordinate system origin) in meters * @param c projection constant/*w w w. ja v a 2 s .com*/ * @param n projection exponent * @return LatLon in radian */ private LatLon Geographic(EastNorth eastNorth, double Xs, double Ys, double c, double n) { double dx = eastNorth.east() - Xs; double dy = Ys - eastNorth.north(); double R = Math.sqrt(dx * dx + dy * dy); double gamma = Math.atan(dx / dy); double l = -1.0 / n * Math.log(Math.abs(R / c)); l = Math.exp(l); double lon = lg0 + gamma / n; double lat = 2.0 * Math.atan(l) - Math.PI / 2.0; double delta = 1.0; while (delta > epsilon) { double eslt = Ellipsoid.clarke.e * Math.sin(lat); double nlt = 2.0 * Math.atan(Math.pow((1.0 + eslt) / (1.0 - eslt), Ellipsoid.clarke.e / 2.0) * l) - Math.PI / 2.0; delta = Math.abs(nlt - lat); lat = nlt; } return new LatLon(lat, lon); // in radian }
From source file:org.cirdles.ambapo.UTMToLatLong.java
/** * // w w w .ja v a 2 s . c o m * @param originalTau * @param sigma * @param eccentricity * @param hemisphere * @return latitude */ private static BigDecimal calcLatitude(BigDecimal originalTau, BigDecimal sigma, BigDecimal eccentricity, char hemisphere) { BigDecimal funcOfTau = functionOfTau(originalTau, sigma, originalTau).setScale(PRECISION, RoundingMode.HALF_UP); BigDecimal changeInTau = changeInTau(eccentricity, originalTau, sigma); BigDecimal newTau = originalTau.subtract(funcOfTau.divide(changeInTau, PRECISION, RoundingMode.HALF_UP)); BigDecimal latitude = (new BigDecimal(Math.atan(newTau.doubleValue()))) .multiply(new BigDecimal(180.0 / Math.PI)); if (hemisphere == 'S') latitude = latitude.multiply(new BigDecimal(-1)); return latitude; }
From source file:org.jfree.experimental.chart.renderer.xy.VectorRenderer.java
/** * Draws the block representing the specified item. * /*www . j a v a2 s . c o m*/ * @param g2 the graphics device. * @param state the state. * @param dataArea the data area. * @param info the plot rendering info. * @param plot the plot. * @param domainAxis the x-axis. * @param rangeAxis the y-axis. * @param dataset the dataset. * @param series the series index. * @param item the item index. * @param crosshairState the crosshair state. * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { double x = dataset.getXValue(series, item); double y = dataset.getYValue(series, item); double dx = 0.0; double dy = 0.0; if (dataset instanceof VectorXYDataset) { dx = ((VectorXYDataset) dataset).getDeltaXValue(series, item); dy = ((VectorXYDataset) dataset).getDeltaYValue(series, item); } double xx0 = domainAxis.valueToJava2D(x, dataArea, plot.getDomainAxisEdge()); double yy0 = rangeAxis.valueToJava2D(y, dataArea, plot.getRangeAxisEdge()); double xx1 = domainAxis.valueToJava2D(x + dx, dataArea, plot.getDomainAxisEdge()); double yy1 = rangeAxis.valueToJava2D(y + dy, dataArea, plot.getRangeAxisEdge()); Line2D line; PlotOrientation orientation = plot.getOrientation(); if (orientation.equals(PlotOrientation.HORIZONTAL)) { line = new Line2D.Double(yy0, xx0, yy1, xx1); } else { line = new Line2D.Double(xx0, yy0, xx1, yy1); } g2.setPaint(getItemPaint(series, item)); g2.setStroke(getItemStroke(series, item)); g2.draw(line); // calculate the arrow head and draw it... double dxx = (xx1 - xx0); double dyy = (yy1 - yy0); double bx = xx0 + (1.0 - this.baseLength) * dxx; double by = yy0 + (1.0 - this.baseLength) * dyy; double cx = xx0 + (1.0 - this.headLength) * dxx; double cy = yy0 + (1.0 - this.headLength) * dyy; double angle = 0.0; if (dxx != 0.0) { angle = Math.PI / 2.0 - Math.atan(dyy / dxx); } double deltaX = 2.0 * Math.cos(angle); double deltaY = 2.0 * Math.sin(angle); double leftx = cx + deltaX; double lefty = cy - deltaY; double rightx = cx - deltaX; double righty = cy + deltaY; GeneralPath p = new GeneralPath(); p.moveTo((float) xx1, (float) yy1); p.lineTo((float) rightx, (float) righty); p.lineTo((float) bx, (float) by); p.lineTo((float) leftx, (float) lefty); p.closePath(); g2.draw(p); }
From source file:org.cirdles.ambapo.UTMToLatLong.java
/** * //w w w. j a va 2 s .c om * @param zoneCentralMeridian * @param etaPrime * @param xiPrime * @return longitude */ private static BigDecimal calcLongitude(double zoneCentralMeridian, BigDecimal etaPrime, BigDecimal xiPrime) { double longitudeRadians = Math.atan(Math.sinh(etaPrime.doubleValue()) / Math.cos(xiPrime.doubleValue())); BigDecimal changeInLongitude = new BigDecimal(longitudeRadians * 180.0 / Math.PI); BigDecimal longitude = new BigDecimal(zoneCentralMeridian).add(changeInLongitude); return longitude; }
From source file:tools.help.java
/** * POZOR neuprauje sa vyska sfunk?ne suradnice su XYZ * * @param LCcoordinates1 globalne suradnice lokalneho sysemu bod 1 * @param LCcoordinates2 globalne suradnice lokalneho sysemu bod 2 * @param X Z bod v globalnych sur ktory transformujeme do LC pri?om 00je * LCCOORDINATES1// w ww . j av a 2 s .co m * @return vrati XZ 0=x 1=Z */ public static double[] CorToLC(double[] LCcoordinates1, double[] LCcoordinates2, double X, double Z) { //double GCX = constants.getGCcoordinates()[0]; // double GCZ = constants.getGCcoordinates()[2]; double P1XGC = X; double P1ZGC = Z; double LCX1 = LCcoordinates1[0]; double LCZ1 = LCcoordinates1[2]; double LCX2 = LCcoordinates2[0]; double LCZ2 = LCcoordinates2[2]; double alpha = 0; if (LCX1 == LCX2) { if (LCZ1 - LCZ2 < 0) { alpha = Math.PI / 2; } if (LCZ1 - LCZ2 > 0) { alpha = -Math.PI / 2; } } // n ochrana pred 90 stupnami a delenim nulou else { alpha = Math.atan((LCZ1 - LCZ2) / (LCX1 - LCX2)); // else{ alpha = Math.atan2((LCX2 - LCX1),(LCZ2 - LCZ1) ); // uhol otocenia else{ alpha = Math.atan((LCZ1 - LCZ2) / (LCX1 - LCX2)); // uhol otocenia System.out.println(alpha); } double P1XLC = (P1XGC - LCX1) * Math.cos(alpha) + (P1ZGC - LCZ1) * Math.sin(alpha); double P1ZLC = (P1ZGC - LCZ1) * Math.cos(alpha) + (P1XGC - LCX1) * Math.sin(alpha); double[] XZcor = new double[2]; XZcor[0] = P1XLC; XZcor[1] = P1ZLC; return XZcor; }
From source file:syncleus.dann.data.vector.Vector.java
/** * Obtain the angle of a particular dimension. * * @param dimension The dimension you want the angle of. the first dimension is 1. * the last is one less than the total number of dimensions. * @return returns a value representing the angle between Pi/2 and -Pi/2 * @since 1.0/* www . j a v a 2 s . c o m*/ */ public double getAngularComponent(final int dimension) { if (dimension <= 0) throw new IllegalArgumentException(DIMENSIONS_BELOW_ONE); if ((dimension - 1) > this.data.length) throw new IllegalArgumentException( "dimensions is larger than the dimensionality (minus 1) of this point"); final double[] currentCoords = this.data.clone(); double squaredSum = 0.0; for (int coordinateIndex = currentCoords.length - 1; coordinateIndex >= dimension; coordinateIndex--) squaredSum += Math.pow(currentCoords[coordinateIndex], 2.0); if (dimension == (this.getDimension() - 1)) return Math.atan2(Math.sqrt(squaredSum), currentCoords[dimension - 1]); else { if (currentCoords[dimension - 1] == 0.0d) return Math.PI / 2.0d; return Math.atan(Math.sqrt(squaredSum) / currentCoords[dimension - 1]); } }
From source file:omr.sheet.SkewBuilder.java
private void detectSticks() { Stick stick;//from w w w. j a v a 2s .c o m // Try to aggregate sections into sticks. Visit all sections of the lag for (GlyphSection s : sLag.getVertices()) { StickSection section = (StickSection) s; if (logger.isFineEnabled()) { logger.fine(section.toString()); } // We consider only significant chunks if (isMajorChunk(section)) { // Is this chunk already part of a stick ? if (section.getGlyph() != null) { // If so, reuse the stick stick = (Stick) section.getGlyph(); } else { // Otherwise, start a brand new stick stick = new BasicStick(sheet.getInterline()); // Include this section in the stick list stick.addSection(section, Glyph.Linking.LINK_BACK); // Register the stick in containing lag // Store this new stick into the stick table sticks.add((Stick) sLag.addGlyph(stick)); } // Now, from this stick section, Look at following connected // chunks for (GlyphSection gs : section.getTargets()) { StickSection lnkSection = (StickSection) gs; if (isMajorChunk(lnkSection) && areCompatible(section, lnkSection)) { // If this section is already part of (another) stick, // then merge this other stick with ours if (lnkSection.getGlyph() != null) { // Add the content of the other stick if (lnkSection.getGlyph() != stick) { stick.addGlyphSections(lnkSection.getGlyph(), Glyph.Linking.LINK_BACK); sticks.remove(lnkSection.getGlyph()); } } else { // Let's add this section to the stick stick.addSection(lnkSection, Glyph.Linking.LINK_BACK); } } } if (logger.isFineEnabled()) { stick.dump(); } } } // Now process these sticks if (!sticks.isEmpty()) { // Sort the sticks on their length, longest first (so the swap) Collections.sort(sticks, Stick.reverseLengthComparator); // Length of longest stick Iterator<Stick> it = sticks.iterator(); Stick longest = it.next(); lengthThreshold = (int) ((double) longest.getLength() * constants.sizeRatio.getValue()); double slopeSum = longest.getLine().getSlope() * longest.getLength(); double slopeNb = longest.getLength(); // Compute on sticks w/ significant length while (it.hasNext()) { stick = it.next(); if (stick.getLength() >= lengthThreshold) { slopeSum += (stick.getLine().getSlope() * stick.getLength()); slopeNb += stick.getLength(); //stick.dump (false); } else { break; // Remaining ones are shorter! } } slope = slopeSum / slopeNb; angle = Math.atan(slope); } }
From source file:net.cpacm.library.indicator.SpringIndicator.SpringIndicator.java
@Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { int count = viewPager.getAdapter().getCount(); if (viewPager.getAdapter() instanceof InfinitePagerAdapter) { count = ((InfinitePagerAdapter) viewPager.getAdapter()).getRealCount(); }/*from ww w . ja v a 2 s . co m*/ position = position % count; springView.setCycling(false); if (position == tabs.size() - 1) { springView.setCycling(true); } if (position < tabs.size() - 1) { // radius float radiusOffsetHead = 0.5f; if (positionOffset < radiusOffsetHead) { springView.getHeadPoint().setRadius(radiusMin); } else { springView.getHeadPoint().setRadius( ((positionOffset - radiusOffsetHead) / (1 - radiusOffsetHead) * radiusOffset + radiusMin)); } float radiusOffsetFoot = 0.5f; if (positionOffset < radiusOffsetFoot) { springView.getFootPoint() .setRadius((1 - positionOffset / radiusOffsetFoot) * radiusOffset + radiusMin); } else { springView.getFootPoint().setRadius(radiusMin); } // x float headX = 1f; if (positionOffset < headMoveOffset) { float positionOffsetTemp = positionOffset / headMoveOffset; headX = (float) ((Math.atan(positionOffsetTemp * acceleration * 2 - acceleration) + (Math.atan(acceleration))) / (2 * (Math.atan(acceleration)))); } springView.getHeadPoint().setX(getTabX(position) - headX * getPositionDistance(position)); float footX = 0f; if (positionOffset > footMoveOffset) { float positionOffsetTemp = (positionOffset - footMoveOffset) / (1 - footMoveOffset); footX = (float) ((Math.atan(positionOffsetTemp * acceleration * 2 - acceleration) + (Math.atan(acceleration))) / (2 * (Math.atan(acceleration)))); } springView.getFootPoint().setX(getTabX(position) - footX * getPositionDistance(position)); // reset radius if (positionOffset == 0) { springView.getHeadPoint().setRadius(radiusMax); springView.getFootPoint().setRadius(radiusMax); } } else if (position == tabs.size() - 1) { springView.getHeadPoint().setX(getTabX(position)); springView.getHeadPoint().setRadius(radiusMax * (1 - positionOffset)); springView.getFootPoint().setX(getTabX(0)); springView.getFootPoint().setRadius(radiusMax * (positionOffset)); } else { springView.getHeadPoint().setX(getTabX(position)); springView.getFootPoint().setX(getTabX(position)); springView.getHeadPoint().setRadius(radiusMax); springView.getFootPoint().setRadius(radiusMax); } // set indicator colors // https://github.com/TaurusXi/GuideBackgroundColorAnimation if (indicatorColorsId != 0) { float length = (position + positionOffset) / viewPager.getAdapter().getCount(); int progress = (int) (length * INDICATOR_ANIM_DURATION); seek(progress); } springView.postInvalidate(); if (delegateListener != null) { delegateListener.onPageScrolled(position, positionOffset, positionOffsetPixels); } }
From source file:com.zzti.fyg.widgets.SwipeRefreshLayout.java
/** * Constructor that is called when inflating SwipeRefreshLayout from XML. * /*from www . j a v a 2 s . com*/ * @param context * @param attrs */ public SwipeRefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_longAnimTime); setWillNotDraw(false); final DisplayMetrics metrics = getResources().getDisplayMetrics(); mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR); //screenWidth = metrics.widthPixels; trigger_angle = Math.atan((double) metrics.widthPixels / metrics.heightPixels); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.swiperefresh); // setEnabled(a.getBoolean(0, true)); setEnabled(true); ptr_drawable = a.getResourceId(R.styleable.swiperefresh_roateImage, R.drawable.default_ptr_rotate); ptr_flip_drawable = a.getResourceId(R.styleable.swiperefresh_flipImage, R.drawable.default_ptr_flip); finished_drawable = a.getResourceId(R.styleable.swiperefresh_finishedImage, R.drawable.ic_done_grey600_18dp); pull2refresh = a.getBoolean(R.styleable.swiperefresh_ptr, true); pull2load = a.getBoolean(R.styleable.swiperefresh_ptl, true); textSize = a.getDimension(R.styleable.swiperefresh_srlTextSize, DEFAULT_TIPS_TEXTSIZE * metrics.density); textColor = a.getColor(R.styleable.swiperefresh_srlTextColor, DEFAULT_TEXT_COLOR); type = a.getInt(R.styleable.swiperefresh_srlAnimationStyle, DEFAULT_TYPE); pullDownLabel = a.getString(R.styleable.swiperefresh_pullDownLabel); refreshingLabel = a.getString(R.styleable.swiperefresh_refreshingLabel); releaseDownLabel = a.getString(R.styleable.swiperefresh_releaseDownLabel); pullUpLabel = a.getString(R.styleable.swiperefresh_pullUpLabel); loadingLabel = a.getString(R.styleable.swiperefresh_loadingLabel); releaseUpLabel = a.getString(R.styleable.swiperefresh_releaseUpLabel); if (null == pullDownLabel || pullDownLabel.equals("")) { pullDownLabel = DEFAULT_PULL_DOWN_LABEL; } if (null == refreshingLabel || refreshingLabel.equals("")) { refreshingLabel = DEFAULT_REFRESHING_LABEL; } if (null == releaseDownLabel || releaseDownLabel.equals("")) { releaseDownLabel = DEFAULT_RELEASE_DOWN_LABEL; } if (null == pullUpLabel || pullUpLabel.equals("")) { pullUpLabel = DEFAULT_PULL_UP_LABEL; } if (null == loadingLabel || loadingLabel.equals("")) { loadingLabel = DEFAULT_LOADING_LABEL; } if (null == releaseUpLabel || releaseUpLabel.equals("")) { releaseUpLabel = DEFAULT_RELEASE_UP_LABEL; } mProgressBar = new SwipeProgressBar(this, textSize, textColor, ptr_drawable, ptr_flip_drawable, finished_drawable, type); a.recycle(); }
From source file:com.limxing.library.PullToRefresh.SwipeRefreshLayout.java
/** * Constructor that is called when inflating SwipeRefreshLayout from XML. * /*from w w w. j av a 2s . co m*/ * @param context * @param attrs */ public SwipeRefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_longAnimTime); setWillNotDraw(false); final DisplayMetrics metrics = getResources().getDisplayMetrics(); mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR); // screenWidth = metrics.widthPixels; trigger_angle = Math.atan((double) metrics.widthPixels / metrics.heightPixels); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.swiperefresh); // setEnabled(a.getBoolean(0, true)); setEnabled(true); ptr_drawable = a.getResourceId(R.styleable.swiperefresh_roateImage, R.drawable.default_ptr_rotate); ptr_flip_drawable = a.getResourceId(R.styleable.swiperefresh_flipImage, R.drawable.default_ptr_flip); finished_drawable = a.getResourceId(R.styleable.swiperefresh_finishedImage, R.drawable.xlistview_success); pull2refresh = a.getBoolean(R.styleable.swiperefresh_ptr, true); pull2load = a.getBoolean(R.styleable.swiperefresh_ptl, true); textSize = a.getDimension(R.styleable.swiperefresh_srlTextSize, DEFAULT_TIPS_TEXTSIZE * metrics.density); textColor = a.getColor(R.styleable.swiperefresh_srlTextColor, DEFAULT_TEXT_COLOR); type = a.getInt(R.styleable.swiperefresh_srlAnimationStyle, DEFAULT_TYPE); pullDownLabel = a.getString(R.styleable.swiperefresh_pullDownLabel); refreshingLabel = a.getString(R.styleable.swiperefresh_refreshingLabel); releaseDownLabel = a.getString(R.styleable.swiperefresh_releaseDownLabel); pullUpLabel = a.getString(R.styleable.swiperefresh_pullUpLabel); loadingLabel = a.getString(R.styleable.swiperefresh_loadingLabel); releaseUpLabel = a.getString(R.styleable.swiperefresh_releaseUpLabel); if (null == pullDownLabel || pullDownLabel.equals("")) { pullDownLabel = DEFAULT_PULL_DOWN_LABEL; } if (null == refreshingLabel || refreshingLabel.equals("")) { refreshingLabel = DEFAULT_REFRESHING_LABEL; } if (null == releaseDownLabel || releaseDownLabel.equals("")) { releaseDownLabel = DEFAULT_RELEASE_DOWN_LABEL; } if (null == pullUpLabel || pullUpLabel.equals("")) { pullUpLabel = DEFAULT_PULL_UP_LABEL; } if (null == loadingLabel || loadingLabel.equals("")) { loadingLabel = DEFAULT_LOADING_LABEL; } if (null == releaseUpLabel || releaseUpLabel.equals("")) { releaseUpLabel = DEFAULT_RELEASE_UP_LABEL; } mProgressBar = new SwipeProgressBar(this, textSize, textColor, ptr_drawable, ptr_flip_drawable, finished_drawable, type); a.recycle(); }