亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? smallestcirclecom.java

?? 生成指定點(diǎn)數(shù)的隨機(jī)點(diǎn)
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
//////////////////////////////////////////////////////////////
//
//SmallestCircleCom.java
//
//Created by CAO Song
//
//////////////////////////////////////////////////////////////
//Readme:
//  This program is designed to compare the results of finding
//the smallest enclosing ball with two different algorithms.

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Random;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class SmallestCircleCom extends JPanel implements ActionListener
{
    /**
	 * 
	 */
	private static final long serialVersionUID = -2468943794242724022L;
	private JLabel text1=new JLabel("Please enter the number of points:");//Set up GUI
    private JTextField text2=new JTextField();
    private JButton but=new JButton("Go!");
    private JLabel lab=new JLabel("Used time:");
    private JLabel lab1=new JLabel("Algorithm1's results:");
    private JLabel lab2=new JLabel("Algorithm2's results:");
    
	private long start1,finish1;
	private long start2,finish2;
	private int time1,time2;//Name time references
    
	private int pointcount;//Name the number of points
	static MiniCircle1 target1=new MiniCircle1();//Create a new MiniCircle1 Object target1
	static MiniCircle2 target2=new MiniCircle2();//Create a new MiniCircle2 Object target2
    static Container drawpanel=new DrawPanel();//Create a new DrawPanel Object drawpanel 
    
    public SmallestCircleCom()//Constructor of SmallestCircleCom
    {
     	setLayout(new GridLayout(3,1));
    	JPanel textpane=new JPanel(new GridLayout(1,3));
    	JPanel labpane=new JPanel(new GridLayout(3,1));
    	
    	textpane.add(text1);
    	textpane.add(text2);
    	textpane.add(but);
    	
    	labpane.add(lab);
    	labpane.add(lab1);
    	labpane.add(lab2);
    	
    	text2.addActionListener(this);
    	but.addActionListener(this);	
    	
    	add(textpane);
    	add(labpane);
    }// End of method:SmallestCircleCom
    
	public void actionPerformed(ActionEvent e)
	{
		try
		{
		   pointcount=Integer.parseInt(text2.getText());//Get the number from text2
		   if(pointcount<=0)//Ensure the number is positive
			   throw new Exception();
		   target2.makePoints(pointcount);//Generate the points
		   
		   target1.x=new int [pointcount];
		   target1.y=new int [pointcount];          
		   for(int i=0;i<pointcount;i++)
		   {
			   target1.x[i]=((Point)(target2.points.get(i))).x;
			   target1.y[i]=((Point)(target2.points.get(i))).y;
		   }//Copy the points from target2 to target1
			
           start1=System.currentTimeMillis();
           target1.getMiniCircle();//Calculate the smallest circle with algorithm1
		   finish1=System.currentTimeMillis();
		   time1=(int)(finish1-start1);//Calculate the time used with algorithm1
		   
		   start2=System.currentTimeMillis();
		   target2.miniCircle=target2.getMiniCircle(target2.points);//Calculate the smallest circle with algorithm2
		   finish2=System.currentTimeMillis();
		   time2=(int)(finish2-start2);//Calculate the time used with algorithm2
		
		   lab.setText("DONE!  Used time by Algorithm1: "+time1+" milliseconds." +
				       "       Used time by Algorithm2: "+time2+" milliseconds." );
		   lab1.setText("Algorithm1's results: center("+target1.centerx+","+target1.centery+") , radius="+target1.radius);
		   lab2.setText("Algorithm2's results: center("+(int)target2.miniCircle.getCenterX()+","+(int)target2.miniCircle.getCenterY()+") , radius="+(int)(SmallestCircleCom.target2.miniCircle.getWidth()/2));
		   
		   drawpanel.paint(drawpanel.getGraphics());
		   target1.refresh();
		   target2.refresh();
		   target1.x=null;
		   target1.y=null;
		   System.gc();//Refresh target1 and target2
		}
		catch(Exception exception)
		{
			lab.setText("Input Error!");
		}
	}// End of method:actionPerformed
	
	public void paint(Graphics g)
	{
		super.paint(g);//Paint GUI
	}// End of method:paint
	
	public static void main(String[] args)
	{
		JFrame frame=new JFrame("Find the smallest enclosing circle!(Comparing two Algorithms)");
		frame.setLayout(new BorderLayout());
		Container controls=new SmallestCircleCom();
		frame.add(controls,BorderLayout.SOUTH);
		frame.add(drawpanel,BorderLayout.CENTER);
		
		frame.setSize(700,750);
	    frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}//End of method:main
}//End of class:SmallestCircle2

