Example #1
0
		/// <summary>Checks whether a vector is a null vector.</summary>
		/// <returns>A boolean indicating whether the vector is a null vector.</returns>
		public static bool IsNullVector(Vector2f vector) {
			return vector.X == 0.0f & vector.Y == 0.0f;
		}
Example #2
0
		/// <summary>Scales a vector by a specified factor.</summary>
		/// <param name="vector">The vector.</param>
		/// <param name="factor">The factor.</param>
		/// <returns>The scaled vector.</returns>
		public static Vector2f Scale(Vector2f vector, Vector2f factor) {
			float x = vector.X * factor.X;
			float y = vector.Y * factor.Y;
			return new Vector2f(x, y);
		}
Example #3
0
		/// <summary>Rotates a vector by a specified angle.</summary>
		/// <param name="vector">The vector.</param>
		/// <param name="cosineOfAngle">The cosine of the angle.</param>
		/// <param name="sineOfAngle">The sine of the angle.</param>
		/// <returns>The rotated vector.</returns>
		public static Vector2f Rotate(Vector2f vector, float cosineOfAngle, float sineOfAngle) {
			float x = cosineOfAngle * vector.X - sineOfAngle * vector.Y;
			float y = sineOfAngle * vector.X + cosineOfAngle * vector.Y;
			return new Vector2f(x, y);

		}
Example #4
0
 /// <summary>Scales the vector by a specified factor.</summary>
 /// <param name="factor">The factor.</param>
 public void Scale(Vector2f factor)
 {
     this.X *= factor.X;
     this.Y *= factor.Y;
 }
Example #5
0
		/// <summary>Translates a vector by a specified offset.</summary>
		/// <param name="vector">The vector.</param>
		/// <param name="offset">The offset.</param>
		/// <returns>The translated vector.</returns>
		public static Vector2f Translate(Vector2f vector, Vector2f offset) {
			float x = vector.X + offset.X;
			float y = vector.Y + offset.Y;
			return new Vector2f(x, y);
		}
Example #6
0
        /// <summary>Returns a normalized vector based on a 2D vector in the XZ plane and an additional Y-coordinate.</summary>
        /// <param name="Vector">The vector in the XZ-plane. The X and Y components in Vector represent the X- and Z-coordinates, respectively.</param>
        /// <param name="Y">The Y-coordinate.</param>
        internal static Vector3f GetVector3f(Vector2f Vector, float Y)
        {
            float t = 1.0f / (float)System.Math.Sqrt(Vector.X * Vector.X + Vector.Y * Vector.Y + Y * Y);

            return(new Vector3f(t * Vector.X, t * Y, t * Vector.Y));
        }
Example #7
0
			internal Vertex(double X, double Y, double Z) {
				this.Coordinates = new Vector3D(X, Y, Z);
				this.TextureCoordinates = new Vector2f(0.0f, 0.0f);
			}
Example #8
0
		/// <summary>Translates the vector by a specified offset.</summary>
		/// <param name="offset">The offset.</param>
		public void Translate(Vector2f offset) {
			this.X += offset.X;
			this.Y += offset.Y;
		}
Example #9
0
		/// <summary>Scales the vector by a specified factor.</summary>
		/// <param name="factor">The factor.</param>
		public void Scale(Vector2f factor) {
			this.X *= factor.X;
			this.Y *= factor.Y;
		}
Example #10
0
 /// <summary>Gets the square of the euclidean norm of the specified vector.</summary>
 /// <param name="vector">The vector.</param>
 /// <returns>The square of the euclidean norm.</returns>
 public static double NormSquared(Vector2f vector)
 {
     return(vector.X * vector.X + vector.Y * vector.Y);
 }
Example #11
0
 /// <summary>Creates a clone of a vector</summary>
 /// <param name="v">The vector to clone</param>
 public Vector2f(Vector2f v)
 {
     this.X = v.X;
     this.Y = v.Y;
 }
Example #12
0
 /// <summary>Gets the euclidean norm of the specified vector.</summary>
 /// <param name="vector">The vector.</param>
 /// <returns>The euclidean norm.</returns>
 public static double Norm(Vector2f vector)
 {
     return(System.Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y));
 }
