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


Java ManifoldType.CIRCLES属性代码示例

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


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

示例1: collideCircles

/**
 * Compute the collision manifold between two circles.
 * 
 * @param manifold
 * @param circle1
 * @param xfA
 * @param circle2
 * @param xfB
 */
public final void collideCircles(Manifold manifold, final CircleShape circle1, final Transform xfA,
		final CircleShape circle2, final Transform xfB) {
	manifold.pointCount = 0;
	
	Transform.mulToOut(xfA, circle1.m_p, pA);
	Transform.mulToOut(xfB, circle2.m_p, pB);
	
	d.set(pB).subLocal(pA);
	float distSqr = Vec2.dot(d, d);
	float radius = circle1.m_radius + circle2.m_radius;
	if (distSqr > radius * radius) {
		return;
	}
	
	manifold.type = ManifoldType.CIRCLES;
	manifold.localPoint.set(circle1.m_p);
	manifold.localNormal.setZero();
	manifold.pointCount = 1;
	
	manifold.points[0].localPoint.set(circle2.m_p);
	manifold.points[0].id.zero();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:31,代码来源:Collision.java

示例2: collideCircles

/**
 * Compute the collision manifold between two circles.
 * 
 * @param manifold
 * @param circle1
 * @param xfA
 * @param circle2
 * @param xfB
 */
public final void collideCircles(Manifold manifold, final CircleShape circle1,
    final Transform xfA, final CircleShape circle2, final Transform xfB) {
  manifold.pointCount = 0;
  // before inline:
  // Transform.mulToOut(xfA, circle1.m_p, pA);
  // Transform.mulToOut(xfB, circle2.m_p, pB);
  // d.set(pB).subLocal(pA);
  // float distSqr = d.x * d.x + d.y * d.y;

  // after inline:
  Vec2 circle1p = circle1.m_p;
  Vec2 circle2p = circle2.m_p;
  float pAx = (xfA.q.c * circle1p.x - xfA.q.s * circle1p.y) + xfA.p.x;
  float pAy = (xfA.q.s * circle1p.x + xfA.q.c * circle1p.y) + xfA.p.y;
  float pBx = (xfB.q.c * circle2p.x - xfB.q.s * circle2p.y) + xfB.p.x;
  float pBy = (xfB.q.s * circle2p.x + xfB.q.c * circle2p.y) + xfB.p.y;
  float dx = pBx - pAx;
  float dy = pBy - pAy;
  float distSqr = dx * dx + dy * dy;
  // end inline

  final float radius = circle1.m_radius + circle2.m_radius;
  if (distSqr > radius * radius) {
    return;
  }

  manifold.type = ManifoldType.CIRCLES;
  manifold.localPoint.set(circle1p);
  manifold.localNormal.setZero();
  manifold.pointCount = 1;

  manifold.points[0].localPoint.set(circle2p);
  manifold.points[0].id.zero();
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:43,代码来源:Collision.java

示例3: collideCircles

/**
 * Compute the collision manifold between two circles.
 * 
 * @param manifold
 * @param circle1
 * @param xfA
 * @param circle2
 * @param xfB
 */
public final void collideCircles(Manifold manifold, final CircleShape circle1,
    final Transform xfA, final CircleShape circle2, final Transform xfB) {
  manifold.pointCount = 0;
  // before inline:
  // Transform.mulToOut(xfA, circle1.m_p, pA);
  // Transform.mulToOut(xfB, circle2.m_p, pB);
  // d.set(pB).subLocal(pA);
  // float distSqr = d.x * d.x + d.y * d.y;

  // after inline:
  Vector2 circle1p = circle1.m_p;
  Vector2 circle2p = circle2.m_p;
  float pAx = (xfA.q.c * circle1p.x - xfA.q.s * circle1p.y) + xfA.p.x;
  float pAy = (xfA.q.s * circle1p.x + xfA.q.c * circle1p.y) + xfA.p.y;
  float pBx = (xfB.q.c * circle2p.x - xfB.q.s * circle2p.y) + xfB.p.x;
  float pBy = (xfB.q.s * circle2p.x + xfB.q.c * circle2p.y) + xfB.p.y;
  float dx = pBx - pAx;
  float dy = pBy - pAy;
  float distSqr = dx * dx + dy * dy;
  // end inline

  final float radius = circle1.m_radius + circle2.m_radius;
  if (distSqr > radius * radius) {
    return;
  }

  manifold.type = ManifoldType.CIRCLES;
  manifold.localPoint.set(circle1p);
  manifold.localNormal.setZero();
  manifold.pointCount = 1;

  manifold.points[0].localPoint.set(circle2p);
  manifold.points[0].id.zero();
}
 
开发者ID:pianoman373,项目名称:Point-Engine,代码行数:43,代码来源:Collision.java

示例4: collideCircles

/**
	 * Compute the collision manifold between two circles.
	 * 
	 * @param manifold
	 * @param circle1
	 * @param xfA
	 * @param circle2
	 * @param xfB
	 */
	public final void collideCircles(Manifold manifold, final CircleShape circle1, final Transform xfA,
			final CircleShape circle2, final Transform xfB) {
		manifold.pointCount = 0;
		
    // before inline:
//		Transform.mulToOut(xfA, circle1.m_p, pA);
//    Transform.mulToOut(xfB, circle2.m_p, pB);
//		d.set(pB).subLocal(pA);
//    float distSqr = d.x * d.x + d.y * d.y;
    
    // after inline:
    final Vec2 v = circle1.m_p;
		final float pAy = xfA.position.y + xfA.R.col1.y * v.x + xfA.R.col2.y * v.y;
    final float pAx = xfA.position.x + xfA.R.col1.x * v.x + xfA.R.col2.x * v.y;

    final Vec2 v1 = circle2.m_p;
		final float pBy = xfB.position.y + xfB.R.col1.y * v1.x + xfB.R.col2.y * v1.y;
    final float pBx = xfB.position.x + xfB.R.col1.x * v1.x + xfB.R.col2.x * v1.y;
    
    final float dx = pBx - pAx;
    final float dy = pBy - pAy;
    
    final float distSqr = dx * dx + dy * dy;
    // end inline
		
		final float radius = circle1.m_radius + circle2.m_radius;
		if (distSqr > radius * radius) {
			return;
		}
		
		manifold.type = ManifoldType.CIRCLES;
		manifold.localPoint.set(circle1.m_p);
		manifold.localNormal.setZero();
		manifold.pointCount = 1;
		
		manifold.points[0].localPoint.set(circle2.m_p);
		manifold.points[0].id.zero();
	}
 
开发者ID:col726,项目名称:game-engine-CMZ,代码行数:47,代码来源:Collision.java


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