tig.maths
Class Vector2
- java.lang.Object
-
- tig.maths.Vector2
-
public class Vector2 extends java.lang.ObjectSimple representation of a vector in a 2D space.
Represented as 2doubles.
-
-
Field Summary
Fields Modifier and Type Field and Description doublex0First coordinate of this vector.doublex1Second coordinate of this vector.
-
Constructor Summary
Constructors Constructor and Description Vector2(double[] coords)Constructor from an array containing 2doubles.Vector2(double a0, double a1)Constructor from 2doubles.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static Vector2add(Vector2 a, Vector2 b)Returns aVector2c such as c = a + b.static Vector2mul(double k, Vector2 a)Multiplication of a vector by a scalar ; returns a vector b such as b = k a.static Vector2mul(Matrix2 M, Vector2 a)Multiplication of a vector by a matrix ; returns a vector b such as b = M a.static Vector2negate(Vector2 a)Returns aVector2b such as b = -a.static doublenorm(Vector2 v)Returns the norm of the vector passed in parameter.static Vector2sub(Vector2 a, Vector2 b)Returns aVector2c such as c = a - b.java.lang.StringtoString()Returns a String representation of this Vector.
-
-
-
Field Detail
-
x0
public double x0
First coordinate of this vector.
-
x1
public double x1
Second coordinate of this vector.
-
-
Constructor Detail
-
Vector2
public Vector2(double a0, double a1)Constructor from 2doubles.
-
Vector2
public Vector2(double[] coords)
Constructor from an array containing 2doubles.- Throws:
java.lang.IllegalArgumentException- ifcoords.length != 2.
-
-
Method Detail
-
toString
public java.lang.String toString()
Returns a String representation of this Vector. The form is :(x0, x1).- Overrides:
toStringin classjava.lang.Object
-
norm
public static double norm(Vector2 v)
Returns the norm of the vector passed in parameter.
-
mul
public static Vector2 mul(Matrix2 M, Vector2 a)
Multiplication of a vector by a matrix ; returns a vector b such as b = M a.
-
mul
public static Vector2 mul(double k, Vector2 a)
Multiplication of a vector by a scalar ; returns a vector b such as b = k a.
-
-
DMelt 3.0 © DataMelt by jWork.ORG