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


Java CircleShape.getRadius方法代码示例

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


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

示例1: ComputeSubmergedArea

import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
public static float ComputeSubmergedArea(CircleShape shape, Vector2 normal, float offset, Transform xf, Vector2 c)
{
   Vector2 p = xf.mul(shape.getPosition());
   float l = -(normal.dot(p) - offset);
   float r = shape.getRadius();

   if (l < -r)
   { // Completely dry
      return 0;
   }

   if (l > r)
   { // Completely wet
      c.set(p);
      return MathUtils.PI * r * r;
   }

   float r2 = r * r;
   float l2 = l * l;
   float area = r2 * ((float) Math.asin(l / r) + MathUtils.PI / 2) + l * (float) Math.sqrt(r2 - l2);
   float com = -2.0f / 3.0f * (float) Math.pow(r2 - l2, 1.5f) / area;
   c.x = p.x + normal.x * com;
   c.y = p.y + normal.y * com;
   return area;
}
 
开发者ID:tescott,项目名称:box2dcontrollers,代码行数:26,代码来源:B2ShapeExtensions.java

示例2: ComputeSubmergedArea

import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
public static float ComputeSubmergedArea(CircleShape shape, Vector2 normal, float offset, Transform xf, Vector2 c)
{
    Vector2 p = xf.mul(shape.getPosition());
    float l = -(normal.dot(p) - offset);
    float r = shape.getRadius();

    if (l < -r)
    { // Completely dry
        return 0;
    }

    if (l > r)
    { // Completely wet
        c.set(p);
        return MathUtils.PI * r * r;
    }

    float r2 = r * r;
    float l2 = l * l;
    float area = r2 * ((float) Math.asin(l / r) + MathUtils.PI / 2) + l * (float) Math.sqrt(r2 - l2);
    float com = -2.0f / 3.0f * (float) Math.pow(r2 - l2, 1.5f) / area;
    c.x = p.x + normal.x * com;
    c.y = p.y + normal.y * com;
    return area;
}
 
开发者ID:Rubentxu,项目名称:DreamsLibGdx,代码行数:26,代码来源:BuoyancyUtils.java

示例3: draw

import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
public void draw(IFieldRenderer renderer) {
    CircleShape shape = (CircleShape)body.getFixtureList().get(0).getShape();
    Vector2 center = body.getPosition();
    float radius = shape.getRadius();
    renderer.fillCircle(center.x, center.y, radius, primaryColor);

    // Draw a smaller circle to show the ball's rotation.
    float angle = body.getAngle();
    float smallCenterX = center.x + (radius / 2) * MathUtils.cos(angle);
    float smallCenterY = center.y + (radius / 2) * MathUtils.sin(angle);
    renderer.fillCircle(smallCenterX, smallCenterY, radius / 4, secondaryColor);
}
 
开发者ID:StringMon,项目名称:homescreenarcade,代码行数:13,代码来源:Ball.java

示例4: RenderOfCircleFixture

import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
public RenderOfCircleFixture(Fixture fixture, VertexBufferObjectManager pVBO) {
	super(fixture);

	CircleShape fixtureShape = (CircleShape) fixture.getShape();
	Vector2 position = fixtureShape.getPosition();
	float radius = fixtureShape.getRadius() * PhysicsConnector.PIXEL_TO_METER_RATIO_DEFAULT;

	mEntity = new Ellipse(position.x * PhysicsConnector.PIXEL_TO_METER_RATIO_DEFAULT,
			position.y * PhysicsConnector.PIXEL_TO_METER_RATIO_DEFAULT,
			radius, radius, pVBO);
}
 
开发者ID:mediamonks,项目名称:tilt-game-android,代码行数:12,代码来源:RenderOfCircleFixture.java

示例5: createShape

import com.badlogic.gdx.physics.box2d.CircleShape; //导入方法依赖的package包/类
/**
 * Creates the shape.
 */
@Override
public void createShape()
{
	shape = new CircleShape();
	shape.setRadius(_radius/B2FlxB.RATIO);
	// The shape radius is gone when the shape got disposed.
	_shapeRadius = shape.getRadius();
	fixtureDef.shape = shape;
}
 
开发者ID:flixel-gdx,项目名称:flixel-gdx-box2d,代码行数:13,代码来源:B2FlxCircle.java


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