Class Vector2D

java.lang.Object
edu.ntnu.stud.chaosgame.model.data.Vector2D
Direct Known Subclasses:
Complex

public class Vector2D extends Object
Class representing a 2D vector.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final double
    The x0 component of the vector.
    private final double
    The x1 component of the vector.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Vector2D(double x0, double x1)
    Create a new 2D vector; parameterized.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(Vector2D other)
    Add another vector to this vector.
    double
    Get the x0 component of the vector.
    double
    Get the x1 component of the vector.
    Subtract another vector from this vector.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • x0

      private final double x0
      The x0 component of the vector.
    • x1

      private final double x1
      The x1 component of the vector.
  • Constructor Details

    • Vector2D

      public Vector2D(double x0, double x1)
      Create a new 2D vector; parameterized.
      Parameters:
      x0 - The x0 component of the vector.
      x1 - The x1 component of the vector.
  • Method Details

    • getX0

      public double getX0()
      Get the x0 component of the vector.
      Returns:
      The x0 component of the vector.
    • getX1

      public double getX1()
      Get the x1 component of the vector.
      Returns:
      The x1 component of the vector.
    • add

      public Vector2D add(Vector2D other)
      Add another vector to this vector.
      Parameters:
      other - The other vector to add.
      Returns:
      A new vector that is the sum of this vector and the other vector.
    • subtract

      public Vector2D subtract(Vector2D other)
      Subtract another vector from this vector.
      Parameters:
      other - The other vector to subtract.
      Returns:
      A new vector that is the difference between this vector and the other vector.