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

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

?? capturesim.java

?? 一個多機器人的仿真平臺
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/* * CaptureSim.java */package EDU.gatech.cc.is.abstractrobot;import java.awt.*;import java.util.Enumeration;import EDU.gatech.cc.is.util.*;import EDU.gatech.cc.is.simulation.*;import EDU.gatech.cc.is.communication.*;import EDU.cmu.cs.coral.util.Polygon2;import EDU.cmu.cs.coral.util.Circle2;/** * CaptureSim implements Capture for simulation. * Also includes code implementing communication, gripper and * vision. * <P> * <A HREF="../COPYRIGHT.html">Copyright</A> * (c)1998 Tucker Balch * * @see Capture * @author Tucker Balch * @version $Revision: 1.5 $ */public class CaptureSim extends Simple	implements Capture, SimpleN150, SimulatedObject	{	private	CircularBuffer	trail;	// robot's trail	private KinSensorSim	kin_sensor;	// senses our kin	private TransceiverSim	transceiver;	// comm to other robots	private Vec2	position;	private Vec2	steer;	private	double	turret;	private	double	speed;	private	Color	foreground, background;	private long	time;	private double	timed;	private double	left, right, top, bottom;	private	SimulatedObject[] all_objects = new SimulatedObject[0];	private	int	visionclass;	public	static final boolean DEBUG = false;	/**	 * Instantiate a <B>CaptureSim</B> object.  Be sure	 * to also call init with proper values.	 * @see CaptureSim#init	 */        public CaptureSim()		{		/*--- set parameters ---*/                super(1);		position = new Vec2(0,0);		steer = new Vec2(1,0);		turret = 0;		foreground = Color.black;		background = Color.black;		if (DEBUG) System.out.println("CaptureSim: instantiated.");		/*--- set default bounds ---*/		top = 1000;		bottom = -1000;		left = -1000;		right = 1000;				}	        /**         * Initialize a <B>CaptureSim</B> object.         */	public void init(double xp, double yp, double tp, double ignore,		Color f, Color b, int v, int i, long s)		{		trail = new CircularBuffer(1000);		setID(i);                kin_sensor = new KinSensorSim(this);		transceiver = new TransceiverSim(this, this);		position = new Vec2(xp,yp);		steer = new Vec2(1,0);		steer.sett(tp);		turret = tp;		foreground = f;		background = b;		time = 0;		timed = 0;		visionclass = v;		if (DEBUG) System.out.println("CaptureSim: initialized"			+" at "+xp+","+yp);		}	/**	 * Take a simulated step;	 */	public void takeStep(long time_increment, SimulatedObject[] all_objs)		{		if (DEBUG) System.out.println("CaptureSim.TakeStep()");		/*--- keep pointer to the other objects ---*/		all_objects = all_objs;		/*--- update the time ---*/		time += time_increment;		double time_incd = ((double)time_increment)/1000;		timed += time_incd;		/*--- update the steering ---*/		double sturn = Units.BestTurnRad(steer.t, desired_heading);		if (Math.abs(sturn) > (MAX_STEER*time_incd))			{			if (sturn<0)				sturn = -MAX_STEER*time_incd;			else sturn = MAX_STEER*time_incd;			}		steer.sett(steer.t + sturn);		/*--- update the turret ---*/		double tturn = Units.BestTurnRad(turret, 			desired_turret_heading);		if (Math.abs(tturn) > (MAX_TURRET*time_incd))			{			if (tturn<0)				tturn = -MAX_TURRET*time_incd;			else tturn = MAX_TURRET*time_incd;			}		turret = Units.ClipRad(turret + tturn);		/*--- compute velocity ---*/		Vec2 velocity = new Vec2(steer.x, steer.y);		if (in_reverse)			velocity.setr(-base_speed * desired_speed);		else			velocity.setr(base_speed * desired_speed);		// don't drive unless close turret aligned.		//if (Math.abs(Units.BestTurnRad(turret,                        //desired_turret_heading))>Math.PI/2.0)			//velocity.setr(0.00001);		/*--- compute a movement step ---*/		Vec2 mvstep = new Vec2(velocity.x, velocity.y);		mvstep.setr(mvstep.r * time_incd);		/*--- test the new position to see if in bounds ---*/		Vec2 pp = new Vec2(position.x, position.y);		pp.add(mvstep);		if (pp.x+RADIUS > right)			{			position.setx(right-RADIUS);			velocity.setx(0);			mvstep.setx(0);			}		else if (pp.x-RADIUS < left)			{			position.setx(left+RADIUS);			velocity.setx(0);			mvstep.setx(0);			}		if (pp.y+RADIUS > top)			{			position.sety(top-RADIUS);			velocity.sety(0);			mvstep.sety(0);			}		else if (pp.y-RADIUS < bottom)			{			position.sety(bottom+RADIUS);			velocity.sety(0);			mvstep.sety(0);			}		/*--- test the new position to see if on top of obstacle ---*/		pp = new Vec2(position.x, position.y);		boolean moveok = true;		pp.add(mvstep);		for (int i=0; i<all_objects.length; i++)			{			if (all_objects[i].isObstacle() && 				(all_objects[i].getID() != unique_id))				{				Vec2 tmp = all_objects[i].getClosestPoint(pp);				if (tmp.r < RADIUS)					{					moveok = false;					break;					}				}			}		if (moveok) position.add(mvstep);		/*--- test the new position to see if on top of pushable ---*/		for (int i=0; i<all_objects.length; i++)			{			if (all_objects[i].isPushable() && 				(all_objects[i].getID() != unique_id))				{				Vec2 tmp = all_objects[i].getClosestPoint(pp);				if (tmp.r < RADIUS)					{					tmp.setr(RADIUS - tmp.r);					all_objects[i].push(tmp, velocity);					}				}			}		/*--- check for object in gripper ---*/		if (trigger_mode)			setGripperFingers(-1,-1);		}	/*--- From SimulatedObject ---*/	public boolean isObstacle()		{		return(true);		}		public boolean isPushable()		{		return(false);		}		public boolean isPickupable()		{		return(false);		}		public Vec2 getClosestPoint(Vec2 from)		{		Vec2 tmp = new Vec2(position.x, position.y);		tmp.sub(from);		if (tmp.r < RADIUS)			tmp.setr(0);		else			tmp.setr(tmp.r-RADIUS);		return(tmp);		}        /**	 * determine if the object is intersecting with a specified circle.	 * This is useful for obstacle avoidance and so on.	 * @param c the circle which may be intersecting the current object.	 * @return true if collision detected.         */	public boolean checkCollision(Circle2 c)	    {	    Vec2 closest = getClosestPoint(c.centre); // closest is a vector with origin at centre that leads to closest point on current object	    if (closest.r <= c.radius) // closest point is within c.radius of c.centre			{			return true;			}	    else 			{			return false;			}	    }        /**	 * determine if the object is intersecting with a specified polygon.	 * This is useful for obstacle avoidance and so on.	 * @param p the polygon which may be intersecting the current object.	 * @return true if collision detected.         */	public boolean checkCollision(Polygon2 p)		{		Vec2 vertex1, vertex2, vec1, vector2, closestPt;		int numberEdges = p.vertices.size(); // n edges if n vertices (as vertex n+1 wraps round to vertex 0)		double scale;		for (int i=0;i<numberEdges;i++)			{			vertex1 = (Vec2)p.vertices.elementAt(i);			vertex2 = (Vec2)p.vertices.elementAt((i+1)%numberEdges);			vertex1.sub(position);			vertex2.sub(position);			// if either vertex is within the circles radius you are colliding			if ((vertex1.r < RADIUS) || (vertex2.r < RADIUS))				{				return true;				} 			vertex1.add(position);			vertex2.add(position);			vec1 = new Vec2(vertex2);			vec1.sub(vertex1);			vector2 = new Vec2(position);			vector2.sub(vertex1);			scale = ((vec1.x*vector2.x)+(vec1.y*vector2.y))/((vec1.x*vec1.x)+(vec1.y*vec1.y));			closestPt = new Vec2(scale*vec1.x, scale*vec1.y);			closestPt.add(vertex1); // absolute position of closest point			closestPt.sub(position); // position of closest point relative to centre of current object			if (closestPt.r < RADIUS)				{				// now need to check if closestPt lies between vertex1 and vertex2				// i.e. it could lie on vector between them but outside of them				if ( (scale > 0.0) && (scale < 1.0) )					{					return true;					}				}			}		return false; // closest point to object on each edge of polygon not within object					}	public Vec2 getCenter(Vec2 from)		{		Vec2 tmp = new Vec2(position.x, position.y);		tmp.sub(from);		return(tmp);		}	public void push(Vec2 d, Vec2 v)		{		// sorry no pushee robots!		}	public void pickUp(SimulatedObject o)		{		// sorry no pickupee robots!		}	public void putDown(Vec2 p)		{		// sorry no put downee robots!		}	public void setVisionClass(int v)		{		visionclass = v;		}	public int getVisionClass()		{		return(visionclass);		}	/**         * Draw the robot's ID.         */        public void drawID(Graphics g, int w, int h,                double t, double b, double l, double r)                {                top =t; bottom =b; left =l; right =r;                if (DEBUG) System.out.println("draw "+                        w + " " +                        h + " " +                        t + " " +                        b + " " +                        l + " " +                        r + " ");                double meterspp = (r - l) / (double)w;                int radius = (int)(RADIUS / meterspp);                int xpix = (int)((position.x - l) / meterspp);                int ypix = (int)((double)h - ((position.y - b) / meterspp));                /*--- draw ID ---*/                g.setColor(background);                g.drawString(String.valueOf(getPlayerNumber(0))			,xpix-radius,ypix-radius);                }        private Point last = new Point(0,0);        /**         * Draw the robot's Trail.         */        public void drawTrail(Graphics g, int w, int h,                double t, double b, double l, double r)                {                top =t; bottom =b; left =l; right =r;                if (DEBUG) System.out.println("draw "+                        w + " " +                        h + " " +                        t + " " +                        b + " " +                        l + " " +                        r + " ");                double meterspp = (r - l) / (double)w;                int xpix = (int)((position.x - l) / meterspp);                int ypix = (int)((double)h - ((position.y - b) / meterspp));                /*--- record the point ---*/                Point p = new Point(xpix,ypix);                if ((last.x!=xpix)||(last.y!=ypix))                        trail.put(p);                last = p;                /*--- get the list of all points ---*/                Enumeration point_list = trail.elements();                /*--- draw the trail ---*/                g.setColor(background);                Point from = (Point)point_list.nextElement();                while (point_list.hasMoreElements())                        {                        Point next = (Point)point_list.nextElement();                        g.drawLine(from.x,from.y,next.x,next.y);                        from = next;                        }                }	private String display_string = "blank";	/**         * Set the String that is printed on the robot's display.         * For simulated robots, this appears printed below the agent         * when view "Robot State" is selected.         * @param s String, the text to display.         */        public void setDisplayString(String s)		{		display_string = s;		}	  public Color getForegroundColor() { return foreground; }	  public Color getBackgroundColor() { return background; }        /**         * Draw the robot's state.         */        public void drawState(Graphics g, int w, int h,                double t, double b, double l, double r)                {                top =t; bottom =b; left =l; right =r;                if (DEBUG) System.out.println("draw "+                        w + " " +                        h + " " +                        t + " " +                        b + " " +                        l + " " +                        r + " ");                double meterspp = (r - l) / (double)w;                int radius = (int)(RADIUS / meterspp);                int xpix = (int)((position.x - l) / meterspp);                int ypix = (int)((double)h - ((position.y - b) / meterspp));                /*--- draw State ---*/                g.setColor(background);                g.drawString(display_string,xpix+radius+3,ypix-radius);		/*--- draw Vectors ---*/		displayVectors.draw(g, w, h, t, b, l, r);                }	/**         * Set the length of the trail (in movement steps).         * @param l int, the length of the trail.         */        public void setTrailLength(int l)		{		trail = new CircularBuffer(l);		}        /**         * Clear the trail.         */        public void clearTrail()		{		trail.clear();		}        /**         * Draw the robot in a specific spot.         */        public void draw(Vec2 pos, Graphics g, int w, int h,                double t, double b, double l, double r)                {                Vec2 old_pos = position;                position = pos;                draw(g,w,h,t,b,l,r);                position = old_pos;                }        /**         * Draw the object as an icon.         * Default is just to do a regular draw.         */        public void drawIcon(Graphics g, int w, int h,                double t, double b, double l, double r)                {                draw(g, w, h, t, b, l, r);                }	/**	 * Draw the robot.	 */	public void draw(Graphics g, int w, int h,		double t, double b, double l, double r)		{		top =t; bottom =b; left =l; right =r;		if (DEBUG) System.out.println("draw "+			w + " " +			h + " " +			t + " " +			b + " " +			l + " " +			r + " ");		double meterspp = (r - l) / (double)w;		if (DEBUG) System.out.println("meterspp "+meterspp);		int radius = (int)(RADIUS / meterspp);		int turretd = (int)Units.RadToDeg(turret);		int visionr = (int)(Capture.VISION_RANGE / meterspp);		int xpix = (int)((position.x - l) / meterspp);		int ypix = (int)((double)h - ((position.y - b) / meterspp));		if (DEBUG) System.out.println("robot at"+			" at "+xpix+","+ypix);		/*--- draw the main body ---*/		g.setColor(foreground);		g.fillOval(xpix - radius, ypix - radius,			radius + radius, radius + radius);		//g.drawOval(xpix - radius, ypix - radius,		//	radius + radius, radius + radius);		/*--- draw the turret ---*/		g.setColor(background);		int dirx = xpix + (int)((double)radius * Math.cos(turret));		int diry = ypix + -(int)((double)radius * Math.sin(turret));		g.drawLine(xpix, ypix, dirx, diry);		// don't draw the vision arc for capture agents		//g.drawArc(xpix - visionr, ypix - visionr,		//		visionr + visionr, visionr + visionr,		//		turretd - (MultiForageN150.VISION_FOV_DEG/2), 		//			MultiForageN150.VISION_FOV_DEG);		/*--- draw steer      ---*/		dirx = xpix + (int)((double)radius * Math.cos(steer.t)*0.5);		diry = ypix + -(int)((double)radius * Math.sin(steer.t)*0.5);		g.drawLine(xpix, ypix, dirx, diry);		/*--- draw what we are carrying ---*/		if (in_gripper != null)			{			Vec2 gpos = new Vec2(RADIUS,0);			gpos.sett(turret);			gpos.add(position);			in_gripper.draw(gpos,g,w,h,t,b,l,r);			}		}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91亚洲精品久久久蜜桃网站 | 成人福利电影精品一区二区在线观看| 欧美乱妇23p| 日韩黄色免费电影| 日韩视频一区二区在线观看| 老司机精品视频导航| 精品乱人伦小说| 粉嫩一区二区三区在线看| 欧美国产激情一区二区三区蜜月| 国产电影一区二区三区| 亚洲欧洲国产专区| 91理论电影在线观看| 亚洲成人动漫在线免费观看| 日韩午夜精品视频| 国产精品一二三四区| 中文字幕乱码日本亚洲一区二区| 91亚洲国产成人精品一区二三| 夜夜嗨av一区二区三区四季av| 精品视频一区三区九区| 麻豆精品蜜桃视频网站| 欧美极品少妇xxxxⅹ高跟鞋| 色吧成人激情小说| 捆绑变态av一区二区三区 | 国产网站一区二区三区| 不卡一区二区三区四区| 五月婷婷色综合| 国产亚洲欧美日韩俺去了| 99riav一区二区三区| 免费高清成人在线| 中文字幕亚洲视频| 日韩一级二级三级精品视频| 成人午夜私人影院| 日韩精品一二区| 中文字幕av一区二区三区高| 欧美体内she精视频| 国产一二三精品| 亚洲观看高清完整版在线观看 | 欧美一区二区在线观看| 国产成人免费在线观看| 午夜精品福利一区二区三区蜜桃| 国产欧美精品一区二区色综合 | 日韩视频免费观看高清在线视频| 成人18精品视频| 久久99精品久久久久久国产越南| 亚洲美女淫视频| 国产三级一区二区三区| 9191精品国产综合久久久久久| 成人黄色软件下载| 国产一区久久久| 日本午夜一本久久久综合| 综合激情网...| 国产网红主播福利一区二区| 日韩一区二区三| 欧美三级在线看| 99re免费视频精品全部| 国产高清在线精品| 日本视频一区二区| 一区二区三区不卡视频在线观看 | 免费成人在线视频观看| 亚洲电影一区二区三区| 亚洲精品欧美二区三区中文字幕| 久久综合久久久久88| 欧美成人精品高清在线播放| 欧美日韩aaaaa| 欧美性猛片xxxx免费看久爱| thepron国产精品| 成人国产精品视频| 懂色av一区二区三区免费看| 国产精品456| 国产一区二区三区在线观看免费视频 | 欧美主播一区二区三区| 99精品视频在线观看免费| 成人开心网精品视频| 粉嫩蜜臀av国产精品网站| 国产福利精品导航| 国产 欧美在线| 成人久久18免费网站麻豆| 波多野结衣在线一区| 丰满白嫩尤物一区二区| 成人国产精品免费| 99久久精品免费看| 99re热这里只有精品免费视频| www.视频一区| 成人爽a毛片一区二区免费| 国产91富婆露脸刺激对白| 国产精华液一区二区三区| 国产v日产∨综合v精品视频| 国产1区2区3区精品美女| a级精品国产片在线观看| 99久久99久久精品免费看蜜桃| 成人福利电影精品一区二区在线观看| gogo大胆日本视频一区| 91美女视频网站| 欧美日韩精品三区| 日韩欧美国产午夜精品| 精品999久久久| 国产精品欧美经典| 一区2区3区在线看| 蜜桃久久久久久| 丁香婷婷深情五月亚洲| 91看片淫黄大片一级在线观看| 91国在线观看| 91超碰这里只有精品国产| 欧美www视频| 亚洲欧洲日韩av| 日韩av电影天堂| 福利一区福利二区| 欧美三级在线视频| 亚洲精品一区二区精华| 中文字幕的久久| 亚洲成av人片在线| 国产精品亚洲一区二区三区在线| 91视频你懂的| 日韩精品一区二区在线观看| 中文字幕中文字幕在线一区| 亚洲chinese男男1069| 久久97超碰国产精品超碰| 99久久精品国产导航| 欧美日韩精品欧美日韩精品| 精品国产91乱码一区二区三区| 国产精品毛片高清在线完整版| 亚洲福中文字幕伊人影院| 国产成人免费在线观看不卡| 欧美日韩二区三区| 亚洲国产精品ⅴa在线观看| 天天操天天干天天综合网| 国产精品77777竹菊影视小说| 欧美亚洲另类激情小说| 国产日本欧洲亚洲| 视频一区欧美日韩| 91网站在线播放| 久久一区二区三区四区| 亚洲成人精品影院| 色综合久久综合| 久久久久国产精品厨房| 日韩精品欧美成人高清一区二区| 97精品国产露脸对白| 精品国产一区二区三区av性色 | 欧美精品久久99| 亚洲裸体在线观看| 国产suv精品一区二区6| 欧美一卡二卡三卡四卡| 亚洲综合免费观看高清完整版在线| 国产高清视频一区| 久久综合九色欧美综合狠狠| 午夜不卡av在线| 欧美在线免费视屏| 中文字幕人成不卡一区| 成人手机电影网| 亚洲精品一线二线三线| 免费高清不卡av| 欧美一区二区日韩一区二区| 亚洲自拍偷拍麻豆| 91色九色蝌蚪| 国产精品九色蝌蚪自拍| 高清beeg欧美| 国产免费成人在线视频| 国产精品1024| 国产亚洲午夜高清国产拍精品| 久久精品国产一区二区| 这里只有精品视频在线观看| 亚洲成人av一区| 欧美日韩国产另类一区| 亚洲午夜羞羞片| 欧美中文字幕不卡| 一区二区三区鲁丝不卡| 色乱码一区二区三区88| 亚洲嫩草精品久久| 色国产综合视频| 亚洲精品老司机| 欧美视频一区二区三区| 日韩在线卡一卡二| 5858s免费视频成人| 男男视频亚洲欧美| 精品国产伦一区二区三区观看方式 | 久久一二三国产| 国产精一区二区三区| 国产欧美精品在线观看| 成年人午夜久久久| 一区二区在线观看av| 欧美日韩一区国产| 青草av.久久免费一区| 26uuu精品一区二区| 成人毛片老司机大片| 亚洲色图在线播放| 欧美精品v国产精品v日韩精品| 日韩电影免费在线观看网站| 日韩一区二区三免费高清| 国产一区二区三区国产| 中文字幕成人在线观看| 在线中文字幕一区| 麻豆精品国产91久久久久久| 久久亚洲私人国产精品va媚药| 国产91露脸合集magnet| 一区二区三区精品视频| 日韩欧美一区二区视频| 成人avav影音| 日韩av二区在线播放| 中文成人av在线| 7777精品伊人久久久大香线蕉完整版|