Example #13
0
 /// <summary>Checks whether a vector is a null vector.</summary>
 /// <returns>A boolean indicating whether the vector is a null vector.</returns>
 public static bool IsNullVector(Vector2f vector)
 {
     return(vector.X == 0.0 & vector.Y == 0.0);
 }
Example #14
0
        // --- static functions ---

        /// <summary>Gives the dot product of two vectors.</summary>
        /// <param name="a">The first vector.</param>
        /// <param name="b">The second vector.</param>
        /// <returns>The dot product of the two vectors.</returns>
        public static double Dot(Vector2f a, Vector2f b)
        {
            return(a.X * b.X + a.Y * b.Y);
        }
Example #15
0
		/// <summary>Gets the euclidean norm of the specified vector.</summary>
		/// <param name="vector">The vector.</param>
		/// <returns>The euclidean norm.</returns>
		public static float Norm(Vector2f vector) {
			return (float)System.Math.Sqrt(vector.X * vector.X + vector.Y * vector.Y);
		}
Example #16
0
		/// <summary>Rotates the vector by the specified angle.</summary>
		/// <param name="cosineOfAngle">The cosine of the angle.</param>
		/// <param name="sineOfAngle">The sine of the angle.</param>
		public void Rotate(float cosineOfAngle, float sineOfAngle) {
			float x = cosineOfAngle * this.X - sineOfAngle * this.Y;
			float y = sineOfAngle * this.X + cosineOfAngle * this.Y;
			this = new Vector2f(x, y);
		}
Example #17
0
		/// <summary>Gets the square of the euclidean norm of the specified vector.</summary>
		/// <param name="vector">The vector.</param>
		/// <returns>The square of the euclidean norm.</returns>
		public static float NormSquared(Vector2f vector) {
			return vector.X * vector.X + vector.Y * vector.Y;
		}
Example #18
0
		// --- static functions ---

		/// <summary>Gives the dot product of two vectors.</summary>
		/// <param name="a">The first vector.</param>
		/// <param name="b">The second vector.</param>
		/// <returns>The dot product of the two vectors.</returns>
		public static float Dot(Vector2f a, Vector2f b) {
			return a.X * b.X + a.Y * b.Y;
		}
Example #19
0
		/// <summary>Returns a normalized vector based on a 2D vector in the XZ plane and an additional Y-coordinate.</summary>
		/// <param name="Vector">The vector in the XZ-plane. The X and Y components in Vector represent the X- and Z-coordinates, respectively.</param>
		/// <param name="Y">The Y-coordinate.</param>
		internal static Vector3f GetVector3f(Vector2f Vector, float Y) {
			float t = 1.0f / (float)System.Math.Sqrt(Vector.X * Vector.X + Vector.Y * Vector.Y + Y * Y);
			return new Vector3f(t * Vector.X, t * Y, t * Vector.Y);
		}
Example #20
0
		/// <summary>Normalizes a vector.</summary>
		/// <param name="vector">The vector.</param>
		/// <returns>The normalized vector.</returns>
		/// <exception cref="System.DivideByZeroException">Raised when the vector is a null vector.</exception>
		public static Vector2f Normalize(Vector2f vector) {
			float norm = vector.X * vector.X + vector.Y * vector.Y;
			if (norm == 0.0f) {
				throw new DivideByZeroException();
			} else {
				float factor = 1.0f / (float)System.Math.Sqrt(norm);
				return new Vector2f(vector.X * factor, vector.Y * factor);
			}
		}
Example #21
0
			internal Vertex(Vector3D Coordinates, Vector2f TextureCoordinates) {
				this.Coordinates = Coordinates;
				this.TextureCoordinates = TextureCoordinates;
			}
Example #22
0
 /// <summary>Translates the vector by a specified offset.</summary>
 /// <param name="offset">The offset.</param>
 public void Translate(Vector2f offset)
 {
     this.X += offset.X;
     this.Y += offset.Y;
 }