Beispiel #1
0
 /// <summary>
 /// Създава сила по даден вектор
 /// </summary>
 /// <param name="vector">Вектора по който ще бъде създадена силата</param>
 public Force(Vector vector)
     : base(vector.Value, vector.Angle)
 {
 }
Beispiel #2
0
 private static Vector ScalarMultiply(double number, Vector vector)
 {
     float x = (float)Math.Abs(number) * vector.X;
     float y = (float)Math.Abs(number) * vector.Y;
     float value = (float)Math.Sqrt(x * x + y * y);
     Vector result = new Vector(value, vector.angle);
     if (number < 0)
         return -result;
     else
         return result;
 }
Beispiel #3
0
 private static Vector Addition(Vector vector1, Vector vector2)
 {
     float x = vector1.X + vector2.X;
     float y = vector1.Y + vector2.Y;
     float value = (float)Math.Sqrt(x * x + y * y);
     float angle = (float)Math.Atan(y / (x == 0 ? 1 : x)); //using a little chat here
     Vector result = new Vector(value, angle);
     return result;
 }
Beispiel #4
0
 /// <summary>
 /// Return new normalize vector
 /// </summary>
 /// <returns>The normalized vector</returns>
 public Vector GetNormalized()
 {
     Vector result = new Vector(1, this.angle);
     return result;
 }
Beispiel #5
0
 //the oposite vector of this vector
 public static Vector operator -(Vector vector)
 {
     Vector result = new Vector(vector.Value, (float)Math.PI + vector.Angle); // 180 + angle is the opposite angle
     return result;
 }
Beispiel #6
0
 public void Tick()
 {
     speed = initalSpeed + acceleration;
     X += initalSpeed.X + 0.5f * acceleration.X;
     Y += initalSpeed.Y + 0.5f * acceleration.Y;
 }