List of usage examples for java.lang Float MIN_VALUE
float MIN_VALUE
To view the source code for java.lang Float MIN_VALUE.
Click Source Link
From source file:org.red5.io.AbstractIOTest.java
@Test public void testNumberFloat() { log.debug("\ntestNumberFloat"); for (Number n : new Number[] { Float.MIN_VALUE, Float.MIN_NORMAL, Float.MAX_VALUE, rnd.nextFloat(), 666.6666f }) {/*www .j a v a 2 s . c om*/ Serializer.serialize(out, n); dumpOutput(); Number rn = Deserializer.deserialize(in, Number.class); assertEquals("Deserialized Float should be the same", (Float) n, (Float) rn.floatValue()); resetOutput(); } }
From source file:gdsc.core.utils.ConvexHull.java
void calculateBounds(float[] xpoints, float[] ypoints, int npoints) { minX = Float.MAX_VALUE;/*from w ww . j a v a 2 s. c o m*/ minY = Float.MAX_VALUE; maxX = Float.MIN_VALUE; maxY = Float.MIN_VALUE; for (int i = 0; i < npoints; i++) { float x = xpoints[i]; minX = Math.min(minX, x); maxX = Math.max(maxX, x); float y = ypoints[i]; minY = Math.min(minY, y); maxY = Math.max(maxY, y); } int iMinX = (int) Math.floor(minX); int iMinY = (int) Math.floor(minY); bounds = new Rectangle(iMinX, iMinY, (int) (maxX - iMinX + 0.5), (int) (maxY - iMinY + 0.5)); }
From source file:it.acubelab.batframework.systemPlugins.AIDAAnnotator.java
@Override public Set<Annotation> solveA2W(String text) throws AnnotationException { return ProblemReduction.Sa2WToA2W(solveSa2W(text), Float.MIN_VALUE); }
From source file:org.vertx.java.http.eventbusbridge.integration.MessagePublishTest.java
@Test public void testPublishingFloatJson() throws IOException { final EventBusMessageType messageType = EventBusMessageType.Float; final Float sentFloat = Float.MIN_VALUE; Map<String, String> expectations = createExpectations(generateUniqueAddress(), Base64.encodeAsString(sentFloat.toString()), messageType); final AtomicInteger completedCount = new AtomicInteger(0); Handler<Message> messagePublishHandler = new MessagePublishHandler(sentFloat, expectations, completedCount); registerListenersAndCheckForResponses(messagePublishHandler, expectations, NUMBER_OF_PUBLISH_HANDLERS, completedCount);//from w w w . j a va 2 s. c o m String body = TemplateHelper.generateOutputUsingTemplate(SEND_REQUEST_TEMPLATE_JSON, expectations); HttpRequestHelper.sendHttpPostRequest(url, body, (VertxInternal) vertx, Status.ACCEPTED.getStatusCode(), MediaType.APPLICATION_JSON); }
From source file:org.esa.nest.dat.views.polarview.PolarView.java
private void createPlot(int rec) { getSpectraMetadata(rec);//from ww w . j a v a2 s. co m spectrum = getSpectrum(0, rec, graphUnit != Unit.IMAGINARY); float minValue = getMinValue(graphUnit != Unit.IMAGINARY); float maxValue = getMaxValue(graphUnit != Unit.IMAGINARY); if (waveProductType == WaveProductType.WAVE_SPECTRA) { if (graphUnit == Unit.INTENSITY) { minValue = Float.MAX_VALUE; maxValue = Float.MIN_VALUE; for (int i = 0; i < spectrum.length; i++) { for (int j = 0; j < spectrum[0].length; j++) { final float realVal = spectrum[i][j]; final float val = realVal * realVal; spectrum[i][j] = val; minValue = Math.min(minValue, val); maxValue = Math.max(maxValue, val); } } } } else if (graphUnit == Unit.AMPLITUDE || graphUnit == Unit.INTENSITY) { // complex data final float imagSpectrum[][] = getSpectrum(1, rec, false); minValue = Float.MAX_VALUE; maxValue = Float.MIN_VALUE; for (int i = 0; i < spectrum.length; i++) { for (int j = 0; j < spectrum[0].length; j++) { final float realVal = spectrum[i][j]; final float imagVal = imagSpectrum[i][j]; float val; if (sign(realVal) == sign(imagVal)) val = realVal * realVal + imagVal * imagVal; else val = 0.0F; if (graphUnit == Unit.AMPLITUDE) val = (float) Math.sqrt(val); spectrum[i][j] = val; minValue = Math.min(minValue, val); maxValue = Math.max(maxValue, val); } } } final float rStep = (float) (Math.log(lastWLBin) - Math.log(firstWLBin)) / (float) (numWLBins - 1); double logr = Math.log(firstWLBin) - (rStep / 2.0); final double colourRange[] = { (double) minValue, (double) maxValue }; final double radialRange[] = { minRadius, 333.33333333333 }; final float thFirst; final float thStep; if (waveProductType == WaveProductType.WAVE_SPECTRA) { thFirst = firstDirBins + 5f; thStep = -dirBinStep; } else { thFirst = firstDirBins - 5f; thStep = dirBinStep; } final int nWl = spectrum[0].length; final float radii[] = new float[nWl + 1]; for (int j = 0; j <= nWl; j++) { radii[j] = (float) (10000.0 / FastMath.exp(logr)); logr += rStep; } final PolarData data = new PolarData(spectrum, 90f + thFirst, thStep, radii); final PolarCanvas polarCanvas = polarPanel.getPolarCanvas(); polarCanvas.setAxisNames("Azimuth", "Range"); if (waveProductType == WaveProductType.WAVE_SPECTRA) { polarCanvas.setWindDirection(windDirection); polarCanvas.showWindDirection(true); polarCanvas.setAxisNames("North", "East"); } final Axis colourAxis = polarCanvas.getColourAxis(); final Axis radialAxis = polarCanvas.getRadialAxis(); colourAxis.setDataRange(colourRange); colourAxis.setUnit(unitTypes[graphUnit.ordinal()]); radialAxis.setAutoRange(false); radialAxis.setDataRange(radialRange); radialAxis.setRange(radialRange[0], radialRange[1], 4); radialAxis.setTitle("Wavelength (m)"); polarCanvas.setRings(rings, ringTextStrings); data.setColorScale(ColourScale.newCustomScale(colourRange)); polarCanvas.setData(data); repaint(); controlPanel.updateControls(); }
From source file:edu.stanford.slac.archiverappliance.PB.data.BoundaryConditionsSimulationValueGenerator.java
public DBR getJCASampleValue(ArchDBRTypes type, int secondsIntoYear) { switch (type) { case DBR_SCALAR_STRING: DBR_TIME_String retvalss = new DBR_TIME_String(new String[] { Integer.toString(secondsIntoYear) }); retvalss.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear)); retvalss.setSeverity(1);/*from ww w . j a v a2s. c o m*/ retvalss.setStatus(0); return retvalss; case DBR_SCALAR_SHORT: DBR_TIME_Short retvalsh; if (0 <= secondsIntoYear && secondsIntoYear < 1000) { // Check for some numbers around the minimum value retvalsh = new DBR_TIME_Short(new short[] { (short) (Short.MIN_VALUE + secondsIntoYear) }); } else if (1000 <= secondsIntoYear && secondsIntoYear < 2000) { // Check for some numbers around the maximum value retvalsh = new DBR_TIME_Short(new short[] { (short) (Short.MAX_VALUE - (secondsIntoYear - 1000)) }); } else { // Check for some numbers around 0 retvalsh = new DBR_TIME_Short(new short[] { (short) (secondsIntoYear - 2000) }); } retvalsh.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear)); retvalsh.setSeverity(1); retvalsh.setStatus(0); return retvalsh; case DBR_SCALAR_FLOAT: DBR_TIME_Float retvalfl; if (0 <= secondsIntoYear && secondsIntoYear < 1000) { // Check for some numbers around the minimum value retvalfl = new DBR_TIME_Float(new float[] { Float.MIN_VALUE + secondsIntoYear }); } else if (1000 <= secondsIntoYear && secondsIntoYear < 2000) { // Check for some numbers around the maximum value retvalfl = new DBR_TIME_Float(new float[] { Float.MAX_VALUE - (secondsIntoYear - 1000) }); } else { // Check for some numbers around 0. Divide by a large number to make sure we cater to the number of precision digits retvalfl = new DBR_TIME_Float(new float[] { (secondsIntoYear - 2000.0f) / secondsIntoYear }); } retvalfl.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear)); retvalfl.setSeverity(1); retvalfl.setStatus(0); return retvalfl; case DBR_SCALAR_ENUM: DBR_TIME_Enum retvalen; retvalen = new DBR_TIME_Enum(new short[] { (short) (secondsIntoYear) }); retvalen.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear)); retvalen.setSeverity(1); retvalen.setStatus(0); return retvalen; case DBR_SCALAR_BYTE: DBR_TIME_Byte retvalby; retvalby = new DBR_TIME_Byte(new byte[] { ((byte) (secondsIntoYear % 255)) }); retvalby.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear)); retvalby.setSeverity(1); retvalby.setStatus(0); return retvalby; case DBR_SCALAR_INT: DBR_TIME_Int retvalint; if (0 <= secondsIntoYear && secondsIntoYear < 1000) { // Check for some numbers around the minimum value retvalint = new DBR_TIME_Int(new int[] { Integer.MIN_VALUE + secondsIntoYear }); } else if (1000 <= secondsIntoYear && secondsIntoYear < 2000) { // Check for some numbers around the maximum value retvalint = new DBR_TIME_Int(new int[] { Integer.MAX_VALUE - (secondsIntoYear - 1000) }); } else { // Check for some numbers around 0 retvalint = new DBR_TIME_Int(new int[] { (secondsIntoYear - 2000) }); } retvalint.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear)); retvalint.setSeverity(1); retvalint.setStatus(0); return retvalint; case DBR_SCALAR_DOUBLE: DBR_TIME_Double retvaldb; if (0 <= secondsIntoYear && secondsIntoYear < 1000) { // Check for some numbers around the minimum value retvaldb = new DBR_TIME_Double(new double[] { (Double.MIN_VALUE + secondsIntoYear) }); } else if (1000 <= secondsIntoYear && secondsIntoYear < 2000) { // Check for some numbers around the maximum value retvaldb = new DBR_TIME_Double(new double[] { (Double.MAX_VALUE - (secondsIntoYear - 1000)) }); } else { // Check for some numbers around 0. Divide by a large number to make sure we cater to the number of precision digits retvaldb = new DBR_TIME_Double( new double[] { ((secondsIntoYear - 2000.0) / (secondsIntoYear * 1000000)) }); } retvaldb.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear)); retvaldb.setSeverity(1); retvaldb.setStatus(0); return retvaldb; case DBR_WAVEFORM_STRING: DBR_TIME_String retvst; // Varying number of copies of a typical value retvst = new DBR_TIME_String( Collections.nCopies(secondsIntoYear, Integer.toString(secondsIntoYear)).toArray(new String[0])); retvst.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear)); retvst.setSeverity(1); retvst.setStatus(0); return retvst; case DBR_WAVEFORM_SHORT: DBR_TIME_Short retvsh; retvsh = new DBR_TIME_Short( ArrayUtils.toPrimitive(Collections.nCopies(1, (short) secondsIntoYear).toArray(new Short[0]))); retvsh.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear)); retvsh.setSeverity(1); retvsh.setStatus(0); return retvsh; case DBR_WAVEFORM_FLOAT: DBR_TIME_Float retvf; // Varying number of copies of a typical value retvf = new DBR_TIME_Float(ArrayUtils.toPrimitive( Collections.nCopies(secondsIntoYear, (float) Math.cos(secondsIntoYear * Math.PI / 3600)) .toArray(new Float[0]))); retvf.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear)); retvf.setSeverity(1); retvf.setStatus(0); return retvf; case DBR_WAVEFORM_ENUM: DBR_TIME_Enum retven; retven = new DBR_TIME_Enum(ArrayUtils .toPrimitive(Collections.nCopies(1024, (short) secondsIntoYear).toArray(new Short[0]))); retven.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear)); retven.setSeverity(1); retven.setStatus(0); return retven; case DBR_WAVEFORM_BYTE: DBR_TIME_Byte retvb; // Large number of elements in the array retvb = new DBR_TIME_Byte(ArrayUtils.toPrimitive(Collections .nCopies(65536 * secondsIntoYear, ((byte) (secondsIntoYear % 255))).toArray(new Byte[0]))); retvb.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear)); retvb.setSeverity(1); retvb.setStatus(0); return retvb; case DBR_WAVEFORM_INT: DBR_TIME_Int retvint; // Varying number of copies of a typical value retvint = new DBR_TIME_Int(ArrayUtils.toPrimitive(Collections .nCopies(secondsIntoYear, secondsIntoYear * secondsIntoYear).toArray(new Integer[0]))); retvint.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear)); retvint.setSeverity(1); retvint.setStatus(0); return retvint; case DBR_WAVEFORM_DOUBLE: DBR_TIME_Double retvd; // Varying number of copies of a typical value retvd = new DBR_TIME_Double(ArrayUtils.toPrimitive(Collections .nCopies(secondsIntoYear, Math.sin(secondsIntoYear * Math.PI / 3600)).toArray(new Double[0]))); retvd.setTimeStamp(convertSecondsIntoYear2JCATimeStamp(secondsIntoYear)); retvd.setSeverity(1); retvd.setStatus(0); return retvd; case DBR_V4_GENERIC_BYTES: throw new RuntimeException("Currently don't support " + type + " when generating sample data"); default: throw new RuntimeException("We seemed to have missed a DBR type when generating sample data"); } }
From source file:it.acubelab.batframework.systemPlugins.AIDAAnnotator.java
@Override public Set<Annotation> solveD2W(String text, Set<Mention> mentions) { return ProblemReduction.Sa2WToD2W(solveSa2W(text), mentions, Float.MIN_VALUE); }
From source file:chenyoufu.hciprojectes10.MyGLSurfaceView.java
private void readMesh() { try {/* w w w. j a v a 2 s .com*/ InputStream meshIS = getResources().openRawResource(R.raw.eight); BufferedReader meshReader = new BufferedReader(new InputStreamReader(meshIS, "UTF-8")); String line; boolean isVertex = false; boolean isFace = false; while ((line = meshReader.readLine()) != null) { if (!isVertex && !isFace) { if (line.charAt(0) == 'V') { Global.verticesCount++; isVertex = true; } } else if (isFace) { Global.facesCount++; } else { if (line.charAt(0) == 'F') { Global.facesCount++; isFace = true; } else { Global.verticesCount++; } } } meshReader.close(); meshIS.close(); Global.edgesCount = 3 * Global.facesCount; //vertices.setSize(verticesCount); //faces.setSize(facesCount); //edges.setSize(edgesCount); for (int i = 0; i < Global.edgesCount; i++) Global.edges.add(new HEEdge(null, null, null, null, null)); // main loop, to assign elements to lists. //int vertexNum=0; // count from 1 int faceNum = 0; // count from 1 //int edgeNum=0; // count from 1 // restore loop state isVertex = false; isFace = false; meshIS = getResources().openRawResource(R.raw.eight); meshReader = new BufferedReader(new InputStreamReader(meshIS, "UTF-8")); while ((line = meshReader.readLine()) != null) { if (!isFace && !isVertex) { if (line.charAt(0) == 'V') { float x = 0, y = 0, z = 0; // fist vertex String[] split = line.split("\\s+"); x = Float.parseFloat(split[2]); y = Float.parseFloat(split[3]); z = Float.parseFloat(split[4]); Global.vertices.add(new HEVert(x, y, z, null)); // loop isVertex = true; } } else if (isFace) { int v1 = 0, v2 = 0, v3 = 0; String[] split = line.split("\\s+"); faceNum = Integer.parseInt(split[1]); v1 = Integer.parseInt(split[2]); v2 = Integer.parseInt(split[3]); v3 = Integer.parseInt(split[4]); Global.faces.add(new HEFace(Global.edges.get(faceNum * 3 - 3))); Global.vertices.get(v1 - 1).edge = Global.edges.get(faceNum * 3 - 3); Global.vertices.get(v2 - 1).edge = Global.edges.get(faceNum * 3 - 2); Global.vertices.get(v3 - 1).edge = Global.edges.get(faceNum * 3 - 1); Global.edges.get(faceNum * 3 - 3).vert = Global.vertices.get(v1 - 1); Global.edges.get(faceNum * 3 - 3).face = Global.faces.get(faceNum - 1); Global.edges.get(faceNum * 3 - 3).prev = Global.edges.get(faceNum * 3 - 1); Global.edges.get(faceNum * 3 - 3).next = Global.edges.get(faceNum * 3 - 2); Global.edges.get(faceNum * 3 - 2).vert = Global.vertices.get(v2 - 1); Global.edges.get(faceNum * 3 - 2).face = Global.faces.get(faceNum - 1); Global.edges.get(faceNum * 3 - 2).prev = Global.edges.get(faceNum * 3 - 3); Global.edges.get(faceNum * 3 - 2).next = Global.edges.get(faceNum * 3 - 1); Global.edges.get(faceNum * 3 - 1).vert = Global.vertices.get(v3 - 1); Global.edges.get(faceNum * 3 - 1).face = Global.faces.get(faceNum - 1); Global.edges.get(faceNum * 3 - 1).prev = Global.edges.get(faceNum * 3 - 2); Global.edges.get(faceNum * 3 - 1).next = Global.edges.get(faceNum * 3 - 3); Global.edgesTemp.put((v1 - 1) + "-" + (v2 - 1), faceNum * 3 - 3); Global.edgesTemp.put((v2 - 1) + "-" + (v3 - 1), faceNum * 3 - 2); Global.edgesTemp.put((v3 - 1) + "-" + (v1 - 1), faceNum * 3 - 1); // dealing with pair edge Integer value = Global.edgesTemp.get("" + (v2 - 1) + "-" + (v1 - 1)); if (value != null) { Global.edges.get(faceNum * 3 - 3).pair = Global.edges.get(value); Global.edges.get(value).pair = Global.edges.get(faceNum * 3 - 3); } value = Global.edgesTemp.get("" + (v3 - 1) + "-" + (v2 - 1)); if (value != null) { Global.edges.get(faceNum * 3 - 2).pair = Global.edges.get(value); Global.edges.get(value).pair = Global.edges.get(faceNum * 3 - 2); } value = Global.edgesTemp.get("" + (v1 - 1) + "-" + (v3 - 1)); if (value != null) { Global.edges.get(faceNum * 3 - 1).pair = Global.edges.get(value); Global.edges.get(value).pair = Global.edges.get(faceNum * 3 - 1); } } else { // is_vertex if (line.charAt(0) == 'F') { // first face int v1 = 0, v2 = 0, v3 = 0; String[] split = line.split("\\s+"); faceNum = Integer.parseInt(split[1]); v1 = Integer.parseInt(split[2]); v2 = Integer.parseInt(split[3]); v3 = Integer.parseInt(split[4]); Global.faces.add(new HEFace(Global.edges.get(faceNum * 3 - 3))); Global.vertices.get(v1 - 1).edge = Global.edges.get(faceNum * 3 - 3); Global.vertices.get(v2 - 1).edge = Global.edges.get(faceNum * 3 - 2); Global.vertices.get(v3 - 1).edge = Global.edges.get(faceNum * 3 - 1); Global.edges.get(faceNum * 3 - 3).vert = Global.vertices.get(v1 - 1); Global.edges.get(faceNum * 3 - 3).face = Global.faces.get(faceNum - 1); Global.edges.get(faceNum * 3 - 3).prev = Global.edges.get(faceNum * 3 - 1); Global.edges.get(faceNum * 3 - 3).next = Global.edges.get(faceNum * 3 - 2); Global.edges.get(faceNum * 3 - 2).vert = Global.vertices.get(v2 - 1); Global.edges.get(faceNum * 3 - 2).face = Global.faces.get(faceNum - 1); Global.edges.get(faceNum * 3 - 2).prev = Global.edges.get(faceNum * 3 - 3); Global.edges.get(faceNum * 3 - 2).next = Global.edges.get(faceNum * 3 - 1); Global.edges.get(faceNum * 3 - 1).vert = Global.vertices.get(v3 - 1); Global.edges.get(faceNum * 3 - 1).face = Global.faces.get(faceNum - 1); Global.edges.get(faceNum * 3 - 1).prev = Global.edges.get(faceNum * 3 - 2); Global.edges.get(faceNum * 3 - 1).next = Global.edges.get(faceNum * 3 - 3); Global.edgesTemp.put((v1 - 1) + "-" + (v2 - 1), faceNum * 3 - 3); Global.edgesTemp.put((v2 - 1) + "-" + (v3 - 1), faceNum * 3 - 2); Global.edgesTemp.put((v3 - 1) + "-" + (v1 - 1), faceNum * 3 - 1); // loop isFace = true; } else { float x = 0, y = 0, z = 0; String[] split = line.split("\\s+"); x = Float.parseFloat(split[2]); y = Float.parseFloat(split[3]); z = Float.parseFloat(split[4]); Global.vertices.add(new HEVert(x, y, z, null)); } } } meshReader.close(); meshIS.close(); // Calculate bounding box float tempMinX = Float.MAX_VALUE, tempMinY = Float.MAX_VALUE, tempMinZ = Float.MAX_VALUE; float tempMaxX = Float.MIN_VALUE, tempMaxY = Float.MIN_VALUE, tempMaxZ = Float.MIN_VALUE; for (int i = 0; i < Global.verticesCount; i++) { if (Global.vertices.get(i).x > tempMaxX) tempMaxX = Global.vertices.get(i).x; if (Global.vertices.get(i).y > tempMaxY) tempMaxY = Global.vertices.get(i).y; if (Global.vertices.get(i).z > tempMaxZ) tempMaxZ = Global.vertices.get(i).z; if (Global.vertices.get(i).x < tempMinX) tempMinX = Global.vertices.get(i).x; if (Global.vertices.get(i).y < tempMinY) tempMinY = Global.vertices.get(i).y; if (Global.vertices.get(i).z < tempMinZ) tempMinZ = Global.vertices.get(i).z; } Global.maxX = tempMaxX; Global.minX = tempMinX; Global.maxY = tempMaxY; Global.minY = tempMinY; Global.maxZ = tempMaxZ; Global.minZ = tempMinZ; // Normalize the vertex coordinates (in the range of 0~2) float centroidX = (Global.maxX + Global.minX) / 2; float rangeX = Global.maxX - centroidX; float centroidY = (Global.maxY + Global.minY) / 2; float rangeY = Global.maxY - centroidY; float centroidZ = (Global.maxZ + Global.minZ) / 2; float rangeZ = Global.maxZ - centroidZ; float tempRange; float maxRatio = (tempRange = rangeX > rangeY ? rangeX : rangeY) > rangeZ ? tempRange : rangeZ; for (int i = 0; i < Global.verticesCount; i++) { Global.vertices.get(i).x = (Global.vertices.get(i).x - (Global.minX + Global.maxX) / 2) / maxRatio; Global.vertices.get(i).y = (Global.vertices.get(i).y - (Global.minY + Global.maxY) / 2) / maxRatio; Global.vertices.get(i).z = (Global.vertices.get(i).z - (Global.minZ + Global.maxZ) / 2) / maxRatio; } /*for (int i=0; i< Global.verticesCount; i++) { System.out.println(i+" "+Global.vertices.get(i).edge.face.edge.vert.x); }*/ /*Global.maxX=(Global.maxX-Global.minX)/maxRatio;Global.minX=0; Global.maxY=(Global.maxY-Global.minY)/maxRatio;Global.minY=0; Global.maxZ=(Global.maxZ-Global.minZ)/maxRatio;Global.minZ=0;*/ // Compute face normals & vertex normals for (int i = 0; i < Global.facesCount; i++) { Tuple3 v1 = new Tuple3(Global.faces.get(i).edge.vert); Tuple3 v2 = new Tuple3(Global.faces.get(i).edge.next.vert); Tuple3 v3 = new Tuple3(Global.faces.get(i).edge.prev.vert); Tuple3 e1 = new Tuple3(v2.x - v1.x, v2.y - v1.y, v2.z - v1.z); Tuple3 e2 = new Tuple3(v3.x - v1.x, v3.y - v1.y, v3.z - v1.z); Tuple3 tempNormal = new Tuple3(e1.y * e2.z - e1.z * e2.y, e1.z * e2.x - e1.x * e2.z, e1.x * e2.y - e1.y * e2.x); float tempArea = (float) Math.sqrt( tempNormal.x * tempNormal.x + tempNormal.y * tempNormal.y + tempNormal.z * tempNormal.z); Global.faceInfos.put(Global.faces.get(i), new FaceInfo(tempArea, tempNormal)); } for (int i = 0; i < Global.verticesCount; i++) { HEFace faceNow = Global.vertices.get(i).edge.face; float totalArea = Global.faceInfos.get(faceNow).area; Tuple3 tempNormal = Global.faceInfos.get(faceNow).normal.mul(totalArea); Global.vertexNormals.put(Global.vertices.get(i), tempNormal); HEEdge edgeNow = Global.vertices.get(i).edge; boolean isReverse = false; while (true) { if (!isReverse) { if (edgeNow.pair != null) { if (edgeNow.pair.next != Global.vertices.get(i).edge) { edgeNow = edgeNow.pair.next; Global.vertexNormals .get(Global.vertices.get(i)).x += Global.faceInfos.get(edgeNow.face).area * Global.faceInfos.get(edgeNow.face).normal.x; Global.vertexNormals .get(Global.vertices.get(i)).y += Global.faceInfos.get(edgeNow.face).area * Global.faceInfos.get(edgeNow.face).normal.y; Global.vertexNormals .get(Global.vertices.get(i)).z += Global.faceInfos.get(edgeNow.face).area * Global.faceInfos.get(edgeNow.face).normal.z; totalArea += Global.faceInfos.get(edgeNow.face).area; } else break; } else { isReverse = true; edgeNow = Global.vertices.get(i).edge; } } else { if (edgeNow.prev.pair != null) { edgeNow = edgeNow.prev.pair; Global.vertexNormals .get(Global.vertices.get(i)).x += Global.faceInfos.get(edgeNow.face).area * Global.faceInfos.get(edgeNow.face).normal.x; Global.vertexNormals .get(Global.vertices.get(i)).y += Global.faceInfos.get(edgeNow.face).area * Global.faceInfos.get(edgeNow.face).normal.y; Global.vertexNormals .get(Global.vertices.get(i)).z += Global.faceInfos.get(edgeNow.face).area * Global.faceInfos.get(edgeNow.face).normal.z; totalArea += Global.faceInfos.get(edgeNow.face).area; } else break; } } Global.vertexNormals.get(Global.vertices.get(i)).x /= totalArea; Global.vertexNormals.get(Global.vertices.get(i)).y /= totalArea; Global.vertexNormals.get(Global.vertices.get(i)).z /= totalArea; //Global.normalize(Global.vertexNormals.get(Global.vertices.get(i))); } /*for (int i=0; i< Global.verticesCount;i++) { System.out.println(Math.sqrt(Global.vertexNormals.get(Global.vertices.get(i)).x*Global.vertexNormals.get(Global.vertices.get(i)).x+Global.vertexNormals.get(Global.vertices.get(i)).y*Global.vertexNormals.get(Global.vertices.get(i)).y+Global.vertexNormals.get(Global.vertices.get(i)).z*Global.vertexNormals.get(Global.vertices.get(i)).z)); }*/ /*for (int i=0; i< Global.verticesCount; i++){ System.out.println(i+" "+Global.vertexNormals.get(Global.vertices.get(i)).x+" "+Global.vertexNormals.get(Global.vertices.get(i)).y+" "+Global.vertexNormals.get(Global.vertices.get(i)).z); }*/ } catch (Exception e) { e.printStackTrace(); } }
From source file:org.apache.myfaces.shared_impl.renderkit.RendererUtils.java
/** * See JSF Spec. 8.5 Table 8-1/* www . jav a 2s.c om*/ * * @param value * @return boolean */ public static boolean isDefaultAttributeValue(Object value) { if (value == null) { return true; } else if (value instanceof Boolean) { return !((Boolean) value).booleanValue(); } else if (value instanceof Number) { if (value instanceof Integer) { return ((Number) value).intValue() == Integer.MIN_VALUE; } else if (value instanceof Double) { return ((Number) value).doubleValue() == Double.MIN_VALUE; } else if (value instanceof Long) { return ((Number) value).longValue() == Long.MIN_VALUE; } else if (value instanceof Byte) { return ((Number) value).byteValue() == Byte.MIN_VALUE; } else if (value instanceof Float) { return ((Number) value).floatValue() == Float.MIN_VALUE; } else if (value instanceof Short) { return ((Number) value).shortValue() == Short.MIN_VALUE; } } return false; }
From source file:org.gradoop.flink.datagen.transactions.foodbroker.config.FoodBrokerConfig.java
/** * Loads the minimal price of a product. * * @return float value of the min price// ww w .ja v a 2 s. com */ public Float getProductMinPrice() { Float minPrice = Float.MIN_VALUE; try { minPrice = (float) getMasterDataConfigNode("Product").getDouble("minPrice"); } catch (JSONException e) { e.printStackTrace(); } return minPrice; }