本文整理汇总了Java中org.jbox2d.common.MathUtils.cos方法的典型用法代码示例。如果您正苦于以下问题:Java MathUtils.cos方法的具体用法?Java MathUtils.cos怎么用?Java MathUtils.cos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jbox2d.common.MathUtils
的用法示例。
在下文中一共展示了MathUtils.cos方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: synchronizeFixtures
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
protected final void synchronizeFixtures() {
final Transform xf1 = pxf;
// xf1.position = m_sweep.c0 - Mul(xf1.R, m_sweep.localCenter);
// xf1.q.set(m_sweep.a0);
// Rot.mulToOutUnsafe(xf1.q, m_sweep.localCenter, xf1.p);
// xf1.p.mulLocal(-1).addLocal(m_sweep.c0);
// inlined:
xf1.q.s = MathUtils.sin(m_sweep.a0);
xf1.q.c = MathUtils.cos(m_sweep.a0);
xf1.p.x = m_sweep.c0.x - xf1.q.c * m_sweep.localCenter.x + xf1.q.s * m_sweep.localCenter.y;
xf1.p.y = m_sweep.c0.y - xf1.q.s * m_sweep.localCenter.x - xf1.q.c * m_sweep.localCenter.y;
// end inline
for (Fixture f = m_fixtureList; f != null; f = f.m_next) {
f.synchronize(m_world.m_contactManager.m_broadPhase, xf1, m_xf);
}
}
示例2: synchronizeTransform
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
public final void synchronizeTransform() {
// m_xf.R.set(m_sweep.a);
//
// //m_xf.position = m_sweep.c - Mul(m_xf.R, m_sweep.localCenter);
// Mat22.mulToOut(m_xf.R, m_sweep.localCenter, m_xf.position);
// m_xf.position.mulLocal(-1).addLocal(m_sweep.c);
final float c = MathUtils.cos(m_sweep.a), s = MathUtils.sin(m_sweep.a);
m_xf.R.col1.x = c;
m_xf.R.col2.x = -s;
m_xf.R.col1.y = s;
m_xf.R.col2.y = c;
m_xf.position.x = m_xf.R.col1.x * m_sweep.localCenter.x + m_xf.R.col2.x * m_sweep.localCenter.y;
m_xf.position.y = m_xf.R.col1.y * m_sweep.localCenter.x + m_xf.R.col2.y * m_sweep.localCenter.y;
m_xf.position.x *= (float) (-1);
m_xf.position.y *= (float) (-1);
m_xf.position.x += m_sweep.c.x;
m_xf.position.y += m_sweep.c.y;
}
示例3: synchronizeTransform
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
public final void synchronizeTransform() {
// m_xf.R.set(m_sweep.a);
//
// //m_xf.position = m_sweep.c - Mul(m_xf.R, m_sweep.localCenter);
// Mat22.mulToOut(m_xf.R, m_sweep.localCenter, m_xf.position);
// m_xf.position.mulLocal(-1).addLocal(m_sweep.c);
final float c = MathUtils.cos(m_sweep.a), s = MathUtils.sin(m_sweep.a);
m_xf.R.m11 = c;
m_xf.R.m21 = -s;
m_xf.R.m12 = s;
m_xf.R.m22 = c;
m_xf.position.x = m_xf.R.m11 * m_sweep.localCenter.x + m_xf.R.m21 * m_sweep.localCenter.y;
m_xf.position.y = m_xf.R.m12 * m_sweep.localCenter.x + m_xf.R.m22 * m_sweep.localCenter.y;
m_xf.position.x *= -1f;
m_xf.position.y *= -1f;
m_xf.position.x += m_sweep.c.x;
m_xf.position.y += m_sweep.c.y;
}
示例4: drawCircle
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
@Override
public void drawCircle(Vec2 center, float radius, Color3f color) {
System.err.println("drawCircle: "+center +", "+radius+", "+color);
GL2 gl = panel.getGL().getGL2();
gl.glPushMatrix();
transformViewport(gl, zero);
float theta = 2 * MathUtils.PI / NUM_CIRCLE_POINTS;
float c = MathUtils.cos(theta);
float s = MathUtils.sin(theta);
float x = radius;
float y = 0;
float cx = center.x;
float cy = center.y;
gl.glBegin(GL2.GL_LINE_LOOP);
gl.glColor4f(color.x, color.y, color.z, 1);
for (int i = 0; i < NUM_CIRCLE_POINTS; i++) {
gl.glVertex3f(x + cx, y + cy, 0);
// apply the rotation matrix
float temp = x;
x = c * x - s * y;
y = s * temp + c * y;
}
gl.glEnd();
gl.glPopMatrix();
}
示例5: drawCircle
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
@Override
public void drawCircle(Vec2 center, float radius, Color3f color) {
//GL2 gl = panel.getGL().getGL2();
gl.glPushMatrix();
transformViewport(gl, zero);
float theta = 2 * MathUtils.PI / NUM_CIRCLE_POINTS;
float c = MathUtils.cos(theta);
float s = MathUtils.sin(theta);
float x = radius;
float y = 0;
float cx = center.x;
float cy = center.y;
gl.glBegin(GL2.GL_LINE_LOOP);
gl.glColor4f(color.x, color.y, color.z, 1);
for (int i = 0; i < NUM_CIRCLE_POINTS; i++) {
gl.glVertex3f(x + cx, y + cy, 0);
// apply the rotation matrix
float temp = x;
x = c * x - s * y;
y = s * temp + c * y;
}
gl.glEnd();
gl.glPopMatrix();
}
示例6: step
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
/**
* @see org.jbox2d.testbed.framework.TestbedTest#step(org.jbox2d.testbed.framework.Testbe.settings)
*/
@Override
public void step(TestbedSettings settings) {
boolean advanceRay = settings.pause == false || settings.singleStep;
super.step(settings);
addTextLine("Press 1-5 to drop stuff");
float L = 25.0f;
Vec2 point1 = new Vec2(0.0f, 10.0f);
Vec2 d = new Vec2(L * MathUtils.cos(m_angle), -L * MathUtils.abs(MathUtils.sin(m_angle)));
Vec2 point2 = point1.add(d);
callback.m_fixture = null;
m_world.raycast(callback, point1, point2);
if (callback.m_fixture != null)
{
m_debugDraw.drawPoint(callback.m_point, 5.0f, new Color3f(0.4f, 0.9f, 0.4f));
m_debugDraw.drawSegment(point1, callback.m_point, new Color3f(0.8f, 0.8f, 0.8f));
Vec2 head = callback.m_normal.mul(.5f).addLocal(callback.m_point);
m_debugDraw.drawSegment(callback.m_point, head, new Color3f(0.9f, 0.9f, 0.4f));
}
else
{
m_debugDraw.drawSegment(point1, point2, new Color3f(0.8f, 0.8f, 0.8f));
}
if (advanceRay)
{
m_angle += 0.25f * MathUtils.PI / 180.0f;
}
}
示例7: generateCirle
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
private void generateCirle(Vec2 argCenter, float argRadius, Vec2[] argPoints, int argNumPoints){
float inc = MathUtils.TWOPI/argNumPoints;
for(int i=0; i<argNumPoints; i++){
argPoints[i].x = (argCenter.x + MathUtils.cos(i*inc)*argRadius);
argPoints[i].y = (argCenter.y + MathUtils.sin(i*inc)*argRadius);
}
}
示例8: drawParticles
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
@Override
public void drawParticles(Vec2[] centers, float radius, ParticleColor[] colors, int count) {
GL2 gl = panel.getGL().getGL2();
gl.glPushMatrix();
transformViewport(gl, zero);
float theta = 2 * MathUtils.PI / NUM_CIRCLE_POINTS;
float c = MathUtils.cos(theta);
float s = MathUtils.sin(theta);
float x = radius;
float y = 0;
for (int i = 0; i < count; i++) {
Vec2 center = centers[i];
float cx = center.x;
float cy = center.y;
gl.glBegin(GL2.GL_TRIANGLE_FAN);
if (colors == null) {
gl.glColor4f(1, 1, 1, .4f);
} else {
ParticleColor color = colors[i];
gl.glColor4b(color.r, color.g, color.b, color.a);
}
for (int j = 0; j < NUM_CIRCLE_POINTS; j++) {
gl.glVertex3f(x + cx, y + cy, 0);
float temp = x;
x = c * x - s * y;
y = s * temp + c * y;
}
gl.glEnd();
}
gl.glPopMatrix();
}
示例9: drawParticlesWireframe
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
@Override
public void drawParticlesWireframe(Vec2[] centers, float radius, ParticleColor[] colors, int count) {
GL2 gl = panel.getGL().getGL2();
gl.glPushMatrix();
transformViewport(gl, zero);
float theta = 2 * MathUtils.PI / NUM_CIRCLE_POINTS;
float c = MathUtils.cos(theta);
float s = MathUtils.sin(theta);
float x = radius;
float y = 0;
for (int i = 0; i < count; i++) {
Vec2 center = centers[i];
float cx = center.x;
float cy = center.y;
gl.glBegin(GL2.GL_LINE_LOOP);
if (colors == null) {
gl.glColor4f(1, 1, 1, 1);
} else {
ParticleColor color = colors[i];
gl.glColor4b(color.r, color.g, color.b, (byte) 127);
}
for (int j = 0; j < NUM_CIRCLE_POINTS; j++) {
gl.glVertex3f(x + cx, y + cy, 0);
float temp = x;
x = c * x - s * y;
y = s * temp + c * y;
}
gl.glEnd();
}
gl.glPopMatrix();
}
示例10: step
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
@Override
public void step(TestbedSettings settings) {
boolean advanceRay = settings.pause == false || settings.singleStep;
super.step(settings);
addTextLine("Press 1-5 to drop stuff");
float L = 25.0f;
Vec2 point1 = new Vec2(0.0f, 10.0f);
Vec2 d = new Vec2(L * MathUtils.cos(m_angle), -L * MathUtils.abs(MathUtils.sin(m_angle)));
Vec2 point2 = point1.add(d);
callback.m_fixture = null;
getWorld().raycast(callback, point1, point2);
if (callback.m_fixture != null) {
getDebugDraw().drawPoint(callback.m_point, 5.0f, new Color3f(0.4f, 0.9f, 0.4f));
getDebugDraw().drawSegment(point1, callback.m_point, new Color3f(0.8f, 0.8f, 0.8f));
Vec2 head = callback.m_normal.mul(.5f).addLocal(callback.m_point);
getDebugDraw().drawSegment(callback.m_point, head, new Color3f(0.9f, 0.9f, 0.4f));
} else {
getDebugDraw().drawSegment(point1, point2, new Color3f(0.8f, 0.8f, 0.8f));
}
if (advanceRay) {
m_angle += 0.25f * MathUtils.PI / 180.0f;
}
}
示例11: drawParticles
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
@Override
public void drawParticles(Vec2[] centers, float radius, ParticleColor[] colors, int count) {
// GL2 gl = panel.getGL().getGL2();
gl.glPushMatrix();
transformViewport(gl, zero);
float theta = 2 * MathUtils.PI / NUM_CIRCLE_POINTS;
float c = MathUtils.cos(theta);
float s = MathUtils.sin(theta);
float x = radius;
float y = 0;
for (int i = 0; i < count; i++) {
Vec2 center = centers[i];
float cx = center.x;
float cy = center.y;
gl.glBegin(GL2.GL_TRIANGLE_FAN);
if (colors == null) {
gl.glColor4f(1, 1, 1, .4f);
} else {
ParticleColor color = colors[i];
gl.glColor4b(color.r, color.g, color.b, color.a);
}
for (int j = 0; j < NUM_CIRCLE_POINTS; j++) {
gl.glVertex3f(x + cx, y + cy, 0);
float temp = x;
x = c * x - s * y;
y = s * temp + c * y;
}
gl.glEnd();
}
gl.glPopMatrix();
}
示例12: drawParticlesWireframe
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
@Override
public void drawParticlesWireframe(Vec2[] centers, float radius, ParticleColor[] colors, int count) {
// GL2 gl = panel.getGL().getGL2();
gl.glPushMatrix();
transformViewport(gl, zero);
float theta = 2 * MathUtils.PI / NUM_CIRCLE_POINTS;
float c = MathUtils.cos(theta);
float s = MathUtils.sin(theta);
float x = radius;
float y = 0;
for (int i = 0; i < count; i++) {
Vec2 center = centers[i];
float cx = center.x;
float cy = center.y;
gl.glBegin(GL2.GL_LINE_LOOP);
if (colors == null) {
gl.glColor4f(1, 1, 1, 1);
} else {
ParticleColor color = colors[i];
gl.glColor4b(color.r, color.g, color.b, (byte) 127);
}
for (int j = 0; j < NUM_CIRCLE_POINTS; j++) {
gl.glVertex3f(x + cx, y + cy, 0);
float temp = x;
x = c * x - s * y;
y = s * temp + c * y;
}
gl.glEnd();
}
gl.glPopMatrix();
}
示例13: generateCirle
import org.jbox2d.common.MathUtils; //导入方法依赖的package包/类
private void generateCirle(Vec2 argCenter, float argRadius, Vec2[] argPoints, int argNumPoints) {
float inc = MathUtils.TWOPI / argNumPoints;
for (int i = 0; i < argNumPoints; i++) {
argPoints[i].x = (argCenter.x + MathUtils.cos(i * inc) * argRadius);
argPoints[i].y = (argCenter.y + MathUtils.sin(i * inc) * argRadius);
}
}