public FPoint RotateAround(FPoint anchor, float radians) { var cos = FloatMath.Cos(radians); var sin = FloatMath.Sin(radians); return(new FPoint(anchor.X + (X - anchor.X) * cos - (Y - anchor.Y) * sin, anchor.Y + (X - anchor.X) * sin + (Y - anchor.Y) * cos)); }
public static Vector2 RotateDeg(this Vector2 vector2, float degree) { var cos = FloatMath.Cos(FloatMath.DegreesToRadians * degree); var sin = FloatMath.Sin(FloatMath.DegreesToRadians * degree); return(new Vector2(vector2.X * cos - vector2.Y * sin, vector2.X * sin + vector2.Y * cos)); }
public FPoint Rotate(float radians) { var cos = FloatMath.Cos(radians); var sin = FloatMath.Sin(radians); return(new FPoint(X * cos - Y * sin, X * sin + Y * cos)); }
public static Vector2 RotateAround(this Vector2 vector2, FPoint anchor, float radians) { var cos = FloatMath.Cos(radians); var sin = FloatMath.Sin(radians); return(new Vector2(anchor.X + (vector2.X - anchor.X) * cos - (vector2.Y - anchor.Y) * sin, anchor.Y + (vector2.X - anchor.X) * sin + (vector2.Y - anchor.Y) * cos)); }
public static Vector2 Rotate(this Vector2 vector2, float radians) { var cos = FloatMath.Cos(radians); var sin = FloatMath.Sin(radians); return(new Vector2(vector2.X * cos - vector2.Y * sin, vector2.X * sin + vector2.Y * cos)); }
public static FPoint GetPointOnEllipse(float cx, float cy, float rx, float ry, float angle) { var t = GetEllipseTheta(angle, rx, ry); var x = FloatMath.Cos(t) * rx; var y = FloatMath.Sin(t) * ry; return(new FPoint(x + cx, y + cy)); }
public static Vector2 RotateWithLength(this Vector2 v, float radians, float len) { var vlen = v.Length(); var cos = FloatMath.Cos(radians); var sin = FloatMath.Sin(radians); return(new Vector2(((v.X * cos - v.Y * sin) * len) / vlen, ((v.X * sin + v.Y * cos) * len) / vlen)); }
public Flare(int nRays, float radius) : base(0, 0, 0, 0) { // FIXME // Texture is incorrectly created every time we need // to show the effect, it must be refactored var gradient = new[] { Android.Graphics.Color.Argb(0xFF, 0xFF, 0xFF, 0xFF), Android.Graphics.Color.Argb(0x00, 0xFF, 0xFF, 0xFF) }; _texture = new Gradient(gradient); _nRays = nRays; Angle = 45; AngularSpeed = 180; _vertices = ByteBuffer.AllocateDirect((nRays * 2 + 1) * 4 * (sizeof(float))).Order(ByteOrder.NativeOrder()).AsFloatBuffer(); _indices = ByteBuffer.AllocateDirect(nRays * 3 * sizeof(short)).Order(ByteOrder.NativeOrder()).AsShortBuffer(); var v = new float[4]; v[0] = 0; v[1] = 0; v[2] = 0.25f; v[3] = 0; _vertices.Put(v); v[2] = 0.75f; v[3] = 0; for (var i = 0; i < nRays; i++) { var a = i * 3.1415926f * 2 / nRays; v[0] = FloatMath.Cos(a) * radius; v[1] = FloatMath.Sin(a) * radius; _vertices.Put(v); a += 3.1415926f * 2 / nRays / 2; v[0] = FloatMath.Cos(a) * radius; v[1] = FloatMath.Sin(a) * radius; _vertices.Put(v); _indices.Put(0); _indices.Put((short)(1 + i * 2)); _indices.Put((short)(2 + i * 2)); } _indices.Position(0); }
public Transformation setToRotate(float pAngle) { float angleRad = MathUtils.DegToRad(pAngle); float sin = FloatMath.Sin(angleRad); float cos = FloatMath.Cos(angleRad); this.a = cos; this.b = sin; this.c = -sin; this.d = cos; this.tx = 0; this.ty = 0; return(this); }
protected override void OnProgress(HUDScorePanel element, float progress, InputState istate) { if (progress < 0.5f) { var p = (FloatMath.Cos(progress * 2 * FloatMath.PI) + 1) / 2; element.LabelTime1.Alpha = p; element.LabelTime2.Alpha = p; } else { var p = (FloatMath.Cos(progress * 2 * FloatMath.PI) + 1) / 2; element.LabelTime1.L10NText = _txt1; element.LabelTime2.Text = _txt2; element.LabelTime1.Alpha = p; element.LabelTime2.Alpha = p; } }
protected override void OnProgress(HUDSCCMScorePanel_Won element, float progress, SAMTime gameTime, InputState istate) { if (progress < 0.5f) { var p = (FloatMath.Cos(progress * 2 * FloatMath.PI) + 1) / 2; element.LabelTimeHeader.Alpha = p; element.LabelTimeValue.Alpha = p; } else { if (!switched) { Switch(element); } var p = (FloatMath.Cos(progress * 2 * FloatMath.PI) + 1) / 2; element.LabelTimeHeader.Alpha = p; element.LabelTimeValue.Alpha = p; } }
public virtual PointF Polar(float a, float l) { X = l * FloatMath.Cos(a); Y = l * FloatMath.Sin(a); return(this); }
public override void Update() { base.Update(); _left -= Game.Elapsed; if (_left <= 0) { Kill(); } else { float p = 1 - _left / _lifespan; // 0 -> 1 switch (_type) { case STAR: case FORGE: Scale.Set(1 - p); Am = p < 0.2f ? p * 5f : (1 - p) * 1.25f; break; case KIT: case MASTERY: Am = 1 - p * p; break; case EVOKE: case HEALING: Am = p < 0.5f ? 1 : 2 - p * 2; break; case LIGHT: Am = Scale.Set(p < 0.2f ? p * 5f : (1 - p) * 1.25f).X; break; case DISCOVER: Am = 1 - p; Scale.Set((p < 0.5f ? p : 1 - p) * 2); break; case QUESTION: Scale.Set((float)(Math.Sqrt(p < 0.5f ? p : 1 - p) * 3)); break; case UP: Scale.Set((float)(Math.Sqrt(p < 0.5f ? p : 1 - p) * 2)); break; case SCREAM: Am = (float)Math.Sqrt((p < 0.5f ? p : 1 - p) * 2f); Scale.Set(p * 7); break; case BONE: case RATTLE: Am = p < 0.9f ? 1 : (1 - p) * 10; break; case ROCK: Am = p < 0.2f ? p * 5 : 1; break; case NOTE: Am = 1 - p * p; break; case WOOL: Scale.Set(1 - p); break; case CHANGE: Am = FloatMath.Sqrt((p < 0.5f ? p : 1 - p) * 2); Scale.Y = (1 + p) * 0.5f; Scale.X = Scale.Y * FloatMath.Cos(_left * 15); break; case HEART: Scale.Set(1 - p); Am = 1 - p * p; break; case BUBBLE: Am = p < 0.2f ? p * 5 : 1; break; case STEAM: case TOXIC: case PARALYSIS: case CONFUSION: case DUST: Am = p < 0.5f ? p : 1 - p; Scale.Set(1 + p * 2); break; case JET: Am = (p < 0.5f ? p : 1 - p) * 2; Scale.Set(p * 1.5f); break; case COIN: Scale.X = FloatMath.Cos(_left * 5); Rm = Gm = Bm = (Math.Abs(Scale.X) + 1) * 0.5f; Am = p < 0.9f ? 1 : (1 - p) * 10; break; } } }
public static float GetPointXOnEllipse(float cx, float cy, float rx, float ry, float angle) { var t = GetEllipseTheta(angle, rx, ry); return(cx + FloatMath.Cos(t) * rx); }