edu.wpi.first.wpilibj.drive

## Class Vector2d

• java.lang.Object
• edu.wpi.first.wpilibj.drive.Vector2d

• ```public class Vector2d
extends java.lang.Object```
This is a 2D vector struct that supports basic vector operations.
• ### Field Summary

Fields
Modifier and Type Field and Description
`double` `x`
`double` `y`
• ### Constructor Summary

Constructors
Constructor and Description
`Vector2d()`
```Vector2d(double x, double y)```
• ### Method Summary

All Methods
Modifier and Type Method and Description
`double` `dot(Vector2d vec)`
Returns dot product of this vector with argument.
`double` `magnitude()`
Returns magnitude of vector.
`void` `rotate(double angle)`
Rotate a vector in Cartesian space.
`double` `scalarProject(Vector2d vec)`
Returns scalar projection of this vector onto argument.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Field Detail

• #### x

`public double x`
• #### y

`public double y`
• ### Constructor Detail

• #### Vector2d

`public Vector2d()`
• #### Vector2d

```public Vector2d(double x,
double y)```
• ### Method Detail

• #### rotate

`public void rotate(double angle)`
Rotate a vector in Cartesian space.
Parameters:
`angle` - angle in degrees by which to rotate vector counter-clockwise.
• #### dot

`public double dot(Vector2d vec)`
Returns dot product of this vector with argument.
Parameters:
`vec` - Vector with which to perform dot product.
• #### magnitude

`public double magnitude()`
Returns magnitude of vector.
• #### scalarProject

`public double scalarProject(Vector2d vec)`
Returns scalar projection of this vector onto argument.
Parameters:
`vec` - Vector onto which to project this vector.