/// <summary> /// Transforms the 2-D vector normal by a given matrix. /// </summary> /// <param name="vector">Array of source TGCVector2.</param> /// <param name="sourceMatrix">Source TGCMatrix.</param> /// <returns>Array of TGCVector2 that contain the results of this method.</returns> public static TGCVector2[] TransformNormal(TGCVector2[] vector, TGCMatrix sourceMatrix) { TGCVector2[] ret = new TGCVector2[vector.Length]; for (int i = 0; i < vector.Length; i++) { ret[i] = new TGCVector2(Vector2.TransformNormal(vector[i].ToVector2(), sourceMatrix.ToMatrix())); } return(ret); }
/// <summary> /// Transforms the 2-D vector normal by a given matrix. /// </summary> /// <param name="source">Source TGCVector2.</param> /// <param name="sourceMatrix">Source TGCMatrix.</param> /// <returns>A TGCVector2 that contains the results of this method.</returns> public static TGCVector2 TransformNormal(TGCVector2 source, TGCMatrix sourceMatrix) { return(new TGCVector2(Vector2.TransformNormal(source.ToVector2(), sourceMatrix.ToMatrix()))); }
/// <summary> /// Subtracts two 2-D vectors. /// </summary> /// <param name="left">Source TGCVector2 to the left of the subtraction operator.</param> /// <param name="right">Source TGCVector2 to the right of the subtraction operator.</param> /// <returns>A TGCVector2 that is the result of the operation.</returns> public static TGCVector2 Subtract(TGCVector2 left, TGCVector2 right) { return(new TGCVector2(Vector2.Subtract(left.ToVector2(), right.ToVector2()))); }
/// <summary> /// Subtracts two 2-D vectors. /// </summary> /// <param name="source">Source TGCVector2 to subtract from the current TGCVector2 instance.</param> public void Subtract(TGCVector2 source) { this.dxVector2.Subtract(source.ToVector2()); }
/// <summary> /// Scales a 2-D vector. /// </summary> /// <param name="source">Source TGCVector2.</param> /// <param name="scalingFactor">Scaling value.</param> /// <returns>A TGCVector2 that is the scaled vector.</returns> public static TGCVector2 Scale(TGCVector2 source, float scalingFactor) { return(new TGCVector2(Vector2.Scale(source.ToVector2(), scalingFactor))); }
/// <summary> /// Builds a 2-D transformation matrix in the xy plane. /// </summary> /// <param name="scalingCenter">A TGCVector2 structure that is a point identifying the scaling center.</param> /// <param name="scalingRotation">Scaling rotation factor. Use a zero value to specify no rotation.</param> /// <param name="scaling">A TGCVector2 structure that is a point identifying the scale. Use TGCVector2.Empty to specify no scaling.</param> /// <param name="rotationCenter">A TGCVector2 structure that is a point identifying the rotation center.</param> /// <param name="rotation">Angle of rotation, in radians.</param> /// <param name="translation">A TGCVector2 structure that identifies the translation. Use TGCVector2.Empty to specify no translation.</param> /// <returns>A TGCMatrix that contains the transformation matrix.</returns> public static TGCMatrix Transformation2D(TGCVector2 scalingCenter, float scalingRotation, TGCVector2 scaling, TGCVector2 rotationCenter, float rotation, TGCVector2 translation) { return(new TGCMatrix(Matrix.Transformation2D(scalingCenter, scalingRotation, scaling, rotationCenter, rotation, translation))); }
/// <summary> /// Adds two 2-D vectors. /// </summary> /// <param name="left">Source TGCVector2.</param> /// <param name="right">Source TGCVector2.</param> /// <returns>Sum of the two source TGCVector2.</returns> public static TGCVector2 Add(TGCVector2 left, TGCVector2 right) { return(new TGCVector2(Vector2.Add(left.ToVector2(), right.ToVector2()))); }
/// <summary> /// Convierte un TGCVector2 a un float[2] /// </summary> public static float[] Vector2ToFloat2Array(TGCVector2 v) { return(new[] { v.X, v.Y }); }
/// <summary> /// Returns a 2-D vector that is made up of the smallest components of two 2-D vectors. /// </summary> /// <param name="source">Source TGCVector2.</param> public void Minimize(TGCVector2 source) { this.dxVector2.Minimize(source.ToVector2()); }
/// <summary> /// Performs a linear interpolation between two 2-D vectors. /// </summary> /// <param name="left">Source TGCVector2.</param> /// <param name="right">Source TGCVector2.</param> /// <param name="interpolater">Parameter that linearly interpolates between the vectors.</param> /// <returns></returns> public static TGCVector2 Lerp(TGCVector2 left, TGCVector2 right, float interpolater) { return(new TGCVector2(Vector2.Lerp(left.ToVector2(), right.ToVector2(), interpolater))); }
/// <summary> /// Returns the square of the length of a 2-D vector. /// </summary> /// <param name="source">Source TGCVector2.</param> /// <returns>Vector's squared length.</returns> public static float LengthSq(TGCVector2 source) { return(Vector2.LengthSq(source.ToVector2())); }
/// <summary> /// Performs a Hermite spline interpolation using specified 2-D vectors. /// </summary> /// <param name="position">Source TGCVector2 that is a position vector.</param> /// <param name="tangent">Source TGCVector2 that is a tangent vector.</param> /// <param name="position2">Source TGCVector2 that is a position vector.</param> /// <param name="tangent2">Source TGCVector2 that is a tangent vector.</param> /// <param name="weightingFactor">Weighting factor.</param> /// <returns>A TGCVector2 that is the result of the Hermite spline interpolation.</returns> public static TGCVector2 Hermite(TGCVector2 position, TGCVector2 tangent, TGCVector2 position2, TGCVector2 tangent2, float weightingFactor) { return(new TGCVector2(Vector2.Hermite(position.ToVector2(), tangent.ToVector2(), position2.ToVector2(), tangent2.ToVector2(), weightingFactor))); }
/// <summary> /// Determines the dot product of two 2-D vectors. /// </summary> /// <param name="left">Source TGCVector2.</param> /// <param name="right">Source TGCVector2.</param> /// <returns>Dot product.</returns> public static float Dot(TGCVector2 left, TGCVector2 right) { return(Vector2.Dot(left.ToVector2(), right.ToVector2())); }
/// <summary> /// Performs a Catmull-Rom interpolation using specified 2-D vectors. /// </summary> /// <param name="position1">Source TGCVector2 that is a position vector.</param> /// <param name="position2">Source TGCVector2 that is a position vector.</param> /// <param name="position3">Source TGCVector2 that is a position vector.</param> /// <param name="position4">Source TGCVector2 that is a position vector.</param> /// <param name="weightingFactor">Weighting factor.</param> /// <returns></returns> public static TGCVector2 CatmullRom(TGCVector2 position1, TGCVector2 position2, TGCVector2 position3, TGCVector2 position4, float weightingFactor) { return(new TGCVector2(Vector2.CatmullRom(position1.ToVector2(), position2.ToVector2(), position3.ToVector2(), position4.ToVector2(), weightingFactor))); }
/// <summary> /// Returns a 2-D vector that is made up of the smallest components of two 2-D vectors. /// </summary> /// <param name="left">Source TGCVector2.</param> /// <param name="right">Source TGCVector2.</param> /// <returns>A TGCVector2 that is made up of the smallest components of the two vectors.</returns> public static TGCVector2 Minimize(TGCVector2 left, TGCVector2 right) { return(new TGCVector2(Vector2.Minimize(left.ToVector2(), right.ToVector2()))); }
/// <summary> /// Imprime un TGCVector2 de la forma [150.0,150.0] /// </summary> public static string PrintVector2(TGCVector2 vec) { return(PrintVector2(vec.X, vec.Y)); }
/// <summary> /// Multiplies the current 2-D vector with a single value. /// </summary> /// <param name="source">Source TGCVector2.</param> /// <param name="s">Source float value.</param> /// <returns>A TGCVector2 that is the result of the source parameter multiplied by the s parameter.</returns> public static TGCVector2 Multiply(TGCVector2 source, float s) { return(new TGCVector2(Vector2.Multiply(source.ToVector2(), s))); }
/// <summary> /// Adds two 2-D vectors. /// </summary> /// <param name="v">Source TGCVector2.</param> public void Add(TGCVector2 v) { this.dxVector2.Add(v.ToVector2()); }
/// <summary> /// Returns the normalized version of a 2-D vector. /// </summary> /// <param name="source">Source TGCVector2.</param> /// <returns>A Vector2 that is the normalized version of the vector.</returns> public static TGCVector2 Normalize(TGCVector2 source) { return(new TGCVector2(Vector2.Normalize(source.ToVector2()))); }
/// <summary> /// Returns a point in barycentric coordinates, using specified 2-D vectors. /// </summary> /// <param name="v1">Source TGCVector2.</param> /// <param name="v2">Source TGCVector2.</param> /// <param name="v3">Source TGCVector2.</param> /// <param name="f">Weighting factor.</param> /// <param name="g">Weighting factor.</param> /// <returns>A TGCVector2 in barycentric coordinates.</returns> public static TGCVector2 BaryCentric(TGCVector2 v1, TGCVector2 v2, TGCVector2 v3, float f, float g) { return(new TGCVector2(Vector2.BaryCentric(v1.ToVector2(), v2.ToVector2(), v3.ToVector2(), f, g))); }
/// <summary> /// Builds a 2-D affine transformation matrix in the xy plane. /// </summary> /// <param name="scaling">Scaling factor. A value of zero indicates no scaling.</param> /// <param name="rotationCenter">A TGCVector2 structure that represents a point identifying the center of rotation. Use an empty TGCVector2 for no rotation.</param> /// <param name="rotation">Angle of rotation. A value of zero indicates no rotation.</param> /// <param name="translation">A TGCVector2 structure that represents the translation. Use TGCVector2.Empty to specify no translation.</param> /// <returns>A TGCMatrix that is an affine transformation matrix.</returns> public static TGCMatrix AffineTransformation2D(float scaling, TGCVector2 rotationCenter, float rotation, TGCVector2 translation) { return(new TGCMatrix(Matrix.AffineTransformation2D(scaling, rotationCenter, rotation, translation))); }