当前位置: 首页>>代码示例>>Java>>正文


Java Loopz.minMax方法代码示例

本文整理汇总了Java中org.twak.utils.collections.Loopz.minMax方法的典型用法代码示例。如果您正苦于以下问题:Java Loopz.minMax方法的具体用法?Java Loopz.minMax怎么用?Java Loopz.minMax使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.twak.utils.collections.Loopz的用法示例。


在下文中一共展示了Loopz.minMax方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findSE

import org.twak.utils.collections.Loopz; //导入方法依赖的package包/类
private static double[] findSE( MiniFacade mf, Line l, List<Face> chain ) {
	
	double mlen = l.length();
	
	double lowest = Double.MAX_VALUE;
	Face bestFace = null;
	
	for (Face f : chain) {
		double[] bounds = Loopz.minMax( f.getLoopL() );
		if (bounds[5] - bounds[4] > 1 && bounds[4] < lowest) {
			bestFace = f;
			lowest = bounds[4];
		}
	}
	
	if (bestFace == null)
		return new double[] {mf.left, mf.left+ mf.width}; //!
	
	List<Double> params = bestFace.getLoopL().streamE().map( p3 -> l.findPPram( new Point2d ( p3.x, p3.y ) ) ).collect( Collectors.toList() );
	
	double[] out = new double[] {
		params.stream().mapToDouble( x->x ).min().getAsDouble() * mlen,
		params.stream().mapToDouble( x->x ).max().getAsDouble() * mlen
	};

	// if good, stretch whole minifacade to mesh
	if ( Mathz.inRange( ( out[1] - out[0]) / (mf.width), 0.66, 1.4 ) )
		return out;
	
	// else snap to the closest of start/end
	if ( 
			l.fromPPram( out[0] / mlen ).distance( l.fromPPram( mf.left / mlen ) ) >
			l.fromPPram( out[1] / mlen ).distance( l.fromPPram( (mf.left + mf.width ) / mlen ) ) )
		return new double[] {out[1] - mf.width, out[1]}; 
	else
		return new double[] {out[0], out[0] + mf.width }; 
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:38,代码来源:Greeble.java

示例2: facadeSelected

import org.twak.utils.collections.Loopz; //导入方法依赖的package包/类
public void facadeSelected( LoopL<Point3d> list, BlockGen block ) {

		//		if (block == null) {
		//			JOptionPane.showMessageDialog( null, "generate mesh for block first" );
		//			return;
		//		}
		
		double[] minMax = Loopz.minMax( list );// Polygonz.findBounds( polies, min, max );

		Loopz.expand( minMax, 30 );

		Map<Point2d, Pano> panos = new HashMap<>();

		for ( Gen gen : tweed.frame.gens( PanoGen.class ) )
			for ( Pano pg : ( (PanoGen) gen ).getPanos() ) {
				Point2d pt = new Point2d( pg.location.x, pg.location.z );

				if ( pt.x > minMax[ 0 ] && pt.x < minMax[ 1 ] && pt.y > minMax[ 4 ] && pt.y < minMax[ 5 ] )

					panos.put( pt, pg );
			}

		List<Point3d> objPoints = null;
		if ( block != null ) {
			objPoints = new ObjRead( block.getCroppedFile() ).points();
		}

		FacadeFinder ff = new FacadeFinder( Loopz.toXZLoop( list ), panos, objPoints, block, tweed.frame.getGenOf( PlanesGen.class ) );

		Point2d cen = Loopz.average( Loopz.to2dLoop( list, 1, null ) );
		
		renderFacades( block == null ? null : block.gNode, cen.x+"_"+cen.y, ff );
	}
 
开发者ID:twak,项目名称:chordatlas,代码行数:34,代码来源:FacadeTool.java

示例3: render

import org.twak.utils.collections.Loopz; //导入方法依赖的package包/类
public static void render( Tweed tweed, LoopL<Point3d> loopL ) {

		double[] range = Loopz.minMax( loopL );
		
		double jump = 30;
		int xMin = -1, xMax = 1, yMin = -1, yMax = 1;
		
		BufferedImage out = new BufferedImage( 640 * ( xMax-xMin+1), 640 * (yMax - yMin + 1), BufferedImage.TYPE_3BYTE_BGR );
		Graphics2D g = out.createGraphics();
		
		int cenX = out.getWidth()/2, cenY = out.getHeight()/2;
		
		int removeBottom = 30;
		
		try {
			
			for (int x = xMin; x <= xMax; x++)
				for (int y = yMax; y >= yMin; y--) 
				{
			
				Point3d cen = new Point3d( 
						( range[ 0 ] + range[ 1 ] ) * 0.5 + x*jump, 
						0, 
						( range[ 4 ] + range[ 5 ] ) * 0.5 + y*jump );

				Point2d ll = worldToLLong( tweed, cen );

				System.out.println( "in EPSG:27700 " + cen );
				System.out.println( "lat long " + ll.x + " " + ll.y );

				URL url = new URL( "https://maps.googleapis.com/maps/api/staticmap?center=" + 
						ll.x + "," + ll.y + 
						"&zoom=20&size=640x640&maptype=satellite&format=png32&key=go_get_your_own" );

				URLConnection connection = url.openConnection();
				InputStream is = connection.getInputStream();

				BufferedImage image = ImageIO.read( is );

				g.drawImage( image, 
						cenX - image.getWidth() /2 - x * 323 + y * 8,
						cenY - image.getHeight()/2 - x * 8   - y * 323, 
						cenX + image.getWidth() /2 - x * 323 + y * 8,
						cenY + image.getHeight()/2 - x * 8   - y * 323 - removeBottom,
						
						0,0,image.getWidth(), image.getHeight() - removeBottom,
						
						 null );
				
				
				
			}

			g.dispose();
			ImageIO.write( out, "png", new File( Tweed.SCRATCH + "ssat.png" ) );
			
		} catch ( Throwable e ) {
			e.printStackTrace();
		}
	}
 
开发者ID:twak,项目名称:chordatlas,代码行数:61,代码来源:SatUtils.java


注:本文中的org.twak.utils.collections.Loopz.minMax方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。