Package jadex.extension.envsupport.math
Class Vector2Double
- java.lang.Object
-
- jadex.extension.envsupport.math.Vector2Double
-
-
Constructor Summary
Constructors Constructor Description Vector2Double()
Creates a new Vector2Double with the value (0,0).Vector2Double(double scalar)
Creates a new Vector2 using the scalar to assign the value (scalar,scalar).Vector2Double(double x, double y)
Creates a new Vector2 with the given value.Vector2Double(IVector2 vector)
Creates a new Vector2 with the same value as the input vector.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IVector2
add(double scalar)
Adds a scalar to each component of this vector.IVector2
add(IVector1 scalar)
Adds a scalar to each component of this vector.IVector2
add(IVector2 vector)
Adds another vector to this vector, adding individual components.IVector2
assign(IVector2 vector)
Assigns this vector the values of another vector.java.lang.Object
clone()
Generates a deep clone of the vector.IVector2
copy()
Makes a copy of the vector without using the complex clone interface.IVector2
divide(IVector2 vector)
Performs a division on the vector.boolean
equals(IVector2 vector)
Compares the vector to another vector.boolean
equals(java.lang.Object obj)
Compares the vector to an objectIVector1
getDirection()
Returns the direction (theta) of the vector.IVector1
getDirection(IVector2 vector)
Returns the direction (theta) of the vector.double
getDirectionAsDouble()
Returns the direction (theta) of the vector as double.double
getDirectionAsDouble(IVector2 vector)
Returns the direction (theta) of the vector as double.float
getDirectionAsFloat()
Returns the direction (theta) of the vector as float.float
getDirectionAsFloat(IVector2 vector)
Returns the direction (theta) of the vector as float.IVector1
getDistance(IVector2 vector)
Returns the distance to another vector.double
getInnerProductAsDouble(IVector2 vector)
Returns the length (magnitude) of the vector.IVector1
getLength()
Returns the length (magnitude) of the vector.IVector1
getMean()
Returns the mean average of the vector components.IVector1
getSquaredLength()
Returns the squared length (magnitude) of the vector.static IVector2
getVector2(java.lang.Double a, java.lang.Double b)
Get a vector for two doubles.Vector3Double
getVector3DoubleValueNoHight()
IVector1
getX()
Returns the x-component of the vector.java.math.BigDecimal
getXAsBigDecimal()
Returns the x-component of the vector as BigDecimal.double
getXAsDouble()
Returns the x-component of the vector as double.float
getXAsFloat()
Returns the x-component of the vector as float.int
getXAsInteger()
Returns the x-component of the vector as integer.long
getXAsLong()
Returns the x-component of the vector as long.IVector1
getY()
Returns the y-component of the vector.java.math.BigDecimal
getYAsBigDecimal()
Returns the component of the vector as BigDecima;.double
getYAsDouble()
Returns the component of the vector as double.float
getYAsFloat()
Returns the component of the vector as float.int
getYAsInteger()
Returns the component of the vector as integer.long
getYAsLong()
Returns the component of the vector as float.int
hashCode()
Compute the hash code.IVector2
mod(IVector2 modulus)
Applies a modulo vector.IVector2
multiply(double scalar)
Performs a scalar multiplication (scaling) on the vector.IVector2
multiply(IVector1 scalar)
Performs a scalar multiplication (scaling) on the vector.IVector2
multiply(IVector2 vector)
Performs a multiplication on the vector.IVector2
negate()
Negates the vector by negating its components.IVector2
negateX()
Negates the x-component.IVector2
negateY()
Negates the y-component.IVector2
normalize()
Converts the vector to a unit vector (normalization)IVector2
randomX(IVector1 lower, IVector1 upper)
Sets the x-component to a random value in the interval [lower,upper]IVector2
randomY(IVector1 lower, IVector1 upper)
Sets the y-component to a random value in the interval [lower,upper]IVector2
redirect(double angle)
Redirects the vector to a new direction, maintaining the magnitude.void
setX(IVector1 x)
void
setY(IVector1 y)
IVector2
subtract(double scalar)
Subtracts a scalar to each component of this vector.IVector2
subtract(IVector1 scalar)
Subtracts a scalar to each component of this vector.IVector2
subtract(IVector2 vector)
Subtracts another vector to this vector, subtracting individual components.java.lang.String
toString()
IVector2
zero()
Sets all vector components to zero.
-
-
-
Field Detail
-
ZERO
public static final IVector2 ZERO
Zero vector.
-
-
Constructor Detail
-
Vector2Double
public Vector2Double()
Creates a new Vector2Double with the value (0,0).
-
Vector2Double
public Vector2Double(IVector2 vector)
Creates a new Vector2 with the same value as the input vector.
-
Vector2Double
public Vector2Double(double scalar)
Creates a new Vector2 using the scalar to assign the value (scalar,scalar).
-
Vector2Double
public Vector2Double(double x, double y)
Creates a new Vector2 with the given value.
-
-
Method Detail
-
add
public IVector2 add(double scalar)
Description copied from interface:IVector2
Adds a scalar to each component of this vector.
-
add
public IVector2 add(IVector1 scalar)
Description copied from interface:IVector2
Adds a scalar to each component of this vector.
-
add
public IVector2 add(IVector2 vector)
Description copied from interface:IVector2
Adds another vector to this vector, adding individual components.
-
subtract
public IVector2 subtract(double scalar)
Description copied from interface:IVector2
Subtracts a scalar to each component of this vector.
-
subtract
public IVector2 subtract(IVector1 scalar)
Description copied from interface:IVector2
Subtracts a scalar to each component of this vector.
-
subtract
public IVector2 subtract(IVector2 vector)
Description copied from interface:IVector2
Subtracts another vector to this vector, subtracting individual components.
-
mod
public IVector2 mod(IVector2 modulus)
Description copied from interface:IVector2
Applies a modulo vector. The modulus will be added first so that values in the interval (-modulus, 0) will wrap over into the positive range.
-
multiply
public IVector2 multiply(double scalar)
Description copied from interface:IVector2
Performs a scalar multiplication (scaling) on the vector.
-
multiply
public IVector2 multiply(IVector1 scalar)
Description copied from interface:IVector2
Performs a scalar multiplication (scaling) on the vector.
-
multiply
public IVector2 multiply(IVector2 vector)
Description copied from interface:IVector2
Performs a multiplication on the vector.
-
zero
public IVector2 zero()
Description copied from interface:IVector2
Sets all vector components to zero.
-
negateX
public IVector2 negateX()
Description copied from interface:IVector2
Negates the x-component.
-
negateY
public IVector2 negateY()
Description copied from interface:IVector2
Negates the y-component.
-
negate
public IVector2 negate()
Description copied from interface:IVector2
Negates the vector by negating its components.
-
randomX
public IVector2 randomX(IVector1 lower, IVector1 upper)
Description copied from interface:IVector2
Sets the x-component to a random value in the interval [lower,upper]
-
randomY
public IVector2 randomY(IVector1 lower, IVector1 upper)
Description copied from interface:IVector2
Sets the y-component to a random value in the interval [lower,upper]
-
normalize
public IVector2 normalize()
Description copied from interface:IVector2
Converts the vector to a unit vector (normalization)
-
redirect
public IVector2 redirect(double angle)
Redirects the vector to a new direction, maintaining the magnitude.
-
getLength
public IVector1 getLength()
Description copied from interface:IVector2
Returns the length (magnitude) of the vector.
-
getSquaredLength
public IVector1 getSquaredLength()
Returns the squared length (magnitude) of the vector.- Specified by:
getSquaredLength
in interfaceIVector2
- Returns:
- squared vector length
-
getDirection
public IVector1 getDirection()
Description copied from interface:IVector2
Returns the direction (theta) of the vector.- Specified by:
getDirection
in interfaceIVector2
- Returns:
- vector direction
-
getDirectionAsFloat
public float getDirectionAsFloat()
Description copied from interface:IVector2
Returns the direction (theta) of the vector as float.- Specified by:
getDirectionAsFloat
in interfaceIVector2
- Returns:
- vector direction as float
-
getDirectionAsDouble
public double getDirectionAsDouble()
Description copied from interface:IVector2
Returns the direction (theta) of the vector as double.- Specified by:
getDirectionAsDouble
in interfaceIVector2
- Returns:
- vector direction as double
-
getMean
public IVector1 getMean()
Description copied from interface:IVector2
Returns the mean average of the vector components.
-
getDistance
public IVector1 getDistance(IVector2 vector)
Description copied from interface:IVector2
Returns the distance to another vector.- Specified by:
getDistance
in interfaceIVector2
- Parameters:
vector
- other vector- Returns:
- distance
-
getX
public IVector1 getX()
Description copied from interface:IVector2
Returns the x-component of the vector.
-
getY
public IVector1 getY()
Description copied from interface:IVector2
Returns the y-component of the vector.
-
setX
public void setX(IVector1 x)
-
setY
public void setY(IVector1 y)
-
getXAsInteger
public int getXAsInteger()
Returns the x-component of the vector as integer.- Specified by:
getXAsInteger
in interfaceIVector2
- Returns:
- x-component as integer
-
getYAsInteger
public int getYAsInteger()
Returns the component of the vector as integer.- Specified by:
getYAsInteger
in interfaceIVector2
- Returns:
- y-component as float
-
getXAsLong
public long getXAsLong()
Returns the x-component of the vector as long.- Specified by:
getXAsLong
in interfaceIVector2
- Returns:
- x-component as long
-
getYAsLong
public long getYAsLong()
Returns the component of the vector as float.- Specified by:
getYAsLong
in interfaceIVector2
- Returns:
- y-component as float
-
getXAsFloat
public float getXAsFloat()
Description copied from interface:IVector2
Returns the x-component of the vector as float.- Specified by:
getXAsFloat
in interfaceIVector2
- Returns:
- x-component as float
-
getYAsFloat
public float getYAsFloat()
Description copied from interface:IVector2
Returns the component of the vector as float.- Specified by:
getYAsFloat
in interfaceIVector2
- Returns:
- y-component as float
-
getXAsDouble
public double getXAsDouble()
Description copied from interface:IVector2
Returns the x-component of the vector as double.- Specified by:
getXAsDouble
in interfaceIVector2
- Returns:
- x-component as double
-
getYAsDouble
public double getYAsDouble()
Description copied from interface:IVector2
Returns the component of the vector as double.- Specified by:
getYAsDouble
in interfaceIVector2
- Returns:
- y-component as double
-
getXAsBigDecimal
public java.math.BigDecimal getXAsBigDecimal()
Description copied from interface:IVector2
Returns the x-component of the vector as BigDecimal.- Specified by:
getXAsBigDecimal
in interfaceIVector2
- Returns:
- x-component as BigDecimal
-
getYAsBigDecimal
public java.math.BigDecimal getYAsBigDecimal()
Description copied from interface:IVector2
Returns the component of the vector as BigDecima;.- Specified by:
getYAsBigDecimal
in interfaceIVector2
- Returns:
- y-component as BigDecimal
-
copy
public IVector2 copy()
Description copied from interface:IVector2
Makes a copy of the vector without using the complex clone interface.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Description copied from interface:IVector2
Generates a deep clone of the vector.
-
equals
public boolean equals(java.lang.Object obj)
Description copied from interface:IVector2
Compares the vector to an object
-
equals
public boolean equals(IVector2 vector)
Description copied from interface:IVector2
Compares the vector to another vector. The vectors are equal if the components are equal.
-
hashCode
public int hashCode()
Compute the hash code.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- The hash code.
-
getVector3DoubleValueNoHight
public Vector3Double getVector3DoubleValueNoHight()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getVector2
public static IVector2 getVector2(java.lang.Double a, java.lang.Double b)
Get a vector for two doubles.- Parameters:
a
- The first value.b
- The second value.- Returns:
- The vector (null if at least one of args is null).
-
getInnerProductAsDouble
public double getInnerProductAsDouble(IVector2 vector)
Description copied from interface:IVector2
Returns the length (magnitude) of the vector.- Specified by:
getInnerProductAsDouble
in interfaceIVector2
- Returns:
- vector length
-
getDirection
public IVector1 getDirection(IVector2 vector)
Description copied from interface:IVector2
Returns the direction (theta) of the vector.- Specified by:
getDirection
in interfaceIVector2
- Returns:
- vector direction
-
getDirectionAsDouble
public double getDirectionAsDouble(IVector2 vector)
Description copied from interface:IVector2
Returns the direction (theta) of the vector as double.- Specified by:
getDirectionAsDouble
in interfaceIVector2
- Returns:
- vector direction as double
-
getDirectionAsFloat
public float getDirectionAsFloat(IVector2 vector)
Description copied from interface:IVector2
Returns the direction (theta) of the vector as float.- Specified by:
getDirectionAsFloat
in interfaceIVector2
- Returns:
- vector direction as float
-
-