예제 #1
0
        public Vector Rotate(double angle, Vector origin)
        {
            var delta = this - origin;

              var dx = Math.Cos(angle) * delta.X - Math.Sin(angle) * delta.Y;
              var dy = Math.Sin(angle) * delta.X + Math.Cos(angle) * delta.Y;

              return new Vector(origin.X + dx, origin.Y + dy);
        }
예제 #2
0
        // p = start position
        // v = start velocity
        // a = acceleration
        public static IEnumerable<Vector> Trace(Vector p, Vector v, Vector a, float mass = 1)
        {
            yield return p;

              int dt = 10;

              while (true)
              {
            Vector dv = a * (dt / mass);
            p = p + v * dt;
            p = p + dv * (dt / 2);
            v = v + dv;
            yield return p;
              }
        }
예제 #3
0
 public static LineSegment FromVectors(Vector v1, Vector v2)
 {
     return new LineSegment(v1, v2);
 }
예제 #4
0
 public LineSegment(Vector v1, Vector v2)
     : this()
 {
     this.V1 = v1;
       this.V2 = v2;
 }
예제 #5
0
        private double computeOptimalAngle(Vector v)
        {
            var hw = Settings.Default.tankWidth / 2;
              var vl = v - Vector.FromCart(hw, 0);
              var vr = v + Vector.FromCart(hw, 0);

              var dx = vr.X - v.X;
              var dy = Landscape.fakeLandscape[Convert.ToInt32(vr.X)] - v.Y;
              var alpha = Math.Atan2(dy, dx);

              dx = v.X - vl.X;
              dy = v.Y - Landscape.fakeLandscape[Convert.ToInt32(vl.X)];
              var beta = Math.Atan2(dy, dx);

              return (alpha + beta) / 2;
        }