public class

Vector2D

extends Object
java.lang.Object
   ↳ com.commsignia.v2x.utils.vectors.Vector2D

Class Overview

A class representing a vector in 2D space

Summary

Public Constructors
Vector2D(double x, double y)
Create a vector using the supplied x and y coordinates
Public Methods
double angleWith(Vector2D other)
Calculate angle with another vector
double dot(Vector2D other)
Calculate dot product
boolean equals(Object o)
double getX()
Get the X coordinate
double getY()
Get the Y coordinate
int hashCode()
Vector2D multiply(double scalar)
Multiply the vector with the given scalar
Vector2D perpendicular()
Create a vector perpendicular to this vector
String toString()
Return a human readable representation of this vector
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Vector2D (double x, double y)

Create a vector using the supplied x and y coordinates

Parameters
x X coordinate
y Y coordinate

Public Methods

public double angleWith (Vector2D other)

Calculate angle with another vector

Parameters
other the other vector
Returns
  • angle in degrees

public double dot (Vector2D other)

Calculate dot product

Parameters
other other vector
Returns
  • calculated dot product

public boolean equals (Object o)

public double getX ()

Get the X coordinate

Returns
  • x coordinate as a double value

public double getY ()

Get the Y coordinate

Returns
  • y coordinate as a double value

public int hashCode ()

public Vector2D multiply (double scalar)

Multiply the vector with the given scalar

Parameters
scalar scalar value
Returns
  • multiplied vector

public Vector2D perpendicular ()

Create a vector perpendicular to this vector

Returns
  • perpendicular vector

public String toString ()

Return a human readable representation of this vector

Returns
  • human readable string