public Rot set(float angle) { s = MathUtils.sin(angle); c = MathUtils.cos(angle); return this; }
/** * Set as a matrix representing a rotation. * * @param angle Rotation (in radians) that matrix represents. */ public final void set(final float angle) { final float c = MathUtils.cos(angle), s = MathUtils.sin(angle); ex.x = c; ey.x = -s; ex.y = s; ey.y = c; }
public final static void createRotationalTransform(float angle, Mat22 out) { final float c = MathUtils.cos(angle); final float s = MathUtils.sin(angle); out.ex.x = c; out.ey.x = -s; out.ex.y = s; out.ey.y = c; }
public final void synchronizeTransform() { // m_xf.q.set(m_sweep.a); // // // m_xf.position = m_sweep.c - Mul(m_xf.R, m_sweep.localCenter); // Rot.mulToOutUnsafe(m_xf.q, m_sweep.localCenter, m_xf.p); // m_xf.p.mulLocal(-1).addLocal(m_sweep.c); // m_xf.q.s = MathUtils.sin(m_sweep.a); m_xf.q.c = MathUtils.cos(m_sweep.a); Rot q = m_xf.q; Vec2 v = m_sweep.localCenter; m_xf.p.x = m_sweep.c.x - q.c * v.x + q.s * v.y; m_xf.p.y = m_sweep.c.y - q.s * v.x - q.c * v.y; }
public final static Mat22 createRotationalTransform(float angle) { Mat22 mat = new Mat22(); final float c = MathUtils.cos(angle); final float s = MathUtils.sin(angle); mat.ex.x = c; mat.ey.x = -s; mat.ex.y = s; mat.ey.y = c; return mat; }
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); } }
/** * Set as a matrix representing a rotation. * * @param angle Rotation (in radians) that matrix represents. */ public final void set(final float angle) { final float c = MathUtils.cos(angle), s = MathUtils.sin(angle); ex.x = c; ey.x = -s; ex.y = s; ey.y = c; }
public final static void createRotationalTransform(float angle, Mat22 out) { final float c = MathUtils.cos(angle); final float s = MathUtils.sin(angle); out.ex.x = c; out.ey.x = -s; out.ex.y = s; out.ey.y = c; }
public Rot set(float angle) { s = MathUtils.sin(angle); c = MathUtils.cos(angle); return this; }
public final void synchronizeTransform() { // m_xf.q.set(m_sweep.a); // // // m_xf.position = m_sweep.c - Mul(m_xf.R, m_sweep.localCenter); // Rot.mulToOutUnsafe(m_xf.q, m_sweep.localCenter, m_xf.p); // m_xf.p.mulLocal(-1).addLocal(m_sweep.c); // m_xf.q.s = MathUtils.sin(m_sweep.a); m_xf.q.c = MathUtils.cos(m_sweep.a); Rot q = m_xf.q; Vec2 v = m_sweep.localCenter; m_xf.p.x = m_sweep.c.x - q.c * v.x + q.s * v.y; m_xf.p.y = m_sweep.c.y - q.s * v.x - q.c * v.y; }
public final static Mat22 createRotationalTransform(float angle) { Mat22 mat = new Mat22(); final float c = MathUtils.cos(angle); final float s = MathUtils.sin(angle); mat.ex.x = c; mat.ey.x = -s; mat.ex.y = s; mat.ey.y = c; return mat; }
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); } }
@Override public void step(TestbedSettings settings) { float hz = settings.getSetting(TestbedSettings.Hz).value; if (m_go && hz > 0.0f) { m_time += 1.0f / hz; } linearOffset.x = 6.0f * MathUtils.sin(2.0f * m_time); linearOffset.y = 8.0f + 4.0f * MathUtils.sin(1.0f * m_time); float angularOffset = 4.0f * m_time; m_joint.setLinearOffset(linearOffset); m_joint.setAngularOffset(angularOffset); getDebugDraw().drawPoint(linearOffset, 4.0f, color); super.step(settings); addTextLine("Keys: (s) pause"); }
@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(); }
float s = MathUtils.sin(theta);
float s = MathUtils.sin(theta);
@Override public void drawCircle(Vec2 center, float radius, Vec2 axis, 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.glBegin(GL2.GL_LINES); gl.glVertex3f(cx, cy, 0); gl.glVertex3f(cx + axis.x * radius, cy + axis.y * radius, 0); gl.glEnd(); gl.glPopMatrix(); }
float theta = 2 * MathUtils.PI / NUM_CIRCLE_POINTS; float c = MathUtils.cos(theta); float s = MathUtils.sin(theta); float x = radius; float y = 0;
@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; } }
d.set(L * MathUtils.cos(m_angle), L * MathUtils.sin(m_angle)); point2.set(point1); point2.addLocal(d);