- java.lang.Object
-
- org.arakhne.afc.math.geometry.d2.d.Tuple2d<Vector2d>
-
- org.arakhne.afc.math.geometry.d2.d.Vector2d
-
- All Implemented Interfaces:
Serializable,Cloneable,Tuple2D<Vector2d>,Vector2D<Vector2d,Point2d>,JsonableObject
public class Vector2d extends Tuple2d<Vector2d> implements Vector2D<Vector2d,Point2d>
2D Vector with 2 double precision floating-point numbers.- Since:
- 13.0
- Version:
- 17.0 2020-01-04 14:41:43
- Author:
- Stéphane GALLAND
- See Also:
- Serialized Form
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- mathgeom
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.arakhne.afc.math.geometry.d2.Vector2D
Vector2D.PowerResult<T extends Vector2D<? super T,?>>
-
-
Constructor Summary
Constructors Constructor Description Vector2d()Construct a zero vector.Vector2d(double[] tuple)Constructor by copy.Vector2d(double x, double y)Construct a vector with the given coordinates.Vector2d(float x, float y)Construct a vector with the given coordinates.Vector2d(int[] tuple)Constructor by copy.Vector2d(int x, int y)Construct a vector with the given coordinates.Vector2d(long x, long y)Construct a vector with the given coordinates.Vector2d(Tuple2D<?> tuple)Constructor by copy.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Vector2D<?,?> vector)Sets the value of this tuple to the sum of itself and the given vector.voidadd(Vector2D<?,?> vector1, Vector2D<?,?> vector2)Sets the value of this tuple to the sum of tuples vector1 and vector2.static Vector2dconvert(Tuple2D<?> tuple)Convert the given tuple to a real Vector2d.doubledot(Vector2D<?,?> vector)Computes the dot product of the this vector and the given vector.GeomFactory2dgetGeomFactory()Replies the geometry factory associated to this point.doublegetLength()Returns the length of this vector.doublegetLengthSquared()Returns the squared length of this vector.doubleperp(Vector2D<?,?> vector)Compute the the perpendicular product of the two vectors (aka. the determinant of two vectors).voidscaleAdd(double scale, Vector2D<?,?> vector)Sets the value of this tuple to the scalar multiplication of itself and then adds tuple vector (this = s*this + vector).voidscaleAdd(double scale, Vector2D<?,?> vector1, Vector2D<?,?> vector2)Sets the value of this tuple to the scalar multiplication of the tuple vector1 plus the tuple vector2 (this = s*vector1 + vector2).voidscaleAdd(int scale, Vector2D<?,?> vector)Sets the value of this tuple to the scalar multiplication of itself and then adds tuple vector (this = s*this + vector).voidscaleAdd(int scale, Vector2D<?,?> vector1, Vector2D<?,?> vector2)Sets the value of this tuple to the scalar multiplication of tuple t1 plus tuple t2 (this = s*t1 + t2).voidsetLength(double newLength)Change the length of the vector.voidsub(Point2D<?,?> point1, Point2D<?,?> point2)Sets the value of this tuple to the difference of tuples point1 and point2 (this = point1 - point2).voidsub(Vector2D<?,?> vector)Sets the value of this tuple to the difference of itself and vector (this = this - vector).voidsub(Vector2D<?,?> vector1, Vector2D<?,?> vector2)Sets the value of this tuple to the difference of tuples vector1 and vector2 (this = vector1 - vector2).static Vector2dtoOrientationVector(double angle)Replies the orientation vector, which is corresponding to the given angle on a trigonometric circle.UnmodifiableVector2D<Vector2d,Point2d>toUnmodifiable()Replies an unmodifiable copy of this vector.-
Methods inherited from class org.arakhne.afc.math.geometry.d2.d.Tuple2d
absolute, absolute, add, add, addX, addX, addY, addY, clone, equals, getX, getY, hashCode, ix, iy, negate, negate, scale, scale, scale, scale, set, set, set, set, set, setX, setX, setY, setY, sub, sub, subX, subX, subY, subY, toJson, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.arakhne.afc.vmutil.json.JsonableObject
toJson
-
Methods inherited from interface org.arakhne.afc.math.geometry.d2.Tuple2D
absolute, absolute, add, add, addX, addX, addY, addY, clamp, clamp, clamp, clamp, clampMax, clampMax, clampMax, clampMax, clampMin, clampMin, clampMin, clampMin, clone, epsilonEquals, equals, equals, get, get, get, getX, getY, hashCode, interpolate, interpolate, ix, iy, negate, negate, scale, scale, scale, scale, set, set, set, set, set, setX, setX, setY, setY, sub, sub, subX, subX, subY, subY
-
Methods inherited from interface org.arakhne.afc.math.geometry.d2.Vector2D
$div, $minus, $minus, $minus, $minus, $plus, $plus, $plus, $times, $times, $up, $up, angle, getOrientationAngle, isOrthogonal, isUnitVector, makeOrthogonal, normalize, normalize, operator_add, operator_divide, operator_doubleDotLessThan, operator_elvis, operator_equals, operator_greaterThanDoubleDot, operator_minus, operator_minus, operator_minus, operator_minus, operator_multiply, operator_multiply, operator_notEquals, operator_plus, operator_plus, operator_plus, operator_power, operator_power, operator_remove, operator_upTo, power, signedAngle, toColinearVector, toOrthogonalVector, toUnitVector, turn, turn, turnLeft, turnLeft, turnLeft, turnRight, turnRight
-
-
-
-
Constructor Detail
-
Vector2d
public Vector2d()
Construct a zero vector.
-
Vector2d
public Vector2d(Tuple2D<?> tuple)
Constructor by copy.- Parameters:
tuple- is the tuple to copy.
-
Vector2d
public Vector2d(int[] tuple)
Constructor by copy.- Parameters:
tuple- is the tuple to copy.
-
Vector2d
public Vector2d(double[] tuple)
Constructor by copy.- Parameters:
tuple- is the tuple to copy.
-
Vector2d
public Vector2d(int x, int y)Construct a vector with the given coordinates.- Parameters:
x- x coordinate.y- y coordinate.
-
Vector2d
public Vector2d(float x, float y)Construct a vector with the given coordinates.- Parameters:
x- x coordinate.y- y coordinate.
-
Vector2d
public Vector2d(double x, double y)Construct a vector with the given coordinates.- Parameters:
x- x coordinate.y- y coordinate.
-
Vector2d
public Vector2d(long x, long y)Construct a vector with the given coordinates.- Parameters:
x- x coordinate.y- y coordinate.
-
-
Method Detail
-
convert
public static Vector2d convert(Tuple2D<?> tuple)
Convert the given tuple to a real Vector2d.If the given tuple is already a Vector2d, it is replied.
- Parameters:
tuple- the tuple.- Returns:
- the Vector2d.
- Since:
- 14.0
-
toOrientationVector
@Pure public static Vector2d toOrientationVector(double angle)
Replies the orientation vector, which is corresponding to the given angle on a trigonometric circle.- Parameters:
angle- is the angle in radians to translate.- Returns:
- the orientation vector which is corresponding to the given angle.
-
getGeomFactory
public GeomFactory2d getGeomFactory()
Description copied from interface:Vector2DReplies the geometry factory associated to this point.- Specified by:
getGeomFactoryin interfaceVector2D<Vector2d,Point2d>- Returns:
- the factory.
-
dot
@Pure public double dot(Vector2D<?,?> vector)
Description copied from interface:Vector2DComputes the dot product of the this vector and the given vector.
-
perp
@Pure public double perp(Vector2D<?,?> vector)
Description copied from interface:Vector2DCompute the the perpendicular product of the two vectors (aka. the determinant of two vectors).
wheredet(X1, X2) = |X1|.|X2|.sin(a)X1andX2are two vectors andais the angle betweenX1andX2.
-
getLength
@Pure public double getLength()
Description copied from interface:Vector2DReturns the length of this vector.
-
getLengthSquared
@Pure public double getLengthSquared()
Description copied from interface:Vector2DReturns the squared length of this vector.- Specified by:
getLengthSquaredin interfaceVector2D<Vector2d,Point2d>- Returns:
- the squared length of this vector
-
add
public void add(Vector2D<?,?> vector1, Vector2D<?,?> vector2)
Description copied from interface:Vector2DSets the value of this tuple to the sum of tuples vector1 and vector2.
-
add
public void add(Vector2D<?,?> vector)
Description copied from interface:Vector2DSets the value of this tuple to the sum of itself and the given vector.
-
scaleAdd
public void scaleAdd(int scale, Vector2D<?,?> vector1, Vector2D<?,?> vector2)Description copied from interface:Vector2DSets the value of this tuple to the scalar multiplication of tuple t1 plus tuple t2 (this = s*t1 + t2).
-
scaleAdd
public void scaleAdd(double scale, Vector2D<?,?> vector1, Vector2D<?,?> vector2)Description copied from interface:Vector2DSets the value of this tuple to the scalar multiplication of the tuple vector1 plus the tuple vector2 (this = s*vector1 + vector2).
-
scaleAdd
public void scaleAdd(int scale, Vector2D<?,?> vector)Description copied from interface:Vector2DSets the value of this tuple to the scalar multiplication of itself and then adds tuple vector (this = s*this + vector).
-
scaleAdd
public void scaleAdd(double scale, Vector2D<?,?> vector)Description copied from interface:Vector2DSets the value of this tuple to the scalar multiplication of itself and then adds tuple vector (this = s*this + vector).
-
sub
public void sub(Vector2D<?,?> vector1, Vector2D<?,?> vector2)
Description copied from interface:Vector2DSets the value of this tuple to the difference of tuples vector1 and vector2 (this = vector1 - vector2).
-
sub
public void sub(Point2D<?,?> point1, Point2D<?,?> point2)
Description copied from interface:Vector2DSets the value of this tuple to the difference of tuples point1 and point2 (this = point1 - point2).
-
sub
public void sub(Vector2D<?,?> vector)
Description copied from interface:Vector2DSets the value of this tuple to the difference of itself and vector (this = this - vector).
-
setLength
public void setLength(double newLength)
Description copied from interface:Vector2DChange the length of the vector. The direction of the vector is unchanged.
-
toUnmodifiable
@Pure public UnmodifiableVector2D<Vector2d,Point2d> toUnmodifiable()
Description copied from interface:Vector2DReplies an unmodifiable copy of this vector.- Specified by:
toUnmodifiablein interfaceVector2D<Vector2d,Point2d>- Returns:
- an unmodifiable copy.
-
-