org.jsfml.system

Class Vector2f

• All Implemented Interfaces:
Serializable

```public final class Vector2f
extends Object
implements Serializable```
Represents two-dimensional vectors using floating point coordinates and provides arithmetic operations on floating point 2D vectors.
Serialized Form
• Field Summary

Fields
Modifier and Type Field and Description
`float` `x`
The vector's X coordinate.
`float` `y`
The vector's Y coordinate.
`static Vector2f` `ZERO`
The zero vector.
• Constructor Summary

Constructors
Constructor and Description
```Vector2f(float x, float y)```
Constructs a new vector with the given coordinates.
`Vector2f(Vector2i v)`
Constructs a new vector by converting an integral vector.
• Method Summary

Methods
Modifier and Type Method and Description
`static Vector2f` ```add(Vector2f a, Vector2f b)```
`static Vector2f` ```componentwiseDiv(Vector2f a, Vector2f b)```
Performs a component-wise division of two vectors.
`static Vector2f` ```componentwiseMul(Vector2f a, Vector2f b)```
Performs a component-wise multiplication of two vectors.
`static Vector2f` ```div(Vector2f a, float s)```
Multiplies a vector by the inverse of a scalar.
`boolean` `equals(Object o)`
`int` `hashCode()`
`static Vector2f` ```mul(Vector2f a, float s)```
Multiplies a vector by a scalar.
`static Vector2f` `neg(Vector2f v)`
Computes the negation of a vector.
`static Vector2f` ```sub(Vector2f a, Vector2f b)```
Subtracts two vectors.
`String` `toString()`
• Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`
• Field Detail

• ZERO

`public static final Vector2f ZERO`
The zero vector.
• x

`public final float x`
The vector's X coordinate.
• y

`public final float y`
The vector's Y coordinate.
• Constructor Detail

• Vector2f

```public Vector2f(float x,
float y)```
Constructs a new vector with the given coordinates.
Parameters:
`x` - the X coordinate.
`y` - the Y coordinate.
• Vector2f

`public Vector2f(Vector2i v)`
Constructs a new vector by converting an integral vector.

The fractions of the coordinates will be zero.

Parameters:
`v` - the vector to convert.
• Method Detail

```public static Vector2f add(Vector2f a,
Vector2f b)```
Parameters:
`a` - the first vector.
`b` - the second vector.
Returns:
a new vector, representing the sum of the two vectors.
• sub

```public static Vector2f sub(Vector2f a,
Vector2f b)```
Subtracts two vectors.
Parameters:
`a` - the first vector.
`b` - the second vector.
Returns:
a new vector, representing the difference between the two vectors.
• componentwiseMul

```public static Vector2f componentwiseMul(Vector2f a,
Vector2f b)```
Performs a component-wise multiplication of two vectors.
Parameters:
`a` - the first vector.
`b` - the second vector.
Returns:
a new vector, representing the "product" of the two vectors.
• componentwiseDiv

```public static Vector2f componentwiseDiv(Vector2f a,
Vector2f b)```
Performs a component-wise division of two vectors.
Parameters:
`a` - the first vector.
`b` - the second vector.
Returns:
a new vector, representing the "quotient" of the two vectors.
• mul

```public static Vector2f mul(Vector2f a,
float s)```
Multiplies a vector by a scalar.
Parameters:
`a` - the vector.
`s` - the scalar to multiply by.
Returns:
a new vector, representing the scaled vector.
• div

```public static Vector2f div(Vector2f a,
float s)```
Multiplies a vector by the inverse of a scalar.
Parameters:
`a` - the vector.
`s` - the scalar to divide by.
Returns:
a new vector, representing the scaled vector.
• neg

`public static Vector2f neg(Vector2f v)`
Computes the negation of a vector.
Parameters:
`v` - the vector.
Returns:
a new vector, representing the negation of the given vector.
• equals

`public boolean equals(Object o)`
Overrides:
`equals` in class `Object`
• hashCode

`public int hashCode()`
Overrides:
`hashCode` in class `Object`
• toString

`public String toString()`
Overrides:
`toString` in class `Object`