public Vector RotateScaleAndAdd(float angle, float scale, Vector add) { float sina = FloatMath.Sin(angle), cosa = FloatMath.Cos(angle); return(new Vector((x * cosa - y * sina) * scale + add.x, (x * sina + y * cosa) * scale + add.y)); }
/** * Inverse transforms a point as specified, storing the result in the point provided. * @return a reference to the result vector, for chaining. */ public static Vector InverseTransform(float x, float y, float sx, float sy, float rotation) { float sinnega = FloatMath.Sin(-rotation), cosnega = FloatMath.Cos(-rotation); float nx = (x * cosnega - y * sinnega); // unrotate float ny = (x * sinnega + y * cosnega); return(new Vector(nx / sx, ny / sy)); // unscale }
/** 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; }
/** Inverse transforms a point as specified, storing the result in the point provided. * @return a reference to the result point, for chaining. */ public static Point InverseTransform(float x, float y, float sx, float sy, float rotation, float tx, float ty) { x -= tx; y -= ty; // untranslate float sinnega = FloatMath.Sin(-rotation), cosnega = FloatMath.Cos(-rotation); float nx = (x * cosnega - y * sinnega); // unrotate float ny = (x * sinnega + y * cosnega); return(new Point(nx / sx, ny / sy)); // unscale }
public Transform Rotate(float angle) { float otx = this.Tx, oty = this.Ty; if (otx != 0 || oty != 0) { float sina = FloatMath.Sin(angle); float cosa = FloatMath.Cos(angle); this.Tx = otx * cosa - oty * sina; this.Ty = otx * sina + oty * cosa; } this.Rotation += angle; return(this); }
public Transform PreConcatenate(Transform other) { if (this.Generality < other.Generality) { return(other.Concatenate(this)); } float sina = FloatMath.Sin(other.Rotation), cosa = FloatMath.Cos(other.Rotation); float ntx = (Tx * cosa - Ty * sina) * other.ScaleX + other.Tx; float nty = (Tx * sina + Ty * cosa) * other.ScaleY + other.Ty; float nrotation = MathUtil.NormalizeAngle(other.Rotation + this.Rotation); float nscaleX = other.ScaleX * this.ScaleX; float nscaleY = other.ScaleY * this.ScaleY; return(new NonUniformTransform(nscaleX, nscaleY, nrotation, ntx, nty)); }
/** * Transforms a vector as specified. */ public static Vector Transform(float x, float y, float sx, float sy, float rotation) { return(Transform(x, y, sx, sy, FloatMath.Sin(rotation), FloatMath.Cos(rotation))); }
public Transform Rotate(float angle) { float sina = FloatMath.Sin(angle), cosa = FloatMath.Cos(angle); return(Transforms.Multiply(cosa, sina, -sina, cosa, 0, 0, this, this)); }
/** Transforms a point as specified, storing the result in the point provided. * @return a reference to the result point, for chaining. */ public static Point Transform(float x, float y, float sx, float sy, float rotation, float tx, float ty) { return(Transform(x, y, sx, sy, FloatMath.Sin(rotation), FloatMath.Cos(rotation), tx, ty)); }
public Vector Rotate(float angle) { float sina = FloatMath.Sin(angle), cosa = FloatMath.Cos(angle); return(new Vector(x * cosa - y * sina, x * sina + y * cosa)); }
public Point Rotate(float angle) { float sina = FloatMath.Sin(angle), cosa = FloatMath.Cos(angle); return(new Point(x * cosa - y * sina, x * sina + y * cosa)); }