/** Creates an affine transform from the supplied scale, rotation and translation. */ public AffineTransform (float scaleX, float scaleY, float angle, float tx, float ty) { float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle); this.m00 = cosa * scaleX; this.m01 = sina * scaleY; this.m10 = -sina * scaleX; this.m11 = cosa * scaleY; this.tx = tx; this.ty = ty; }
@Override public Transform rotate(float angle) { float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle); return multiply(cosa, sina, -sina, cosa, 0, 0, this, this); }
/** * Sets this quaternion to the rotation described by the given angle and normalized * axis. * * @return a reference to this quaternion, for chaining. */ public Quaternion fromAngleAxis (float angle, float x, float y, float z) { float sina = FloatMath.sin(angle / 2f); return set(x*sina, y*sina, z*sina, FloatMath.cos(angle / 2f)); }
@Override // from Transform public AffineTransform rotate (float angle) { float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle); return Transforms.multiply(this, cosa, sina, -sina, cosa, 0, 0, this); }
/** * Transforms a vector as specified, storing the result in the vector provided. * @return a reference to the result vector, for chaining. */ public static Vector transform (float x, float y, float sx, float sy, float rotation, Vector result) { return transform(x, y, sx, sy, FloatMath.sin(rotation), FloatMath.cos(rotation), result); }
/** * Transforms a vector as specified, storing the result in the vector provided. * @return a reference to the result vector, for chaining. */ public static Vector transform (float x, float y, float sx, float sy, float rotation, Vector result) { return transform(x, y, sx, sy, FloatMath.sin(rotation), FloatMath.cos(rotation), result); }
/** * Sets this to a rotation matrix. * * @return a reference to this matrix, for chaining. */ public Matrix3 setToRotation (float angle) { float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle); return set(cosa, -sina, 0f, sina, cosa, 0f, 0f, 0f, 1f); }
@Override // from Transform public AffineTransform setRotation (float angle) { // extract the scale, then reapply rotation and scale together float sx = scaleX(), sy = scaleY(); float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle); m00 = cosa * sx; m01 = sina * sx; m10 = -sina * sy; m11 = cosa * sy; return this; }
/** * Sets this vector's angle, preserving its magnitude. * @return a reference to this vector, for chaining. */ public Vector setAngle (float angle) { float l = length(); return set(l * FloatMath.cos(angle), l * FloatMath.sin(angle)); }
/** * Sets this vector's angle, preserving its magnitude. * @return a reference to this vector, for chaining. */ public Vector setAngle (float angle) { float l = length(); return set(l * FloatMath.cos(angle), l * FloatMath.sin(angle)); }
@Override // from interface IVector public Vector rotate (float angle, Vector result) { float x = x(), y = y(); float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle); return result.set(x*cosa - y*sina, x*sina + y*cosa); }
@Override // from interface IVector public Vector rotate (float angle, Vector result) { float x = x(), y = y(); float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle); return result.set(x*cosa - y*sina, x*sina + y*cosa); }
protected void paintClipped (Surface surf) { surf.setFillColor(0xFF99CCFF).fillRect(0, 0, 100, 100); surf.translate(FloatMath.sin(elapsed) * 50, FloatMath.cos(elapsed) * 50 + 25); surf.draw(saustex, 0, 0); } }, 390, 30);
public void render (Surface surf) { surf.setFillColor(0xFF99CCFF); surf.fillRect(0, 0, 100, 100); surf.translate(FloatMath.sin(elapsed) * 50, FloatMath.cos(elapsed) * 50 + 25); surf.drawImage(sausage, 0, 0); } }), 260, 160);
@Override // from interface IVector public Vector rotateScaleAndAdd (float angle, float scale, IVector add, Vector result) { float x = x(), y = y(); float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle); return result.set((x*cosa - y*sina)*scale + add.x(), (x*sina + y*cosa)*scale + add.y()); }
@Override public Transform transform() { if (isSet(Flag.XFDIRTY)) { float sina = FloatMath.sin(rotation), cosa = FloatMath.cos(rotation); float m00 = cosa * scaleX, m01 = sina * scaleY; float m10 = -sina * scaleX, m11 = cosa * scaleY; float tx = transform.tx(), ty = transform.ty(); transform.setTransform(m00, m01, m10, m11, tx, ty); setFlag(Flag.XFDIRTY, false); } return transform; }
@Override // from interface IVector public Vector rotateAndAdd (float angle, IVector add, Vector result) { float x = x(), y = y(); float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle); return result.set(x*cosa - y*sina + add.x(), x*sina + y*cosa + add.y()); }
@Override public Transform setRotation(float angle) { // extract the scale, then reapply rotation and scale together float sx = scaleX(), sy = scaleY(); float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle); setM00(cosa * sx); setM01(sina * sx); setM10(-sina * sy); setM11(cosa * sy); return this; }
private HtmlInternalTransform(Transform other) { this(); float scaleX = other.scaleX(), scaleY = other.scaleY(), angle = other.rotation(); float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle); setTransform(cosa * scaleX, sina * scaleY, -sina * scaleX, cosa * scaleY, other.tx(), other.ty()); }
public void draw(Canvas canvas) { canvas.setFillColor(0xFFCCCCCC).fillRect(0, 0, 50, 50); canvas.setFillColor(0xFFCCCCCC).fillRect(50, 50, 50, 50); TextLayout capF = graphics().layoutText("F", new TextFormat().withFont(F_FONT)); float theta = -FloatMath.PI/4, tsin = FloatMath.sin(theta), tcos = FloatMath.cos(theta); canvas.setFillColor(0xFF000000).fillText(capF, 0, 0); canvas.transform(tcos, -tsin, tsin, tcos, 50, 50); canvas.setFillColor(0xFF000000).fillText(capF, 0, 0); } });