本文整理汇总了Java中org.jbox2d.common.MathUtils.randomFloat方法的典型用法代码示例。如果您正苦于以下问题:Java MathUtils.randomFloat方法的具体用法?Java MathUtils.randomFloat怎么用?Java MathUtils.randomFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jbox2d.common.MathUtils
的用法示例。
在下文中一共展示了MathUtils.randomFloat方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MoveAABB
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
public void MoveAABB(AABB aabb) {
Vec2 d = new Vec2();
d.x = MathUtils.randomFloat(rand, -0.5f, 0.5f);
d.y = MathUtils.randomFloat(rand, -0.5f, 0.5f);
// d.x = 2.0f;
// d.y = 0.0f;
aabb.lowerBound.addLocal(d);
aabb.upperBound.addLocal(d);
Vec2 c0 = aabb.lowerBound.add(aabb.upperBound).mulLocal(.5f);
Vec2 min = new Vec2();
min.set(-worldExtent, 0.0f);
Vec2 max = new Vec2();
max.set(worldExtent, 2.0f * worldExtent);
Vec2 c = MathUtils.clamp(c0, min, max);
aabb.lowerBound.addLocal(c.sub(c0));
aabb.upperBound.addLocal(c.sub(c0));
}
示例2: launch
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
public void launch() {
m_body.setTransform(new Vec2(0.0f, 4.0f), 0.0f);
m_body.setLinearVelocity(new Vec2());
m_body.setAngularVelocity(0.0f);
m_x = MathUtils.randomFloat(-1.0f, 1.0f);
m_bullet.setTransform(new Vec2(m_x, 10.0f), 0.0f);
m_bullet.setLinearVelocity(new Vec2(0.0f, -50.0f));
m_bullet.setAngularVelocity(0.0f);
Distance.GJK_CALLS = 0;
Distance.GJK_ITERS = 0;
Distance.GJK_MAX_ITERS = 0;
TimeOfImpact.toiCalls = 0;
TimeOfImpact.toiIters = 0;
TimeOfImpact.toiMaxIters = 0;
TimeOfImpact.toiRootIters = 0;
TimeOfImpact.toiMaxRootIters = 0;
}
示例3: launch
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
public void launch() {
m_body.setTransform(new Vec2(0.0f, 4.0f), 0.0f);
m_body.setLinearVelocity(new Vec2());
m_body.setAngularVelocity(0.0f);
m_x = MathUtils.randomFloat(-1.0f, 1.0f);
m_bullet.setTransform(new Vec2(m_x, 10.0f), 0.0f);
m_bullet.setLinearVelocity(new Vec2(0.0f, -50.0f));
m_bullet.setAngularVelocity(0.0f);
}
示例4: SPHGroup
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
public SPHGroup(int nParts, AABB aabb, float tStep) {
// set the parameters to some default values
param = new Parameter();
param.numPts = nParts;
param.initVel = new Vec2(0.0f,0.0f);
param.machNum = 0.5;
param.initDensity = 1000.0;
param.initPressure = 10000.0f;
param.nu = 1000.0;
param.deltaT = tStep;
param.numSteps = 500000;
param.outputEvery = 5000;
param.firstOutput = 0;
param.densityVariation = 0.3;
param.lengthScale = 1000.0;
param.bodyFX = 0.0;
param.bodyFY = 0.0;
param.c = 1.0f;
param.h = 1000.0f;
t = new SmoothParticle[nParts];
for (int i=0; i<nParts; ++i) {
float x = MathUtils.randomFloat(aabb.lowerBound.x,aabb.upperBound.x);
float y = MathUtils.randomFloat(aabb.lowerBound.y,aabb.upperBound.y);
t[i] = new SmoothParticle();
t[i].pos.set(new Vec2(x,y));
t[i].vel.set(param.initVel);
t[i].mass = (1.0);
t[i].setDensity(param.initDensity);
t[i].setPressure(param.initPressure);
t[i].setSmoothingLength(param.h);
t[i].setSpeedSound(param.c);
t[i].undeleteParticle();
t[i].ID = i;
t[i].setShapeID(-1);
}
}
示例5: GetRandomAABB
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
public void GetRandomAABB(AABB aabb) {
Vec2 w = new Vec2();
w.set(2.0f * m_proxyExtent, 2.0f * m_proxyExtent);
// aabb.lowerBound.x = -m_proxyExtent;
// aabb.lowerBound.y = -m_proxyExtent + worldExtent;
aabb.lowerBound.x = MathUtils.randomFloat(rand, -worldExtent,
worldExtent);
aabb.lowerBound.y = MathUtils.randomFloat(rand, 0.0f,
2.0f * worldExtent);
aabb.upperBound.set(aabb.lowerBound).addLocal(w);
}
示例6: generate
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
void generate() {
Vec2 lowerBound = new Vec2(-8f, -8f);
Vec2 upperBound = new Vec2(8f, 8f);
for (int i = 0; i < e_count; i++) {
float x = MathUtils.randomFloat(-8, 8);
float y = MathUtils.randomFloat(-8, 8);
Vec2 v = new Vec2(x, y);
MathUtils.clampToOut(v, lowerBound, upperBound, v);
m_points[i] = v;
}
m_count = e_count;
}
示例7: generate
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
void generate() {
Vec2 lowerBound = new Vec2(-8f, -8f);
Vec2 upperBound = new Vec2(8f, 8f);
for (int i = 0; i < count; i++) {
float x = MathUtils.randomFloat(-8, 8);
float y = MathUtils.randomFloat(-8, 8);
Vec2 v = new Vec2(x, y);
MathUtils.clampToOut(v, lowerBound, upperBound, v);
m_points[i] = v;
}
}
示例8: runTest
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
/**
* @see org.jbox2d.testbed.perf.PerfTest#runTest(int)
*/
@Override
public void runTest(int argNum) {
float random = MathUtils.randomFloat(Float.MIN_VALUE/3, Float.MAX_VALUE/3);
switch(argNum){
case 0:
runSinTest(random);
break;
case 1:
runSinLUTTest(random);
break;
case 2:
runPowTest(random);
break;
case 3:
runFastPowTest(random);
break;
case 4:
runMaxTest(random);
break;
case 5:
runFastMaxTest(random);
break;
case 6:
runFloorTest(random);
break;
case 7:
runFastFloorTest(random);
break;
case 8:
runAtan2Test(random);
break;
case 9:
runFastAtan2Test(random);
break;
case 10:
runCeilTest(random);
break;
case 11:
runFastCeilTest(random);
break;
}
}
示例9: checkBounds
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
private void checkBounds() {
for (int i=0; i<liquid.length; ++i) {
if (liquid[i].getWorldCenter().y < -10.0f) {
m_world.destroyBody(liquid[i]);
float massPerParticle = totalMass / nParticles;
CircleShape pd = new CircleShape();
FixtureDef fd = new FixtureDef();
fd.shape = pd;
fd.density = 1.0f;
fd.filter.groupIndex = -10;
pd.m_radius = .05f;
fd.restitution = 0.4f;
fd.friction = 0.0f;
float cx = 0.0f + MathUtils.randomFloat(-0.6f,0.6f);
float cy = 15.0f + MathUtils.randomFloat(-2.3f,2.0f);
BodyDef bd = new BodyDef();
bd.position = new Vec2( cx, cy );
bd.fixedRotation = true;
bd.type = BodyType.DYNAMIC;
Body b = m_world.createBody(bd);
b.createFixture(fd).setUserData(LIQUID_INT);
MassData md = new MassData();
md.mass = massPerParticle;
md.I = 1.0f;
b.setMassData(md);
b.setSleepingAllowed(false);
liquid[i] = b;
}
}
if (bod.getWorldCenter().y < -15.0f) {
m_world.destroyBody(bod);
PolygonShape polyDef = new PolygonShape();
polyDef.setAsBox(MathUtils.randomFloat(0.3f,0.7f), MathUtils.randomFloat(0.3f,0.7f));
BodyDef bodyDef = new BodyDef();
bodyDef.position = new Vec2(0.0f,25.0f);
bodyDef.type = BodyType.DYNAMIC;
bod = m_world.createBody(bodyDef);
bod.createFixture(polyDef, 1f);
}
}
示例10: step
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
@Override
public void step(int argNum) {
float random = MathUtils.randomFloat(-Float.MAX_VALUE / 3, Float.MAX_VALUE / 3);
switch (argNum) {
case 0:
runSinTest(random);
break;
case 1:
runSinLUTTest(random);
break;
case 2:
runPowTest(random);
break;
case 3:
runFastPowTest(random);
break;
case 4:
runMaxTest(random);
break;
case 5:
runFastMaxTest(random);
break;
case 6:
runFloorTest(random);
break;
case 7:
runFastFloorTest(random);
break;
case 8:
runAtan2Test(random);
break;
case 9:
runFastAtan2Test(random);
break;
case 10:
runCeilTest(random);
break;
case 11:
runFastCeilTest(random);
break;
}
}
示例11: runTest
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
/**
* @see org.jbox2d.testbed.perf.BasicPerformanceTest#runTest(int)
*/
@Override
public void runTest(int argNum) {
float random = MathUtils.randomFloat(-Float.MAX_VALUE/3, Float.MAX_VALUE/3);
switch(argNum){
case 0:
runSinTest(random);
break;
case 1:
runSinLUTTest(random);
break;
case 2:
runPowTest(random);
break;
case 3:
runFastPowTest(random);
break;
case 4:
runMaxTest(random);
break;
case 5:
runFastMaxTest(random);
break;
case 6:
runFloorTest(random);
break;
case 7:
runFastFloorTest(random);
break;
case 8:
runAtan2Test(random);
break;
case 9:
runFastAtan2Test(random);
break;
case 10:
runCeilTest(random);
break;
case 11:
runFastCeilTest(random);
break;
}
}
示例12: checkBounds
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
private void checkBounds() {
for (int i = 0; i < liquid.length; ++i) {
if (liquid[i].getWorldCenter().y < -10.0f) {
getWorld().destroyBody(liquid[i]);
float massPerParticle = totalMass / nParticles;
CircleShape pd = new CircleShape();
FixtureDef fd = new FixtureDef();
fd.shape = pd;
fd.density = 1.0f;
fd.filter.groupIndex = -10;
pd.m_radius = .05f;
fd.restitution = 0.4f;
fd.friction = 0.0f;
float cx = 0.0f + MathUtils.randomFloat(-0.6f, 0.6f);
float cy = 15.0f + MathUtils.randomFloat(-2.3f, 2.0f);
BodyDef bd = new BodyDef();
bd.position = new Vec2(cx, cy);
bd.fixedRotation = true;
bd.type = BodyType.DYNAMIC;
Body b = getWorld().createBody(bd);
b.createFixture(fd).setUserData(LIQUID_INT);
MassData md = new MassData();
md.mass = massPerParticle;
md.I = 1.0f;
b.setMassData(md);
b.setSleepingAllowed(false);
liquid[i] = b;
}
}
if (bod.getWorldCenter().y < -15.0f) {
getWorld().destroyBody(bod);
PolygonShape polyDef = new PolygonShape();
polyDef.setAsBox(MathUtils.randomFloat(0.3f, 0.7f), MathUtils.randomFloat(0.3f, 0.7f));
BodyDef bodyDef = new BodyDef();
bodyDef.position = new Vec2(0.0f, 25.0f);
bodyDef.type = BodyType.DYNAMIC;
bod = getWorld().createBody(bodyDef);
bod.createFixture(polyDef, 1f);
}
}