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


Java MathUtils.max方法代码示例

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


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

示例1: getMaxBalance

import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
@Override
public int getMaxBalance() {
  int maxBalance = 0;
  for (int i = 0; i < m_nodeCapacity; ++i) {
    if (m_height[i] <= 1) {
      continue;
    }

    assert (m_child1[i] != NULL_NODE);

    int child1 = m_child1[i];
    int child2 = m_child2[i];
    int balance = MathUtils.abs(m_height[child2] - m_height[child1]);
    maxBalance = MathUtils.max(maxBalance, balance);
  }

  return maxBalance;
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:19,代码来源:DynamicTreeFlatNodes.java

示例2: keyPressed

import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
public void keyPressed() {
  switch (key) {
    case 'a':
      m_spring1.enableMotor(true);
      m_spring1.setMotorSpeed(m_speed);
      break;
    case 's':
      m_spring1.enableMotor(true);
      m_spring1.setMotorSpeed(0.0f);
      break;
    case 'd':
      m_spring1.enableMotor(true);
      m_spring1.setMotorSpeed(-m_speed);
      break;
    case 'q':
      m_hz = MathUtils.max(0.0f, m_hz - 1.0f);
      m_spring1.setSpringFrequencyHz(m_hz);
      m_spring2.setSpringFrequencyHz(m_hz);
      break;
    case 'e':
      m_hz += 1.0f;
      m_spring1.setSpringFrequencyHz(m_hz);
      m_spring2.setSpringFrequencyHz(m_hz);
      break;
  }
}
 
开发者ID:diwi,项目名称:LiquidFunProcessing,代码行数:27,代码来源:box2d_Car.java

示例3: postSolve

import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
  if (m_broke) {
    // The body already broke.
    return;
  }

  // Should the body break?
  int count = contact.getManifold().pointCount;

  float maxImpulse = 0.0f;
  for (int i = 0; i < count; ++i) {
    maxImpulse = MathUtils.max(maxImpulse, impulse.normalImpulses[i]);
  }
  
  if (maxImpulse > 30.0f) {
    // Flag the body for breaking.
    m_break = true;
  }
}
 
开发者ID:diwi,项目名称:LiquidFunProcessing,代码行数:21,代码来源:box2d_Breakable.java

示例4: postSolve