class MiniCircle1//Calculate the Smallest Circle with algorithm1
{
    int[] x,y;//Store the Random Points
	int centerx,centery;//Store the position of the center of the smallest circle
	int radius;//Store the radius of the smallest circle
	private Vector cxs=new Vector();
	private Vector cys=new Vector();//Store the position of the enclosing circles in 3-point searching
	private Vector rs=new Vector();//Store the radius of the enclosing circles in 3-point searching
	static boolean isfinished=false;//Check if the procedure is finished
	
	public void refresh()//Clean old points before restart
	{
		cxs=new Vector();
		cys=new Vector();
		rs=new Vector();
		isfinished=false;
		System.gc();
	}
	public void makePoints(int number)// Generate random points of given number.
	{
		x=new int[number];
		y=new int[number];
		Random random=new Random();
		for(int i=0;i<x.length;i++)
		{
			x[i]=random.nextInt(300)+200;
			y[i]=random.nextInt(300)+150;
		}
	}// End of method:makePoints
	
	public void getMiniCircle()
	{
		if(!searchTwo())//Search for the smallest circle
	    	searchThree();
		isfinished=true;
	}// End of method:getMiniCircle
	
	public boolean searchTwo()//Search circles with 2 points on their boundaris
	{
		double dbx1,dbx2,dby1,dby2;//Coordinates of the two points
		double midx,midy;//Coordinates of the middle point of the two points
		double diam,tem;//Diameter of the circle and a temporary parameter
		double recx,recy;//Coordinates of the up-left corner of the rectangle which contains the circle
		boolean isinside=true;//Check if the point is inside the Circle
		for(int i=0;i<x.length;i++)
		{
			for(int j=i+1;j<x.length;j++)
			{
				dbx1=x[i];
				dby1=y[i];
				dbx2=x[j];
				dby2=y[j];
				midx=(dbx1+dbx2)/2.0;
				midy=(dby1+dby2)/2.0;
				tem=(dbx1-dbx2)*(dbx1-dbx2)+(dby1-dby2)*(dby1-dby2);
				diam=Math.sqrt(tem);
				recx=midx-diam/2.0;
				recy=midy-diam/2.0;
				Ellipse2D.Double ellipse=new Ellipse2D.Double(recx,recy,diam,diam);
				//Get every possible circle
				for(int k=0;k<x.length;k++)
				{
					if(k==i||k==j)
						continue;
					if(!ellipse.contains(x[k],y[k]))
					{
						isinside=false;
						break;
					}
				}
				if(isinside)
				{
					centerx=(int)midx;
					centery=(int)midy;
					radius=(int)(diam/2.0);
					return true;
				}
				isinside=true;//Refresh "isinside"
			}
		}
		return false;
	}//End of method:searchTwo
	
