List of usage examples for java.lang Math atan2
@HotSpotIntrinsicCandidate public static double atan2(double y, double x)
From source file:org.ecocean.MarkedIndividual.java
public float distFrom(float lat1, float lng1, float lat2, float lng2) { double earthRadius = 3958.75; double dLat = Math.toRadians(lat2 - lat1); double dLng = Math.toRadians(lng2 - lng1); double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * Math.sin(dLng / 2) * Math.sin(dLng / 2); double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); double dist = earthRadius * c; int meterConversion = 1609; return new Float(dist * meterConversion).floatValue(); }
From source file:services.SimulationService.java
public void rotateToFaceTarget(SWGObject object, SWGObject target) { float radians = (float) (((float) Math.atan2(target.getPosition().z - object.getPosition().z, target.getPosition().x - object.getPosition().x)) - object.getRadians()); transform(object, radians, object.getPosition()); }
From source file:services.SimulationService.java
public void faceTarget(SWGObject object, SWGObject target) { float direction = (float) Math.atan2(target.getWorldPosition().x - object.getWorldPosition().x, target.getWorldPosition().z - object.getWorldPosition().z); if (direction < 0) { direction = (float) (2 * Math.PI + direction); }//from www. ja v a 2s . c o m if (Math.abs(direction - object.getRadians()) < 0.05) { return; } Quaternion quaternion = new Quaternion((float) Math.cos(direction / 2), 0, (float) Math.sin(direction / 2), 0); if (quaternion.y < 0.0f && quaternion.w > 0.0f) { quaternion.y *= -1; quaternion.w *= -1; } if (object.getContainer() instanceof CellObject) { NGECore.getInstance().simulationService.moveObject(object, object.getPosition(), quaternion, object.getMovementCounter(), 0, (CellObject) object.getContainer()); } else { NGECore.getInstance().simulationService.moveObject(object, object.getPosition(), quaternion, object.getMovementCounter(), 0, null); } }
From source file:com.mitre.holdshort.MainActivity.java
public double bearingBetweenTwoPoints(Point loc1, Point loc2) { double lat1 = loc1.getLatitude() * Math.PI / 180; double lon1 = loc1.getLongitude() * Math.PI / 180; double lat2 = loc2.getLatitude() * Math.PI / 180; double lon2 = loc2.getLongitude() * Math.PI / 180; double dLon = lon2 - lon1; double y = Math.sin(dLon) * Math.cos(lat2); double x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon); return (Math.atan2(y, x)); // bearing in radians }
From source file:org.eclipse.january.dataset.Maths.java
/** * @param a opposite side of right-angled triangle * @param b adjacent side of right-angled triangle * @param o output can be null - in which case, a new dataset is created * @return angle of triangle: atan(b/a)//from www.j a v a 2s . c o m */ public static Dataset arctan2(final Object a, final Object b, final Dataset o) { final Dataset da = a instanceof Dataset ? (Dataset) a : DatasetFactory.createFromObject(a); final Dataset db = b instanceof Dataset ? (Dataset) b : DatasetFactory.createFromObject(b); final BroadcastIterator it = BroadcastIterator.createIterator(da, db, o, true); final Dataset result = it.getOutput(); final int is = result.getElementsPerItem(); final int dt = result.getDType(); switch (dt) { case Dataset.BOOL: boolean[] bdata = ((BooleanDataset) result).getData(); while (it.hasNext()) { bdata[it.oIndex] = Math.atan2(it.aDouble, it.bDouble) != 0; } break; case Dataset.INT8: byte[] i8data = ((ByteDataset) result).getData(); while (it.hasNext()) { i8data[it.oIndex] = (byte) toLong(Math.atan2(it.aDouble, it.bDouble)); } break; case Dataset.INT16: short[] i16data = ((ShortDataset) result).getData(); while (it.hasNext()) { i16data[it.oIndex] = (short) toLong(Math.atan2(it.aDouble, it.bDouble)); } break; case Dataset.INT32: int[] i32data = ((IntegerDataset) result).getData(); while (it.hasNext()) { i32data[it.oIndex] = (int) toLong(Math.atan2(it.aDouble, it.bDouble)); } break; case Dataset.INT64: long[] i64data = ((LongDataset) result).getData(); while (it.hasNext()) { i64data[it.oIndex] = toLong(Math.atan2(it.aDouble, it.bDouble)); } break; case Dataset.FLOAT32: float[] f32data = ((FloatDataset) result).getData(); while (it.hasNext()) { f32data[it.oIndex] = (float) Math.atan2(it.aDouble, it.bDouble); } break; case Dataset.FLOAT64: double[] f64data = ((DoubleDataset) result).getData(); while (it.hasNext()) { f64data[it.oIndex] = Math.atan2(it.aDouble, it.bDouble); } break; case Dataset.ARRAYINT8: byte[] ai8data = ((CompoundByteDataset) result).getData(); if (is == 1) { while (it.hasNext()) { ai8data[it.oIndex] = (byte) toLong(Math.atan2(it.aDouble, it.bDouble)); } } else if (da.getElementsPerItem() == 1) { while (it.hasNext()) { ai8data[it.oIndex] = (byte) toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai8data[it.oIndex + j] = (byte) toLong(Math.atan2(it.aDouble, db.getElementDoubleAbs(it.bIndex + j))); } } } else if (db.getElementsPerItem() == 1) { while (it.hasNext()) { ai8data[it.oIndex] = (byte) toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai8data[it.oIndex + j] = (byte) toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + j), it.bDouble)); } } } else { while (it.hasNext()) { ai8data[it.oIndex] = (byte) toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai8data[it.oIndex + j] = (byte) toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + j), db.getElementDoubleAbs(it.bIndex + j))); } } } break; case Dataset.ARRAYINT16: short[] ai16data = ((CompoundShortDataset) result).getData(); if (is == 1) { while (it.hasNext()) { ai16data[it.oIndex] = (short) toLong(Math.atan2(it.aDouble, it.bDouble)); } } else if (da.getElementsPerItem() == 1) { while (it.hasNext()) { ai16data[it.oIndex] = (short) toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai16data[it.oIndex + j] = (short) toLong( Math.atan2(it.aDouble, db.getElementDoubleAbs(it.bIndex + j))); } } } else if (db.getElementsPerItem() == 1) { while (it.hasNext()) { ai16data[it.oIndex] = (short) toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai16data[it.oIndex + j] = (short) toLong( Math.atan2(da.getElementDoubleAbs(it.aIndex + j), it.bDouble)); } } } else { while (it.hasNext()) { ai16data[it.oIndex] = (short) toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai16data[it.oIndex + j] = (short) toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + j), db.getElementDoubleAbs(it.bIndex + j))); } } } break; case Dataset.ARRAYINT32: int[] ai32data = ((CompoundIntegerDataset) result).getData(); if (is == 1) { while (it.hasNext()) { ai32data[it.oIndex] = (int) toLong(Math.atan2(it.aDouble, it.bDouble)); } } else if (da.getElementsPerItem() == 1) { while (it.hasNext()) { ai32data[it.oIndex] = (int) toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai32data[it.oIndex + j] = (int) toLong(Math.atan2(it.aDouble, db.getElementDoubleAbs(it.bIndex + j))); } } } else if (db.getElementsPerItem() == 1) { while (it.hasNext()) { ai32data[it.oIndex] = (int) toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai32data[it.oIndex + j] = (int) toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + j), it.bDouble)); } } } else { while (it.hasNext()) { ai32data[it.oIndex] = (int) toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai32data[it.oIndex + j] = (int) toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + j), db.getElementDoubleAbs(it.bIndex + j))); } } } break; case Dataset.ARRAYINT64: long[] ai64data = ((CompoundLongDataset) result).getData(); if (is == 1) { while (it.hasNext()) { ai64data[it.oIndex] = toLong(Math.atan2(it.aDouble, it.bDouble)); } } else if (da.getElementsPerItem() == 1) { while (it.hasNext()) { ai64data[it.oIndex] = toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai64data[it.oIndex + j] = toLong( Math.atan2(it.aDouble, db.getElementDoubleAbs(it.bIndex + j))); } } } else if (db.getElementsPerItem() == 1) { while (it.hasNext()) { ai64data[it.oIndex] = toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai64data[it.oIndex + j] = toLong( Math.atan2(da.getElementDoubleAbs(it.aIndex + j), it.bDouble)); } } } else { while (it.hasNext()) { ai64data[it.oIndex] = toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai64data[it.oIndex + j] = toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + j), db.getElementDoubleAbs(it.bIndex + j))); } } } break; case Dataset.ARRAYFLOAT32: float[] a32data = ((CompoundFloatDataset) result).getData(); if (is == 1) { while (it.hasNext()) { a32data[it.oIndex] = (float) Math.atan2(it.aDouble, it.bDouble); } } else if (da.getElementsPerItem() == 1) { while (it.hasNext()) { a32data[it.oIndex] = (float) Math.atan2(it.aDouble, it.bDouble); for (int j = 1; j < is; j++) { a32data[it.oIndex + j] = (float) Math.atan2(it.aDouble, db.getElementDoubleAbs(it.bIndex + j)); } } } else if (db.getElementsPerItem() == 1) { while (it.hasNext()) { a32data[it.oIndex] = (float) Math.atan2(it.aDouble, it.bDouble); for (int j = 1; j < is; j++) { a32data[it.oIndex + j] = (float) Math.atan2(da.getElementDoubleAbs(it.aIndex + j), it.bDouble); } } } else { while (it.hasNext()) { a32data[it.oIndex] = (float) Math.atan2(it.aDouble, it.bDouble); for (int j = 1; j < is; j++) { a32data[it.oIndex + j] = (float) Math.atan2(da.getElementDoubleAbs(it.aIndex + j), db.getElementDoubleAbs(it.bIndex + j)); } } } break; case Dataset.ARRAYFLOAT64: double[] a64data = ((CompoundDoubleDataset) result).getData(); if (is == 1) { while (it.hasNext()) { a64data[it.oIndex] = Math.atan2(it.aDouble, it.bDouble); } } else if (da.getElementsPerItem() == 1) { while (it.hasNext()) { a64data[it.oIndex] = Math.atan2(it.aDouble, it.bDouble); for (int j = 1; j < is; j++) { a64data[it.oIndex + j] = Math.atan2(it.aDouble, db.getElementDoubleAbs(it.bIndex + j)); } } } else if (db.getElementsPerItem() == 1) { while (it.hasNext()) { a64data[it.oIndex] = Math.atan2(it.aDouble, it.bDouble); for (int j = 1; j < is; j++) { a64data[it.oIndex + j] = Math.atan2(da.getElementDoubleAbs(it.aIndex + j), it.bDouble); } } } else { while (it.hasNext()) { a64data[it.oIndex] = Math.atan2(it.aDouble, it.bDouble); for (int j = 1; j < is; j++) { a64data[it.oIndex + j] = Math.atan2(da.getElementDoubleAbs(it.aIndex + j), db.getElementDoubleAbs(it.bIndex + j)); } } } break; default: throw new UnsupportedOperationException("atan2 does not support multiple-element dataset"); } addFunctionName(da, db, result, "atan2"); return result; }
From source file:org.eclipse.dataset.Maths.java
/** * @param a opposite side of right-angled triangle * @param b adjacent side of right-angled triangle * @param o output can be null - in which case, a new dataset is created * @return angle of triangle: atan(b/a)//w w w . j ava 2 s .c om */ public static Dataset arctan2(final Object a, final Object b, final Dataset o) { final Dataset da = a instanceof Dataset ? (Dataset) a : DatasetFactory.createFromObject(a); final Dataset db = b instanceof Dataset ? (Dataset) b : DatasetFactory.createFromObject(b); final BroadcastIterator it = BroadcastIterator.createIterator(da, db, o, true); final Dataset result = it.getOutput(); final int is = result.getElementsPerItem(); final int dt = result.getDtype(); switch (dt) { case Dataset.BOOL: boolean[] bdata = ((BooleanDataset) result).getData(); while (it.hasNext()) { bdata[it.oIndex] = Math.atan2(it.aDouble, it.bDouble) != 0; } break; case Dataset.INT8: byte[] i8data = ((ByteDataset) result).getData(); while (it.hasNext()) { i8data[it.oIndex] = (byte) toLong(Math.atan2(it.aDouble, it.bDouble)); } break; case Dataset.INT16: short[] i16data = ((ShortDataset) result).getData(); while (it.hasNext()) { i16data[it.oIndex] = (short) toLong(Math.atan2(it.aDouble, it.bDouble)); } break; case Dataset.INT32: int[] i32data = ((IntegerDataset) result).getData(); while (it.hasNext()) { i32data[it.oIndex] = (int) toLong(Math.atan2(it.aDouble, it.bDouble)); } break; case Dataset.INT64: long[] i64data = ((LongDataset) result).getData(); while (it.hasNext()) { i64data[it.oIndex] = toLong(Math.atan2(it.aDouble, it.bDouble)); } break; case Dataset.FLOAT32: float[] f32data = ((FloatDataset) result).getData(); while (it.hasNext()) { f32data[it.oIndex] = (float) Math.atan2(it.aDouble, it.bDouble); } break; case Dataset.FLOAT64: double[] f64data = ((DoubleDataset) result).getData(); while (it.hasNext()) { f64data[it.oIndex] = Math.atan2(it.aDouble, it.bDouble); } break; case Dataset.ARRAYINT8: byte[] ai8data = ((CompoundByteDataset) result).getData(); if (is == 1) { while (it.hasNext()) { ai8data[it.oIndex] = (byte) toLong(Math.atan2(it.aDouble, it.bDouble)); } } else if (da.getElementsPerItem() == 1) { while (it.hasNext()) { ai8data[it.oIndex] = (byte) toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai8data[it.oIndex + j] = (byte) toLong(Math.atan2(it.aDouble, db.getElementDoubleAbs(it.bIndex + j))); } } } else if (db.getElementsPerItem() == 1) { while (it.hasNext()) { ai8data[it.oIndex] = (byte) toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai8data[it.oIndex + j] = (byte) toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + j), it.bDouble)); } } } else { while (it.hasNext()) { ai8data[it.oIndex] = (byte) toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai8data[it.oIndex + j] = (byte) toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + j), db.getElementDoubleAbs(it.bIndex + j))); } } } break; case Dataset.ARRAYINT16: short[] ai16data = ((CompoundShortDataset) result).getData(); if (is == 1) { while (it.hasNext()) { ai16data[it.oIndex] = (short) toLong(Math.atan2(it.aDouble, it.bDouble)); } } else if (da.getElementsPerItem() == 1) { while (it.hasNext()) { ai16data[it.oIndex] = (short) toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai16data[it.oIndex + j] = (short) toLong( Math.atan2(it.aDouble, db.getElementDoubleAbs(it.bIndex + j))); } } } else if (db.getElementsPerItem() == 1) { while (it.hasNext()) { ai16data[it.oIndex] = (short) toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai16data[it.oIndex + j] = (short) toLong( Math.atan2(da.getElementDoubleAbs(it.aIndex + j), it.bDouble)); } } } else { while (it.hasNext()) { ai16data[it.oIndex] = (short) toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai16data[it.oIndex + j] = (short) toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + j), db.getElementDoubleAbs(it.bIndex + j))); } } } break; case Dataset.ARRAYINT32: int[] ai32data = ((CompoundIntegerDataset) result).getData(); if (is == 1) { while (it.hasNext()) { ai32data[it.oIndex] = (int) toLong(Math.atan2(it.aDouble, it.bDouble)); } } else if (da.getElementsPerItem() == 1) { while (it.hasNext()) { ai32data[it.oIndex] = (int) toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai32data[it.oIndex + j] = (int) toLong(Math.atan2(it.aDouble, db.getElementDoubleAbs(it.bIndex + j))); } } } else if (db.getElementsPerItem() == 1) { while (it.hasNext()) { ai32data[it.oIndex] = (int) toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai32data[it.oIndex + j] = (int) toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + j), it.bDouble)); } } } else { while (it.hasNext()) { ai32data[it.oIndex] = (int) toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai32data[it.oIndex + j] = (int) toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + j), db.getElementDoubleAbs(it.bIndex + j))); } } } break; case Dataset.ARRAYINT64: long[] ai64data = ((CompoundLongDataset) result).getData(); if (is == 1) { while (it.hasNext()) { ai64data[it.oIndex] = toLong(Math.atan2(it.aDouble, it.bDouble)); } } else if (da.getElementsPerItem() == 1) { while (it.hasNext()) { ai64data[it.oIndex] = toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai64data[it.oIndex + j] = toLong( Math.atan2(it.aDouble, db.getElementDoubleAbs(it.bIndex + j))); } } } else if (db.getElementsPerItem() == 1) { while (it.hasNext()) { ai64data[it.oIndex] = toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai64data[it.oIndex + j] = toLong( Math.atan2(da.getElementDoubleAbs(it.aIndex + j), it.bDouble)); } } } else { while (it.hasNext()) { ai64data[it.oIndex] = toLong(Math.atan2(it.aDouble, it.bDouble)); for (int j = 1; j < is; j++) { ai64data[it.oIndex + j] = toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + j), db.getElementDoubleAbs(it.bIndex + j))); } } } break; case Dataset.ARRAYFLOAT32: float[] a32data = ((CompoundFloatDataset) result).getData(); if (is == 1) { while (it.hasNext()) { a32data[it.oIndex] = (float) Math.atan2(it.aDouble, it.bDouble); } } else if (da.getElementsPerItem() == 1) { while (it.hasNext()) { a32data[it.oIndex] = (float) Math.atan2(it.aDouble, it.bDouble); for (int j = 1; j < is; j++) { a32data[it.oIndex + j] = (float) Math.atan2(it.aDouble, db.getElementDoubleAbs(it.bIndex + j)); } } } else if (db.getElementsPerItem() == 1) { while (it.hasNext()) { a32data[it.oIndex] = (float) Math.atan2(it.aDouble, it.bDouble); for (int j = 1; j < is; j++) { a32data[it.oIndex + j] = (float) Math.atan2(da.getElementDoubleAbs(it.aIndex + j), it.bDouble); } } } else { while (it.hasNext()) { a32data[it.oIndex] = (float) Math.atan2(it.aDouble, it.bDouble); for (int j = 1; j < is; j++) { a32data[it.oIndex + j] = (float) Math.atan2(da.getElementDoubleAbs(it.aIndex + j), db.getElementDoubleAbs(it.bIndex + j)); } } } break; case Dataset.ARRAYFLOAT64: double[] a64data = ((CompoundDoubleDataset) result).getData(); if (is == 1) { while (it.hasNext()) { a64data[it.oIndex] = Math.atan2(it.aDouble, it.bDouble); } } else if (da.getElementsPerItem() == 1) { while (it.hasNext()) { a64data[it.oIndex] = Math.atan2(it.aDouble, it.bDouble); for (int j = 1; j < is; j++) { a64data[it.oIndex + j] = Math.atan2(it.aDouble, db.getElementDoubleAbs(it.bIndex + j)); } } } else if (db.getElementsPerItem() == 1) { while (it.hasNext()) { a64data[it.oIndex] = Math.atan2(it.aDouble, it.bDouble); for (int j = 1; j < is; j++) { a64data[it.oIndex + j] = Math.atan2(da.getElementDoubleAbs(it.aIndex + j), it.bDouble); } } } else { while (it.hasNext()) { a64data[it.oIndex] = Math.atan2(it.aDouble, it.bDouble); for (int j = 1; j < is; j++) { a64data[it.oIndex + j] = Math.atan2(da.getElementDoubleAbs(it.aIndex + j), db.getElementDoubleAbs(it.bIndex + j)); } } } break; default: throw new UnsupportedOperationException("atan2 does not support multiple-element dataset"); } addFunctionName(da, db, result, "atan2"); return result; }
From source file:ucar.unidata.idv.flythrough.Flythrough.java
/** * _more_// w w w . j ava 2 s . c o m * * @param pt1 _more_ * @param xyz1 _more_ * @param xyz2 _more_ * @param actualPoint _more_ * @param animateMove _more_ */ protected void goTo(FlythroughPoint pt1, double[] xyz1, double[] xyz2, double[] actualPoint, boolean animateMove) { currentHeading = 180; if (actualPoint == null) { actualPoint = xyz2; } NavigatedDisplay navDisplay = viewManager.getNavigatedDisplay(); MouseBehavior mouseBehavior = navDisplay.getMouseBehavior(); double[] currentMatrix = navDisplay.getProjectionMatrix(); double[] aspect = navDisplay.getDisplayAspect(); try { if (pt1.getDescription() != null) { getHtmlView().setText(pt1.getDescription()); } else { getHtmlView().setText(""); } processReadout(pt1); float x1 = (float) xyz1[0]; float y1 = (float) xyz1[1]; float z1 = (float) xyz1[2]; float x2 = (float) xyz2[0]; float y2 = (float) xyz2[1]; float z2 = (float) xyz2[2]; double zoom = (pt1.hasZoom() ? pt1.getZoom() : getZoom()); if (zoom == 0) { zoom = 0.1; } double tiltx = (pt1.hasTiltX() ? pt1.getTiltX() : tilt[0]); double tilty = (pt1.hasTiltY() ? pt1.getTiltY() : tilt[1]); double tiltz = (pt1.hasTiltZ() ? pt1.getTiltZ() : tilt[2]); //Check for nans if ((x2 != x2) || (y2 != y2) || (z2 != z2)) { return; } if ((x1 != x1) || (y1 != y1) || (z1 != z1)) { return; } double[] m = pt1.getMatrix(); if (m == null) { m = new double[16]; Transform3D t = new Transform3D(); if (orientation.equals(ORIENT_UP)) { y2 = y1 + 100; x2 = x1; } else if (orientation.equals(ORIENT_DOWN)) { y2 = y1 - 100; x2 = x1; } else if (orientation.equals(ORIENT_LEFT)) { x2 = x1 - 100; y2 = y1; } else if (orientation.equals(ORIENT_RIGHT)) { x2 = x1 + 100; y2 = y1; } if ((x1 == x2) && (y1 == y2) && (z1 == z2)) { return; } Vector3d upVector; if (doGlobe()) { upVector = new Vector3d(x1, y1, z1); } else { upVector = new Vector3d(0, 0, 1); } //Keep flat in z for non globe Point3d p1 = new Point3d(x1, y1, z1); Point3d p2 = new Point3d(x2, y2, ((!getUseFixedZ() || doGlobe()) ? z2 : z1)); t.lookAt(p1, p2, upVector); t.get(m); EarthLocation el1 = navDisplay.getEarthLocation(p1.x, p1.y, p1.z, false); EarthLocation el2 = navDisplay.getEarthLocation(p2.x, p2.y, p2.z, false); Bearing bearing = Bearing.calculateBearing(new LatLonPointImpl(getLat(el1), getLon(el1)), new LatLonPointImpl(getLat(el2), getLon(el2)), null); currentHeading = bearing.getAngle(); double[] tiltMatrix = mouseBehavior.make_matrix(tiltx, tilty, tiltz, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0); m = mouseBehavior.multiply_matrix(tiltMatrix, m); if (aspect != null) { double[] aspectMatrix = mouseBehavior.make_matrix(0.0, 0.0, 0.0, aspect[0], aspect[1], aspect[2], 0.0, 0.0, 0.0); // m = mouseBehavior.multiply_matrix(aspectMatrix, m); } double[] scaleMatrix = mouseBehavior.make_matrix(0.0, 0.0, 0.0, zoom, 0.0, 0.0, 0.0); m = mouseBehavior.multiply_matrix(scaleMatrix, m); } currentPoint = pt1; location = currentPoint.getEarthLocation(); if (doGlobe()) { setPts(locationLine, 0, x1 * 2, 0, y1 * 2, 0, z1 * 2); // setPts(locationLine2, 0, x2 * 2, 0, y2 * 2, 0, z2 * 2); } else { setPts(locationLine, x1, x1, y1, y1, 1, -1); } RealTuple markerLocation = new RealTuple(RealTupleType.SpatialCartesian3DTuple, new double[] { x1, y1, z1 }); if (xyz1[0] != xyz2[0]) { Transform3D rotTransform; VisADGeometryArray marker = (VisADGeometryArray) getMarker().clone(); double rotx = 0; double roty = 0; double rotz = 0; rotz = -Math.toDegrees(Math.atan2(actualPoint[1] - xyz1[1], actualPoint[0] - xyz1[0])) + 90; if (doGlobe()) { Vector3d upVector = new Vector3d(x1, y1, z1); rotTransform = new Transform3D(); rotTransform.lookAt(new Point3d(x1, y1, z1), new Point3d(x2, y2, z2), upVector); Matrix3d m3d = new Matrix3d(); rotTransform.get(m3d); rotTransform = new Transform3D(m3d, new Vector3d(0, 0, 0), 1); rotTransform.invert(); // ShapeUtility.rotate(marker, rotTransform,(float)x1,(float)y1,(float)z1); ShapeUtility.rotate(marker, rotTransform); } else { double[] markerM = navDisplay.getMouseBehavior().make_matrix(rotx, roty, rotz, 1.0, 0.0, 0.0, 0.0); rotTransform = new Transform3D(markerM); ShapeUtility.rotate(marker, rotTransform); } locationMarker.setPoint(markerLocation, marker); } else { locationMarker.setPoint(markerLocation); } locationLine.setVisible(showLine); // locationLine2.setVisible(showLine); locationMarker.setVisible(showMarker); if (hasTimes && getShowTimes()) { DateTime dttm = pt1.getDateTime(); if (dttm != null) { viewManager.getAnimationWidget().setTimeFromUser(dttm); } } if (changeViewpointCbx.isSelected()) { if (animateMove) { navDisplay.animateMatrix(m, animationSpeed); } else { navDisplay.setProjectionMatrix(m); } } if (!Misc.equals(lastLocation, pt1.getEarthLocation())) { lastLocation = pt1.getEarthLocation(); EarthLocationTuple tuplePosition = new EarthLocationTuple(lastLocation.getLatitude(), lastLocation.getLongitude(), lastLocation.getAltitude()); doShare(ucar.unidata.idv.control.ProbeControl.SHARE_POSITION, tuplePosition); } } catch (NumberFormatException exc) { logException("Error parsing number:" + exc, exc); } catch (javax.media.j3d.BadTransformException bte) { try { navDisplay.setProjectionMatrix(currentMatrix); } catch (Exception ignore) { } } catch (Exception exc) { logException("Error", exc); if (animationWidget != null) { animationWidget.setRunning(false); } return; } }
From source file:org.eclipse.january.dataset.Maths.java
/** * Create a dataset of the arguments from a complex dataset * @param a/*from w ww.j a v a2 s .c o m*/ * @param inDegrees if true then return angles in degrees else in radians * @param o output can be null - in which case, a new dataset is created * @return dataset of angles */ public static Dataset angle(final Object a, final boolean inDegrees, final Dataset o) { final Dataset da = a instanceof Dataset ? (Dataset) a : DatasetFactory.createFromObject(a); if (!da.isComplex()) { throw new UnsupportedOperationException("angle does not support this dataset type"); } final SingleInputBroadcastIterator it = new SingleInputBroadcastIterator(da, o, true, false, false); final Dataset result = it.getOutput(); final int is = result.getElementsPerItem(); final int dt = result.getDType(); switch (dt) { case Dataset.INT8: final byte[] oi8data = ((ByteDataset) result).data; it.setOutputDouble(false); if (inDegrees) { while (it.hasNext()) { oi8data[it.oIndex] = (byte) toLong( Math.toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble))); } } else { while (it.hasNext()) { oi8data[it.oIndex] = (byte) toLong( Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); } } break; case Dataset.INT16: final short[] oi16data = ((ShortDataset) result).data; it.setOutputDouble(false); if (inDegrees) { while (it.hasNext()) { oi16data[it.oIndex] = (short) toLong( Math.toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble))); } } else { while (it.hasNext()) { oi16data[it.oIndex] = (short) toLong( Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); } } break; case Dataset.INT32: final int[] oi32data = ((IntegerDataset) result).data; it.setOutputDouble(false); if (inDegrees) { while (it.hasNext()) { oi32data[it.oIndex] = (int) toLong( Math.toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble))); } } else { while (it.hasNext()) { oi32data[it.oIndex] = (int) toLong( Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); } } break; case Dataset.INT64: final long[] oi64data = ((LongDataset) result).data; it.setOutputDouble(false); if (inDegrees) { while (it.hasNext()) { oi64data[it.oIndex] = toLong( Math.toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble))); } } else { while (it.hasNext()) { oi64data[it.oIndex] = toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); } } break; case Dataset.ARRAYINT8: final byte[] oai8data = ((CompoundByteDataset) result).data; it.setOutputDouble(false); if (inDegrees) { while (it.hasNext()) { final byte ox = (byte) toLong( Math.toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble))); for (int j = 0; j < is; j++) { oai8data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { final byte ox = (byte) toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); for (int j = 0; j < is; j++) { oai8data[it.oIndex + j] = ox; } } } break; case Dataset.ARRAYINT16: final short[] oai16data = ((CompoundShortDataset) result).data; it.setOutputDouble(false); if (inDegrees) { while (it.hasNext()) { final short ox = (short) toLong( Math.toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble))); for (int j = 0; j < is; j++) { oai16data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { final short ox = (short) toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); for (int j = 0; j < is; j++) { oai16data[it.oIndex + j] = ox; } } } break; case Dataset.ARRAYINT32: final int[] oai32data = ((CompoundIntegerDataset) result).data; it.setOutputDouble(false); if (inDegrees) { while (it.hasNext()) { final int ox = (int) toLong( Math.toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble))); for (int j = 0; j < is; j++) { oai32data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { final int ox = (int) toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); for (int j = 0; j < is; j++) { oai32data[it.oIndex + j] = ox; } } } break; case Dataset.ARRAYINT64: final long[] oai64data = ((CompoundLongDataset) result).data; it.setOutputDouble(false); if (inDegrees) { while (it.hasNext()) { final long ox = toLong( Math.toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble))); for (int j = 0; j < is; j++) { oai64data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { final long ox = toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); for (int j = 0; j < is; j++) { oai64data[it.oIndex + j] = ox; } } } break; case Dataset.FLOAT32: final float[] of32data = ((FloatDataset) result).data; if (inDegrees) { while (it.hasNext()) { of32data[it.oIndex] = (float) Math .toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); } } else { while (it.hasNext()) { of32data[it.oIndex] = (float) Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble); } } break; case Dataset.FLOAT64: final double[] of64data = ((DoubleDataset) result).data; if (inDegrees) { while (it.hasNext()) { of64data[it.oIndex] = Math .toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); } } else { while (it.hasNext()) { of64data[it.oIndex] = Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble); } } break; case Dataset.ARRAYFLOAT32: final float[] oaf32data = ((CompoundFloatDataset) result).data; if (inDegrees) { while (it.hasNext()) { final float ox = (float) Math .toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); for (int j = 0; j < is; j++) { oaf32data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { final float ox = (float) Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble); for (int j = 0; j < is; j++) { oaf32data[it.oIndex + j] = ox; } } } break; case Dataset.ARRAYFLOAT64: final double[] oaf64data = ((CompoundDoubleDataset) result).data; if (inDegrees) { while (it.hasNext()) { final double ox = Math.toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); for (int j = 0; j < is; j++) { oaf64data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { final double ox = Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble); for (int j = 0; j < is; j++) { oaf64data[it.oIndex + j] = ox; } } } break; case Dataset.COMPLEX64: final float[] oc64data = ((ComplexFloatDataset) result).data; if (inDegrees) { while (it.hasNext()) { oc64data[it.oIndex] = (float) Math .toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); oc64data[it.oIndex + 1] = 0; } } else { while (it.hasNext()) { oc64data[it.oIndex] = (float) Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble); oc64data[it.oIndex + 1] = 0; } } break; case Dataset.COMPLEX128: final double[] oc128data = ((ComplexDoubleDataset) result).data; if (inDegrees) { while (it.hasNext()) { oc128data[it.oIndex] = Math .toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); oc128data[it.oIndex + 1] = 0; } } else { while (it.hasNext()) { oc128data[it.oIndex] = Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble); oc128data[it.oIndex + 1] = 0; } } break; default: throw new IllegalArgumentException("angle does not support this dataset type"); } addFunctionName(result, "angle"); return result; }
From source file:org.eclipse.dataset.Maths.java
/** * Create a dataset of the arguments from a complex dataset * @param a//from w w w. j a v a2 s. c o m * @param inDegrees if true then return angles in degrees else in radians * @param o output can be null - in which case, a new dataset is created * @return dataset of angles */ public static Dataset angle(final Object a, final boolean inDegrees, final Dataset o) { final Dataset da = a instanceof Dataset ? (Dataset) a : DatasetFactory.createFromObject(a); if (!da.isComplex()) { throw new UnsupportedOperationException("angle does not support this dataset type"); } final SingleInputBroadcastIterator it = new SingleInputBroadcastIterator(da, o, true, false, false); final Dataset result = it.getOutput(); final int is = result.getElementsPerItem(); final int dt = result.getDtype(); switch (dt) { case Dataset.INT8: final byte[] oi8data = ((ByteDataset) result).data; it.setOutputDouble(false); if (inDegrees) { while (it.hasNext()) { oi8data[it.oIndex] = (byte) toLong( Math.toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble))); } } else { while (it.hasNext()) { oi8data[it.oIndex] = (byte) toLong( Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); } } break; case Dataset.INT16: final short[] oi16data = ((ShortDataset) result).data; it.setOutputDouble(false); if (inDegrees) { while (it.hasNext()) { oi16data[it.oIndex] = (short) toLong( Math.toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble))); } } else { while (it.hasNext()) { oi16data[it.oIndex] = (short) toLong( Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); } } break; case Dataset.INT32: final int[] oi32data = ((IntegerDataset) result).data; it.setOutputDouble(false); if (inDegrees) { while (it.hasNext()) { oi32data[it.oIndex] = (int) toLong( Math.toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble))); } } else { while (it.hasNext()) { oi32data[it.oIndex] = (int) toLong( Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); } } break; case Dataset.INT64: final long[] oi64data = ((LongDataset) result).data; it.setOutputDouble(false); if (inDegrees) { while (it.hasNext()) { oi64data[it.oIndex] = toLong( Math.toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble))); } } else { while (it.hasNext()) { oi64data[it.oIndex] = toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); } } break; case Dataset.ARRAYINT8: final byte[] oai8data = ((CompoundByteDataset) result).data; it.setOutputDouble(false); if (inDegrees) { while (it.hasNext()) { final byte ox = (byte) toLong( Math.toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble))); for (int j = 0; j < is; j++) { oai8data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { final byte ox = (byte) toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); for (int j = 0; j < is; j++) { oai8data[it.oIndex + j] = ox; } } } break; case Dataset.ARRAYINT16: final short[] oai16data = ((CompoundShortDataset) result).data; it.setOutputDouble(false); if (inDegrees) { while (it.hasNext()) { final short ox = (short) toLong( Math.toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble))); for (int j = 0; j < is; j++) { oai16data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { final short ox = (short) toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); for (int j = 0; j < is; j++) { oai16data[it.oIndex + j] = ox; } } } break; case Dataset.ARRAYINT32: final int[] oai32data = ((CompoundIntegerDataset) result).data; it.setOutputDouble(false); if (inDegrees) { while (it.hasNext()) { final int ox = (int) toLong( Math.toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble))); for (int j = 0; j < is; j++) { oai32data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { final int ox = (int) toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); for (int j = 0; j < is; j++) { oai32data[it.oIndex + j] = ox; } } } break; case Dataset.ARRAYINT64: final long[] oai64data = ((CompoundLongDataset) result).data; it.setOutputDouble(false); if (inDegrees) { while (it.hasNext()) { final long ox = toLong( Math.toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble))); for (int j = 0; j < is; j++) { oai64data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { final long ox = toLong(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); for (int j = 0; j < is; j++) { oai64data[it.oIndex + j] = ox; } } } break; case Dataset.FLOAT32: final float[] of32data = ((FloatDataset) result).data; if (inDegrees) { while (it.hasNext()) { of32data[it.oIndex] = (float) Math .toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); } } else { while (it.hasNext()) { of32data[it.oIndex] = (float) Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble); } } break; case Dataset.FLOAT64: final double[] of64data = ((DoubleDataset) result).data; if (inDegrees) { while (it.hasNext()) { of64data[it.oIndex] = Math .toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); } } else { while (it.hasNext()) { of64data[it.oIndex] = Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble); } } break; case Dataset.ARRAYFLOAT32: final float[] oaf32data = ((CompoundFloatDataset) result).data; if (inDegrees) { while (it.hasNext()) { final float ox = (float) Math .toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); for (int j = 0; j < is; j++) { oaf32data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { final float ox = (float) Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble); for (int j = 0; j < is; j++) { oaf32data[it.oIndex + j] = ox; } } } break; case Dataset.ARRAYFLOAT64: final double[] oaf64data = ((CompoundDoubleDataset) result).data; if (inDegrees) { while (it.hasNext()) { final double ox = Math.toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); for (int j = 0; j < is; j++) { oaf64data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { final double ox = Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble); for (int j = 0; j < is; j++) { oaf64data[it.oIndex + j] = ox; } } } break; case Dataset.COMPLEX64: final float[] oc64data = ((ComplexFloatDataset) result).data; if (inDegrees) { while (it.hasNext()) { oc64data[it.oIndex] = (float) Math .toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); oc64data[it.oIndex + 1] = 0; } } else { while (it.hasNext()) { oc64data[it.oIndex] = (float) Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble); oc64data[it.oIndex + 1] = 0; } } break; case Dataset.COMPLEX128: final double[] oc128data = ((ComplexDoubleDataset) result).data; if (inDegrees) { while (it.hasNext()) { oc128data[it.oIndex] = Math .toDegrees(Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble)); oc128data[it.oIndex + 1] = 0; } } else { while (it.hasNext()) { oc128data[it.oIndex] = Math.atan2(da.getElementDoubleAbs(it.aIndex + 1), it.aDouble); oc128data[it.oIndex + 1] = 0; } } break; default: throw new IllegalArgumentException("angle does not support this dataset type"); } addFunctionName(result, "angle"); return result; }
From source file:com.aerohive.nms.web.config.lbs.services.HmFolderServiceImpl.java
private boolean validateGeoPerimeter(HmFolder floor, HmGeoPerimeterVo vo) throws Exception { double degToRad = Math.PI / 180.0; ArrayList<HmGeoVertexVo> latLngs = vo.getVertexes(); double lat1 = latLngs.get(0).getLatitude().doubleValue(); double lng1 = latLngs.get(0).getLongitude().doubleValue(); double firstLat = lat1; double firstLng = lng1; double dlat1cos = Math.pow(Math.cos(degToRad * lat1), 2); double x_min = 0, x_max = 0, y_min = 0, y_max = 0; List<HmVertex> perimeter = new ArrayList<HmVertex>(); int perimId = 0; HmVertex v = new HmVertex(); v.setId(0);// ww w . ja v a 2 s.c om v.setX(0.0); v.setY(0.0); perimeter.add(v); for (int i = 1; i < latLngs.size() - 1; i++) { double lat2 = latLngs.get(i).getLatitude().doubleValue(); double dLat = degToRad * (lat2 - lat1); double lng2 = latLngs.get(i).getLongitude().doubleValue(); double dLon = degToRad * (lng2 - lng1); if (lat2 == firstLat && lng2 == firstLng) { perimId++; i++; firstLat = latLngs.get(i).getLatitude().doubleValue(); firstLng = latLngs.get(i).getLongitude().doubleValue(); lat2 = latLngs.get(i).getLatitude().doubleValue(); dLat = degToRad * (lat2 - lat1); lng2 = latLngs.get(i).getLongitude().doubleValue(); dLon = degToRad * (lng2 - lng1); } double adx = dlat1cos * Math.sin(dLon / 2) * Math.sin(dLon / 2); double cdx = 2 * Math.atan2(Math.sqrt(adx), Math.sqrt(1 - adx)); double dx = 6371000.0 * cdx; if (lng2 < lng1) { dx = -dx; } if (dx < x_min) { x_min = dx; } if (dx > x_max) { x_max = dx; } double ady = Math.pow(Math.sin(dLat / 2), 2); double cdy = 2 * Math.atan2(Math.sqrt(ady), Math.sqrt(1 - ady)); double dy = 6371000.0 * cdy; if (lat1 < lat2) { dy = -dy; } if (dy < y_min) { y_min = dy; } if (dy > y_max) { y_max = dy; } v = new HmVertex(); v.setId(perimId); v.setX(dx); v.setY(dy); logger.info("adding vertex[" + perimeter.size() + "]: (" + v.getX() + ", " + v.getY() + ")"); perimeter.add(v); } double width = x_max - x_min; double px = width * 0.1; double height = y_max - y_min; double py = height * 0.1; for (HmVertex vertex : perimeter) { vertex.setType(VertexType.DRY_WALL); vertex.setX(vertex.getX() - x_min + px); vertex.setY(vertex.getY() - y_min + py); } if (!validateGeoPerimeter(perimeter)) { return false; } if (floor != null) { floor.setMetricWidth(width + px * 2); floor.setMetricHeight(height + py * 2); floor.setImageWidth(floor.getMetricWidth().intValue()); floor.setImageHeight(floor.getMetricHeight().intValue()); floor.setPerimeter(perimeter); } return true; }