Ejemplo n.º 1
0
 /// <summary>
 /// 获得外接圆的包围盒
 /// </summary>
 /// <param name="circle"></param>
 /// <returns></returns>
 public static Rect GetCircleBoundBox(Circle circle)
 {
     Rect bBox = new Rect();
     bBox.xMin = circle.center.x - circle.radius;
     bBox.xMax = circle.center.x + circle.radius;
     bBox.yMin = circle.center.y - circle.radius;
     bBox.yMax = circle.center.y + circle.radius;
     return bBox;
 }
Ejemplo n.º 2
0
		/// <summary>
		/// Checks the cross.
		/// </summary>
		/// <returns><c>true</c>, if cross was checked, <c>false</c> otherwise.</returns>
		/// <param name="line">Line.</param>
		/// <param name="cir">Cir.</param>
		public static bool CheckCross( Line2D line , Circle cir )
		{
			return CheckCross(line , cir.center , cir.radius);
		}
Ejemplo n.º 3
0
		/// <summary>
		/// Calculate the circle tangency.
		/// </summary>
		/// <returns>The circle tangency.</returns>
		/// <param name="c">C.</param>
		/// <param name="st">St.</param>
		public static Vector2[] CalCircleTangency( Circle c , Vector2 st )
		{
			Vector2 dir;
			float dis = (c.center - st).magnitude;
			float temp= Mathf.Sqrt(dis*dis-c.radius*c.radius);
			float sina=temp/dis;
			float cosa=c.radius/dis;
			dir.x=(st.x-c.center.x)/dis*c.radius;
			dir.y=(st.y-c.center.y)/dis*c.radius;

			Vector2[] res = new Vector2[2];

			res[0].x = c.center.x+(dir.x*cosa-dir.y*sina);
			res[0].y = c.center.y+(dir.x*sina+dir.y*cosa);
			
			res[1].x = c.center.x+(dir.x*cosa+dir.y*sina);
			res[1].y = c.center.y+(-dir.x*sina+dir.y*cosa);

			return res;
		}