	public void searchThree()//Search circles with 3 points on their boundaries
	{
		double dbx1,dbx2,dby1,dby2,dbx3,dby3;//Coordinates of the three points
		double k12,k23;//Slope of the line determined by two out of the three points
		double mx12,my12,mx23,my23;//Coordinates of the middle point of two out of the three points
		double midx,midy;//Coordinates of the center point of the circle

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一线二线三线久久久| 99在线视频精品| 欧美一区二区网站| 五月综合激情网| 欧美巨大另类极品videosbest | 亚洲三级在线观看| 色综合婷婷久久| 在线观看网站黄不卡| 亚洲线精品一区二区三区 | 亚洲国产高清在线| 成人网在线免费视频| 中文字幕综合网| 7777精品伊人久久久大香线蕉的| 免费人成在线不卡| 久久久91精品国产一区二区三区| www.欧美.com| 日韩精品亚洲一区| 久久精品一区二区三区四区| 9i在线看片成人免费| 亚洲午夜电影在线观看| 欧美大片一区二区| av亚洲精华国产精华精| 亚洲午夜视频在线| 精品国产乱码久久久久久浪潮 | 国产99久久久国产精品潘金 | 国产制服丝袜一区| 国产成人av一区二区| 国产精品成人免费| 欧美乱妇一区二区三区不卡视频| 国产揄拍国内精品对白| 亚洲精品中文在线观看| 日韩欧美一级特黄在线播放| av综合在线播放| 奇米一区二区三区av| 国产精品美女久久久久av爽李琼 | 欧美国产一区二区在线观看 | 91麻豆.com| 蜜桃av一区二区| 国产精品视频一二三区| 欧美日韩国产色站一区二区三区| 国产成人aaa| 日本欧美一区二区三区乱码| 亚洲私人影院在线观看| 3751色影院一区二区三区| a级精品国产片在线观看| 久久国产综合精品| 一区二区欧美视频| 日韩亚洲欧美在线| 色欧美88888久久久久久影院| 日韩欧美视频在线| 久久久久久一二三区| 久久精品久久99精品久久| 18成人在线视频| 久久亚区不卡日本| 日韩免费视频一区| 91精品婷婷国产综合久久 | 亚洲天堂久久久久久久| 精品国产乱码久久久久久久久 | 欧美在线观看视频一区二区 | 亚洲一区二区视频在线| 久久午夜老司机| 欧美变态凌虐bdsm| 欧美一区二区三区在线电影| 色就色 综合激情| aa级大片欧美| 懂色av一区二区三区免费观看| 久久福利资源站| 国产乱理伦片在线观看夜一区| 国产精品麻豆网站| 国产一区二区三区在线观看免费 | 亚洲另类在线制服丝袜| 国产精品剧情在线亚洲| 国产欧美一区在线| 久久久久久电影| 久久久精品国产免大香伊| 精品久久五月天| 欧美成人一区二区三区片免费| 欧美老年两性高潮| 日韩一区二区三区在线| 日韩欧美精品在线视频| 精品久久久久香蕉网| 日韩三级伦理片妻子的秘密按摩| 欧美日韩精品福利| 欧美一区二区在线不卡| 精品日韩在线观看| 久久嫩草精品久久久精品| 久久av资源网| 国产麻豆视频一区| 不卡av免费在线观看| av激情综合网| 欧美日韩在线三级| 8x8x8国产精品| 精品国产91乱码一区二区三区| 久久久精品综合| 国产蜜臀av在线一区二区三区| 国产亚洲一区二区三区在线观看 | 亚洲国产精品久久艾草纯爱| 日日摸夜夜添夜夜添亚洲女人| 久久精品国产99久久6| 国产高清不卡一区| 91久久人澡人人添人人爽欧美| 欧美亚洲愉拍一区二区| 日韩一级大片在线观看| 久久精子c满五个校花| 1区2区3区精品视频| 亚洲777理论| 国产精品一区二区久久精品爱涩 | 在线日韩av片| 欧美一区二区三区播放老司机| 国产女人aaa级久久久级| 有坂深雪av一区二区精品| 日本一不卡视频| caoporn国产一区二区| 欧美日韩精品一区视频| 国产亚洲一二三区| 一区二区不卡在线播放 | 自拍偷拍国产精品| 亚洲成人动漫精品| 国产成人aaa| 欧美综合一区二区| 久久亚洲二区三区| 亚洲一区二区三区在线看| 午夜精品久久久久久久99樱桃| 经典一区二区三区| 91国偷自产一区二区开放时间| 91精品黄色片免费大全| 国产精品久久久久一区二区三区| 亚洲黄色性网站| 韩国女主播一区| 欧美日韩国产精品自在自线| 国产精品素人视频| 极品尤物av久久免费看| 欧美日韩视频不卡| 综合色中文字幕| 国产精品一区专区| 欧美精品久久天天躁| 中文字幕一区在线观看| 国产一区二区美女| 欧美一区二视频| 亚洲国产精品天堂| 99久久精品99国产精品| 中文字幕一区二区视频| 色悠悠久久综合| 一本久久a久久免费精品不卡| 久久影音资源网| 秋霞av亚洲一区二区三| 在线视频中文字幕一区二区| 国产精品亲子伦对白| 狠狠色丁香久久婷婷综合丁香| 欧美日韩国产色站一区二区三区| 亚洲人成网站色在线观看| 顶级嫩模精品视频在线看| 亚洲成人激情av| 欧洲国内综合视频| 亚洲日本电影在线| 丰满少妇在线播放bd日韩电影| 欧美大片在线观看一区二区| 免费欧美在线视频| 欧美色倩网站大全免费| 亚洲老司机在线| 不卡的电影网站| 国产精品久久网站| 国产一区二区日韩精品| 精品久久一区二区| 国内精品在线播放| 久久亚区不卡日本| 国产成人亚洲综合a∨婷婷| 久久九九99视频| 风间由美性色一区二区三区| 国产精品热久久久久夜色精品三区| 国产一区二区不卡在线| 欧美性淫爽ww久久久久无| 国产成人aaa| 久久国产精品露脸对白| 精品一区二区三区在线播放| 99视频精品免费视频| 中文字幕乱码一区二区免费| 国产jizzjizz一区二区| 久久久久国产精品麻豆ai换脸| 国产成人在线免费观看| 国产精品久久久久久福利一牛影视 | 香蕉成人伊视频在线观看| 欧美老女人在线| 美腿丝袜亚洲一区| 久久夜色精品一区| 高清不卡一二三区| 一区二区三区四区不卡视频| 精品视频在线免费看| 麻豆91免费观看| 欧美激情资源网| 一本久道中文字幕精品亚洲嫩| 午夜精品免费在线观看| 日韩欧美在线观看一区二区三区| 国内精品视频666| 国产精品成人免费| 制服丝袜国产精品| 亚洲成av人片在线观看无码| 国产精品国产三级国产| 亚洲女爱视频在线| av资源站一区|