Class Vec2


  • public class Vec2
    extends java.lang.Object
    a cartesian vector
    • Field Summary

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

      Constructors 
      Constructor Description
      Vec2​(double x, double y)
      creates a cartesian vectors
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Vec2 add​(Vec2 other)
      add two vectors (neither will be modified)
      Vec2 div​(int scale)
      divides vector by a scalar value (this will not be modified)
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      Vec2 mul​(double scale)
      multiply vector by a scalar value (this will not be modified)
      Vec2 negate()
      negates a vector (this will not be modified)
      Vec2 sub​(Vec2 other)
      subtract two vectors (neither will be modified)
      • Methods inherited from class java.lang.Object

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

      • x

        public double x
        x coordinate
      • y

        public double y
        y coordinate
    • Constructor Detail

      • Vec2

        public Vec2​(double x,
                    double y)
        creates a cartesian vectors
        Parameters:
        x - x coordinate
        y - y coordinate
    • Method Detail

      • add

        public Vec2 add​(Vec2 other)
        add two vectors (neither will be modified)
        Parameters:
        other - vector add to
        Returns:
        copied sum
      • sub

        public Vec2 sub​(Vec2 other)
        subtract two vectors (neither will be modified)
        Parameters:
        other - vector to subtract
        Returns:
        copied difference
      • mul

        public Vec2 mul​(double scale)
        multiply vector by a scalar value (this will not be modified)
        Parameters:
        scale - scalar value
        Returns:
        scaled copy
      • negate

        public Vec2 negate()
        negates a vector (this will not be modified)
        Returns:
        negated copy
      • div

        public Vec2 div​(int scale)
        divides vector by a scalar value (this will not be modified)
        Parameters:
        scale - scalar value
        Returns:
        scaled copy
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object