private Point2f calcMidPoint( Point2f pa, Point2f pb ) { float maxX = pa.x; float minX = pb.x; float maxY = pa.y; float minY = pb.y; if ( maxX < minX ) { maxX = pb.x; minX = pa.x; } if ( maxY < minY ) { maxY = pb.y; minY = pa.y; } float midX = ( maxX - minX ) / 2.0f + minX; float midY = ( maxY - minY ) / 2.0f + minY; return new Point2f( midX, midY ); }
Point2f calcMidPoint( Point2f pa, Point2f pb ) { float minX = Math.min( pb.x, pa.x ); float minY = Math.min( pb.y, pa.y ); float midX = ( Math.abs( pb.x - pa.x ) * 0.5f ) + minX; float midY = ( Math.abs( pb.y - pa.y ) * 0.5f ) + minY; return new Point2f( midX, midY ); }
public Point2f getTextPoint(Graphics g, String text, double cX, double cY) { FontMetrics metrics = g.getFontMetrics(); Rectangle2D stringBounds = metrics.getStringBounds(text, g); double halfWidth = stringBounds.getWidth() / 2.0; double halfHeight = stringBounds.getHeight() / 2.0; double ascent = metrics.getAscent(); float x = (float) (cX - halfWidth); float y = (float) (cY - halfHeight + ascent); return new Point2f(x, y); }
public Point2f getTextPoint(Graphics g, String text, double cX, double cY) { FontMetrics metrics = g.getFontMetrics(); Rectangle2D stringBounds = metrics.getStringBounds(text, g); double halfWidth = stringBounds.getWidth() / 2.0; double halfHeight = stringBounds.getHeight() / 2.0; double ascent = metrics.getAscent(); float x = (float) (cX - halfWidth); float y = (float) (cY - halfHeight + ascent); return new Point2f(x, y); }
/** * * @param g * @param text * @param cX * @param cY * @return */ public Point2f getTextPoint(Graphics g, String text, double cX, double cY) { FontMetrics metrics = g.getFontMetrics(); Rectangle2D stringBounds = metrics.getStringBounds(text, g); double halfWidth = stringBounds.getWidth() / 2; double halfHeight = stringBounds.getHeight() / 2; double ascent = metrics.getAscent(); float x = (float) (cX - halfWidth); float y = (float) (cY - halfHeight + ascent); return new Point2f(x, y); }
/** * * @param g * @param text * @param cX * @param cY * @return */ public Point2f getTextPoint(Graphics g, String text, double cX, double cY) { FontMetrics metrics = g.getFontMetrics(); Rectangle2D stringBounds = metrics.getStringBounds(text, g); double halfWidth = stringBounds.getWidth() / 2; double halfHeight = stringBounds.getHeight() / 2; double ascent = metrics.getAscent(); float x = (float) (cX - halfWidth); float y = (float) (cY - halfHeight + ascent); return new Point2f(x, y); }
private PatchManager generateMacroTriangles( PatchManager triangleManager, float minX, float minY, float maxX, float maxY ) { Point2f p0 = new Point2f( minX, maxY ); Point2f p1 = new Point2f( minX, minY ); Point2f p2 = new Point2f( maxX, maxY ); Point2f p3 = new Point2f( maxX, minY ); // prepare workers Worker worker1 = new Worker( this, triangleManager, "0", p0, p1, p2 ); Worker worker2 = new Worker( this, triangleManager, "1", p3, p2, p1 ); long sT = currentTimeMillis(); // start workers in different threads // Thread t = new Thread( worker1, "Upper left macro triangle" ); worker1.run(); Thread.currentThread().setName( "Lower right macro triangle" ); worker2.run(); // // wait indefinitely for thread t to finish // try { // t.join(); // // Finished // } catch ( InterruptedException e ) { // // Thread was interrupted // e.printStackTrace(); // } // System.out.println( LogUtils.createDurationTimeString( // "Creation of triangles", sT, true ) ); return triangleManager; }
public static Point2f generateRandomPoint2f(Random random, float minX, float minY, float maxX, float maxY) { float x = generateRandomFloatInRange(random, minX, maxX); float y = generateRandomFloatInRange(random, minY, maxY); return new Point2f(x, y); }
public static Point2f generateRandomPoint2f(Random random, float maxAbsoluteX, float maxAblsoluteY) { float x = generateRandomFloatInRange(random, -maxAbsoluteX, maxAbsoluteX); float y = generateRandomFloatInRange(random, -maxAblsoluteY, maxAblsoluteY); return new Point2f(x, y); }
public static Point2f findBlobFromThresholdImage(Mat thresholdedImage) { Moments moments = Imgproc.moments(thresholdedImage); double m01 = moments.get_m01(); double m10 = moments.get_m10(); double area = moments.get_m00(); Point2f blobPosition; if (m01 != 0.0 && m10 != 0.0 && area != 0.0 && thresholdedImage.width() != 0 && thresholdedImage.height() != 0) { blobPosition = new Point2f((float) (m10 / area / (double) thresholdedImage.width()), (float) (1.0 - m01 / area / (double) thresholdedImage.height())); } else { blobPosition = new Point2f(); } return blobPosition; }
stepRight.scale( 1.0f / ( rowsPerTile * 2.0f ) ); Point2f middleBottom = new Point2f(); middleBottom.sub( p2, p1 ); middleBottom.scale( 0.5f ); vertexNormals[normalId++] = getNormal( p0, stepRight, stepUp ); Point2f lastRowLeftEnd = new Point2f( p0 ); Point2f lastRowRightEnd = new Point2f( p0 ); Point2f currentPos = new Point2f( lastRowLeftEnd ); Point2f leftMiddle = new Point2f( currentPos ); leftMiddle.add( halfStepDownLeft ); tileVertices[vertexId++] = build3DPoint( leftMiddle ); currentPos = new Point2f( leftMiddle ); currentPos.add( halfStepDownLeft ); Point2f rowStart = new Point2f( currentPos ); for ( int rowVertex = 0; rowVertex < row * 2 + 1; rowVertex++ ) { tileVertices[vertexId++] = build3DPoint( currentPos ); Point2f rightMiddle = new Point2f( lastRowRightEnd ); rightMiddle.add( halfStepDownRight ); tileVertices[vertexId++] = build3DPoint( rightMiddle );
Point2f p12D = new Point2f( p ); p12D.sub( stepRight ); Point3f p1 = new Point3f( p12D.x, p12D.y, getHeight( p12D ) ); Point2f p22D = new Point2f( p ); p22D.add( stepUp ); Point3f p2 = new Point3f( p22D.x, p22D.y, getHeight( p22D ) ); Point2f p32D = new Point2f( p ); p32D.add( stepUp ); p32D.add( stepRight ); Point3f p3 = new Point3f( p32D.x, p32D.y, getHeight( p32D ) ); Point2f p42D = new Point2f( p ); p42D.add( stepRight ); Point3f p4 = new Point3f( p42D.x, p42D.y, getHeight( p42D ) ); Point2f p52D = new Point2f( p ); p52D.sub( stepUp ); Point3f p5 = new Point3f( p52D.x, p52D.y, getHeight( p52D ) ); Point2f p62D = new Point2f( p ); p62D.sub( stepUp ); p62D.sub( stepRight );
for (int i = 0; i < vertices.length; i++) { Point2i uvi = uvs[i]; Point2f uv = new Point2f(sprite.getInterpolatedU(uvi.x / width * 16), sprite.getInterpolatedV(uvi.y / height * 16)); this.putVertexData(quadBuilder, format, vertices[i], normal, uv); for (int i = vertices.length - 1; i >= 0; i--) { Point2i uvi = uvs[i]; Point2f uv = new Point2f(sprite.getInterpolatedU(uvi.x / width * 16), sprite.getInterpolatedV(uvi.y / height * 16)); this.putVertexData(quadBuilder, format, vertices[i], normal, uv);
for (int i = 0; i < vertices.length; i++) { Point2i uvi = uvs[i]; Point2f uv = new Point2f(sprite.getInterpolatedU(uvi.x / width * 16), sprite.getInterpolatedV(uvi.y / height * 16)); this.putVertexData(quadBuilder, format, vertices[i], normal, uv);
Point2f eyePos2D = new Point2f( (float) eyePos.x / maxX, (float) eyePos.y / maxY );
Point2f eyePos2D = new Point2f( (float) eyePos.x / 32768.0f, (float) eyePos.y / 32768.0f );