import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
/**
 * @see org.jbox2d.testbed.framework.TestbedTest#postSolve(org.jbox2d.dynamics.contacts.Contact,
 *      org.jbox2d.callbacks.ContactImpulse)
 */
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
	if (m_broke) {
		// The body already broke.
		return;
	}
	
	// Should the body break?
	int count = contact.getManifold().pointCount;
	
	float maxImpulse = 0.0f;
	for (int i = 0; i < count; ++i) {
		maxImpulse = MathUtils.max(maxImpulse, impulse.normalImpulses[i]);
	}
	
	if (maxImpulse > 40.0f) {
		// Flag the body for breaking.
		m_break = true;
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:25,代码来源:Breakable.java

示例5: getMaxBalance

import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
@Override
public int getMaxBalance() {
  int maxBalance = 0;
  for (int i = 0; i < m_nodeCapacity; ++i) {
    final DynamicTreeNode node = m_nodes[i];
    if (node.height <= 1) {
      continue;
    }

    assert (node.isLeaf() == false);

    DynamicTreeNode child1 = node.child1;
    DynamicTreeNode child2 = node.child2;
    int balance = MathUtils.abs(child2.height - child1.height);
    maxBalance = MathUtils.max(maxBalance, balance);
  }

  return maxBalance;
}
 
开发者ID:pianoman373,项目名称:Point-Engine,代码行数:20,代码来源:DynamicTree.java

示例6: postSolve

import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
  if (m_broke) {
    // The body already broke.
    return;
  }

  // Should the body break?
  int count = contact.getManifold().pointCount;

  float maxImpulse = 0.0f;
  for (int i = 0; i < count; ++i) {
    maxImpulse = MathUtils.max(maxImpulse, impulse.normalImpulses[i]);
  }

  if (maxImpulse > 40.0f) {
    // Flag the body for breaking.
    m_break = true;
  }
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:21,代码来源:Breakable.java

示例7: computeHeight

import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
private final int computeHeight(int node) {
  assert (0 <= node && node < m_nodeCapacity);

  if (m_child1[node] == NULL_NODE) {
    return 0;
  }
  int height1 = computeHeight(m_child1[node]);
  int height2 = computeHeight(m_child2[node]);
  return 1 + MathUtils.max(height1, height2);
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:11,代码来源:DynamicTreeFlatNodes.java

示例8: validateMetrics

import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
private void validateMetrics(int node) {
  if (node == NULL_NODE) {
    return;
  }

  int child1 = m_child1[node];
  int child2 = m_child2[node];

  if (child1 == NULL_NODE) {
    assert (child1 == NULL_NODE);
    assert (child2 == NULL_NODE);
    assert (m_height[node] == 0);
    return;
  }

  assert (child1 != NULL_NODE && 0 <= child1 && child1 < m_nodeCapacity);
  assert (child2 != child1 && 0 <= child2 && child2 < m_nodeCapacity);

  int height1 = m_height[child1];
  int height2 = m_height[child2];
  int height;
  height = 1 + MathUtils.max(height1, height2);
  assert (m_height[node] == height);

  AABB aabb = new AABB();
  aabb.combine(m_aabb[child1], m_aabb[child2]);

  assert (aabb.lowerBound.equals(m_aabb[node].lowerBound));
  assert (aabb.upperBound.equals(m_aabb[node].upperBound));

  validateMetrics(child1);
  validateMetrics(child2);
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:34,代码来源:DynamicTreeFlatNodes.java

示例9: computeHeight

import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
private final int computeHeight(DynamicTreeNode node) {
  assert (0 <= node.id && node.id < m_nodeCapacity);

  if (node.child1 == null) {
    return 0;
  }
  int height1 = computeHeight(node.child1);
  int height2 = computeHeight(node.child2);
  return 1 + MathUtils.max(height1, height2);
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:11,代码来源:DynamicTree.java

示例10: computeHeight

import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
private final int computeHeight(DynamicTreeNode argNode) {
	if (argNode == null) {
		return 0;
	}
	
	assert (argNode != null);
	int height1 = computeHeight(argNode.child1);
	int height2 = computeHeight(argNode.child2);
	return 1 + MathUtils.max(height1, height2);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:11,代码来源:DynamicTree.java

示例11: runFastMaxTest

import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
public void runFastMaxTest(float argRandom){
	float a = 0;
	for(int i=0; i<INNER_ITERS; i++){
		a = MathUtils.max(argRandom, MathUtils.randomFloat(-100, 100));
	}
	aStore += a;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:MathPerf.java

示例12: computeHeight

import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
private final int computeHeight(DynamicTreeNode node) {
  assert (0 <= node.id && node.id < m_nodeCapacity);

  if (node.isLeaf()) {
    return 0;
  }
  int height1 = computeHeight(node.child1);
  int height2 = computeHeight(node.child2);
  return 1 + MathUtils.max(height1, height2);
}
 
开发者ID:pianoman373,项目名称:Point-Engine,代码行数:11,代码来源:DynamicTree.java

示例13: keyPressed

import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
@Override
public void keyPressed(char argKeyChar, int argKeyCode) {
  switch (argKeyChar) {
    case 'a':
      m_spring1.enableMotor(true);
      m_spring1.setMotorSpeed(m_speed);
      break;

    case 's':
      m_spring1.enableMotor(true);
      m_spring1.setMotorSpeed(0.0f);
      break;

    case 'd':
      m_spring1.enableMotor(true);
      m_spring1.setMotorSpeed(-m_speed);
      break;

    case 'q':
      m_hz = MathUtils.max(0.0f, m_hz - 1.0f);
      m_spring1.setSpringFrequencyHz(m_hz);
      m_spring2.setSpringFrequencyHz(m_hz);
      break;

    case 'e':
      m_hz += 1.0f;
      m_spring1.setSpringFrequencyHz(m_hz);
      m_spring2.setSpringFrequencyHz(m_hz);
      break;
  }
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:32,代码来源:Car.java

示例14: removeLeaf

import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
private final void removeLeaf(int leaf) {
  if (leaf == m_root) {
    m_root = NULL_NODE;
    return;
  }

  int parent = m_parent[leaf];
  int grandParent = m_parent[parent];
  int parentChild1 = m_child1[parent];
  int parentChild2 = m_child2[parent];
  int sibling;
  if (parentChild1 == leaf) {
    sibling = parentChild2;
  } else {
    sibling = parentChild1;
  }

  if (grandParent != NULL_NODE) {
    // Destroy parent and connect sibling to grandParent.
    if (m_child1[grandParent] == parent) {
      m_child1[grandParent] = sibling;
    } else {
      m_child2[grandParent] = sibling;
    }
    m_parent[sibling] = grandParent;
    freeNode(parent);

    // Adjust ancestor bounds.
    int index = grandParent;
    while (index != NULL_NODE) {
      index = balance(index);

      int child1 = m_child1[index];
      int child2 = m_child2[index];

      m_aabb[index].combine(m_aabb[child1], m_aabb[child2]);
      m_height[index] = 1 + MathUtils.max(m_height[child1], m_height[child2]);

      index = m_parent[index];
    }
  } else {
    m_root = sibling;
    m_parent[sibling] = NULL_NODE;
    freeNode(parent);
  }

  // validate();
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:49,代码来源:DynamicTreeFlatNodes.java

示例15: record

import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
public void record(float value) {
  longAvg = longAvg * (1 - LONG_FRACTION) + value * LONG_FRACTION;
  shortAvg = shortAvg * (1 - SHORT_FRACTION) + value * SHORT_FRACTION;
  min = MathUtils.min(value, min);
  max = MathUtils.max(value, max);
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:7,代码来源:Profile.java


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