Module id.matcv
Package id.mathcalc

Class Vector2f

Object
Vector2f

public class Vector2f extends Object
Vector which contains two floats.

Vector itself is immutable all public fields are final.

All operations are immutable and return new copy of the vector.

  • Field Details

    • n1

      public final float n1
    • n2

      public final float n2
  • Constructor Details

    • Vector2f

      public Vector2f(Vector2f vec)
    • Vector2f

      public Vector2f(float n1, float n2)
  • Method Details

    • norm

      public float norm()
      L2 norm, equals to the square root of the dot product of vector with itself.
    • normalize

      public Vector2f normalize()
      Normalizes the vector, i.e. divides it by its own norm
    • mul

      public Vector2f mul(float scalar)
      Multiply vector with the scalar
    • sub

      public Vector2f sub(Vector2f vector)
      Multiply vector with the scalar
    • hashCode

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object