Class Point4Int

java.lang.Object
com.github.yellowstonegames.grid.Point4Int
All Implemented Interfaces:
com.github.tommyettinger.crux.Point4<Point4Int>, com.github.tommyettinger.crux.PointN<Point4Int>, com.github.tommyettinger.crux.PointNInt<Point4Int, com.github.tommyettinger.crux.Point4<?>>, com.github.tommyettinger.ds.PrimitiveCollection<Integer>, com.github.tommyettinger.ds.PrimitiveCollection.OfInt, PointNInt<Point4Int, com.github.tommyettinger.crux.Point4<?>>

public class Point4Int extends Object implements com.github.tommyettinger.crux.Point4<Point4Int>, PointNInt<Point4Int, com.github.tommyettinger.crux.Point4<?>>, com.github.tommyettinger.ds.PrimitiveCollection.OfInt
A mutable 4D point with int components implementing Point4, PrimitiveCollection.OfInt, and PointNInt.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.github.tommyettinger.ds.PrimitiveCollection

    com.github.tommyettinger.ds.PrimitiveCollection.OfBoolean, com.github.tommyettinger.ds.PrimitiveCollection.OfByte, com.github.tommyettinger.ds.PrimitiveCollection.OfChar, com.github.tommyettinger.ds.PrimitiveCollection.OfDouble, com.github.tommyettinger.ds.PrimitiveCollection.OfFloat, com.github.tommyettinger.ds.PrimitiveCollection.OfInt, com.github.tommyettinger.ds.PrimitiveCollection.OfLong, com.github.tommyettinger.ds.PrimitiveCollection.OfShort
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
     
    int
     
    int
     
    int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    Point4Int(int x, int y, int z, int w)
     
    Point4Int(com.github.tommyettinger.crux.Point4<?> p)
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    add(float x, float y, float z, float w)
     
    boolean
    add(int c)
    Not supported; this collection is fixed-size.
    add(int x, int y, int z, int w)
     
    add(com.github.tommyettinger.crux.Point4<?> point)
     
    add(Point4Int point)
     
    addProduct(com.github.tommyettinger.crux.Point4<?> vec, float scalar)
     
    addProduct(com.github.tommyettinger.crux.Point4<?> vec, com.github.tommyettinger.crux.Point4<?> mulVec)
     
    clampEach(int min, int max)
    For each component, this clamps it between min and max, inclusive.
    clampLength(float min, float max)
     
    void
    Not supported; this collection is fixed-size.
    boolean
    contains(int c)
    Compares c with the components of this collection using ==; if any are considered equal, this returns true.
     
    cpy()
     
    float
    distance(com.github.tommyettinger.crux.Point4<?> point)
     
    int
    distanceSquared(com.github.tommyettinger.crux.Point4<?> point)
     
    div(Point4Int point)
     
    divide(float scalar)
     
    float
    dot(com.github.tommyettinger.crux.Point4<?> other)
     
    static float
    dot(com.github.tommyettinger.crux.Point4<?> a, com.github.tommyettinger.crux.Point4<?> b)
     
    int
    dst2(com.github.tommyettinger.crux.Point4<?> point)
     
    float
    dst2(Point4Int point)
     
    boolean
     
    boolean
    Returns true if this type of point uses float or double for its components, or false otherwise.
    Sets this Point4Int to the value represented by the specified string according to the format of toString().
    int
    get(int index)
    Gets the component at the specified index.
    int
     
    interpolate(com.github.tommyettinger.crux.Point4<?> target, float alpha, com.github.tommyettinger.digital.Interpolations.Interpolator interpolation)
    Calls PointNInt.lerp(PointN, float) with the alpha determined by the given interpolation.
    boolean
     
     
    float
     
    lerp(com.github.tommyettinger.crux.Point4<?> target, float alpha)
    Linear-interpolates from this point toward target, moving a distance proportional to alpha and changing this point in-place if possible.
    limit(float limit)
     
    limit2(float limit2)
     
    limitSquared(float limit2)
     
    minus(float scalar)
     
    mul(float scalar)
    Multiplies each component of this by the given scalar, in-place, and returns this.
    mul(float x, float y, float z, float w)
    Multiplies each component of this by the corresponding scalar, in-place, and returns this.
    mul(int scalar)
    Multiplies each component of this by the given scalar, in-place, and returns this.
    mul(int x, int y, int z, int w)
    Multiplies each component of this by the corresponding scalar, in-place, and returns this.
    mul(com.github.tommyettinger.crux.Point4<?> point)
     
    mul(Point4Int point)
     
    mulAdd(com.github.tommyettinger.crux.Point4<?> vec, float scalar)
     
    mulAdd(com.github.tommyettinger.crux.Point4<?> vec, com.github.tommyettinger.crux.Point4<?> mulVec)
     
    multiply(float scalar)
    Multiplies each component of this by the given scalar, in-place, and returns this.
    multiply(float x, float y, float z, float w)
    Multiplies each component of this by the corresponding scalar, in-place, and returns this.
    multiply(int scalar)
    Multiplies each component of this by the given scalar, in-place, and returns this.
    multiply(int x, int y, int z, int w)
    Multiplies each component of this by the corresponding scalar, in-place, and returns this.
    multiply(com.github.tommyettinger.crux.Point4<?> point)
     
    boolean
     
    plus(float scalar)
     
    boolean
    remove(int c)
    Not supported; this collection is fixed-size.
    scale(float scalar)
     
    scale(float x, float y, float z, float w)
     
    scale(int scalar)
     
    scale(int x, int y, int z, int w)
     
    scale(com.github.tommyettinger.crux.Point4<?> point)
     
    scl(float scalar)
     
    scl(float x, float y, float z, float w)
     
    scl(int scalar)
     
    scl(int x, int y, int z, int w)
     
    scl(com.github.tommyettinger.crux.Point4<?> point)
     
    scl(Point4Int point)
     
    set(float x, float y, float z, float w)
     
    set(int x, int y, int z, int w)
     
    set(com.github.tommyettinger.crux.Point4<?> point)
     
    set(Point4Int point)
     
    setAt(int index, int value)
    Sets the component at the specified index to the specified value.
    setLength(float len)
     
    setLength2(float len2)
     
     
    int
     
    sub(float x, float y, float z, float w)
     
    sub(int x, int y, int z, int w)
     
    sub(com.github.tommyettinger.crux.Point4<?> point)
     
    sub(Point4Int point)
     
    subtract(float x, float y, float z, float w)
     
    subtract(int x, int y, int z, int w)
     
    subtract(com.github.tommyettinger.crux.Point4<?> point)
     
    times(float scalar)
     
    Converts this Point4Int to a string in the format (x,y,z,w).
    float
    w()
     
    w(float next)
     
    int
    wi()
     
    wi(int next)
     
    float
    x()
     
    x(float next)
     
    int
    xi()
     
    xi(int next)
     
    float
    y()
     
    y(float next)
     
    int
    yi()
     
    yi(int next)
     
    float
    z()
     
    z(float next)
     
    int
    zi()
     
    zi(int next)
     

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.github.tommyettinger.crux.Point4

    rank, seti

    Methods inherited from interface com.github.tommyettinger.crux.PointN

    dst, isUnit, isUnit, isZero, isZero, len, mutable, nor

    Methods inherited from interface com.github.tommyettinger.ds.PrimitiveCollection.OfInt

    addAll, addAll, addAll, addAll, addDense, addDense, addLegible, addLegible, addVarargs, appendTo, appendTo, containsAll, containsAll, containsAll, containsAll, containsAny, containsAny, containsAny, containsAny, denseAppendTo, equalContents, first, forEach, removeAll, removeAll, removeAll, removeAll, removeEach, removeEach, removeEach, removeEach, removeIf, retainAll, retainAll, retainAll, toArray, toArray, toDenseString, toDenseString, toString, toString, toString
  • Field Details

    • x

      public int x
    • y

      public int y
    • z

      public int z
    • w

      public int w
  • Constructor Details

    • Point4Int

      public Point4Int()
    • Point4Int

      public Point4Int(int x, int y, int z, int w)
    • Point4Int

      public Point4Int(Point4Int p)
    • Point4Int

      public Point4Int(com.github.tommyettinger.crux.Point4<?> p)
  • Method Details

    • floatingPoint

      public boolean floatingPoint()
      Returns true if this type of point uses float or double for its components, or false otherwise. This always returns false.
      Specified by:
      floatingPoint in interface com.github.tommyettinger.crux.PointN<Point4Int>
      Specified by:
      floatingPoint in interface com.github.tommyettinger.crux.PointNInt<Point4Int, com.github.tommyettinger.crux.Point4<?>>
      Specified by:
      floatingPoint in interface PointNInt<Point4Int, com.github.tommyettinger.crux.Point4<?>>
      Returns:
      false
    • cpy

      public Point4Int cpy()
      Specified by:
      cpy in interface com.github.tommyettinger.crux.PointN<Point4Int>
    • copy

      public Point4Int copy()
    • len2

      public float len2()
      Specified by:
      len2 in interface com.github.tommyettinger.crux.PointN<Point4Int>
    • set

      public Point4Int set(Point4Int point)
      Specified by:
      set in interface com.github.tommyettinger.crux.PointN<Point4Int>
    • set

      public Point4Int set(com.github.tommyettinger.crux.Point4<?> point)
    • sub

      public Point4Int sub(Point4Int point)
      Specified by:
      sub in interface com.github.tommyettinger.crux.PointN<Point4Int>
    • sub

      public Point4Int sub(com.github.tommyettinger.crux.Point4<?> point)
    • subtract

      public Point4Int subtract(com.github.tommyettinger.crux.Point4<?> point)
    • add

      public Point4Int add(Point4Int point)
      Specified by:
      add in interface com.github.tommyettinger.crux.PointN<Point4Int>
    • add

      public Point4Int add(com.github.tommyettinger.crux.Point4<?> point)
    • scl

      public Point4Int scl(Point4Int point)
      Specified by:
      scl in interface com.github.tommyettinger.crux.PointN<Point4Int>
    • scl

      public Point4Int scl(com.github.tommyettinger.crux.Point4<?> point)
    • scale

      public Point4Int scale(com.github.tommyettinger.crux.Point4<?> point)
    • mul

      public Point4Int mul(Point4Int point)
    • mul

      public Point4Int mul(com.github.tommyettinger.crux.Point4<?> point)
    • multiply

      public Point4Int multiply(com.github.tommyettinger.crux.Point4<?> point)
    • dst2

      public float dst2(Point4Int point)
      Specified by:
      dst2 in interface com.github.tommyettinger.crux.PointN<Point4Int>
    • dst2

      public int dst2(com.github.tommyettinger.crux.Point4<?> point)
    • distance

      public float distance(com.github.tommyettinger.crux.Point4<?> point)
    • distanceSquared

      public int distanceSquared(com.github.tommyettinger.crux.Point4<?> point)
    • setZero

      public Point4Int setZero()
      Specified by:
      setZero in interface com.github.tommyettinger.crux.PointN<Point4Int>
    • x

      public float x()
      Specified by:
      x in interface com.github.tommyettinger.crux.Point4<Point4Int>
    • x

      public Point4Int x(float next)
      Specified by:
      x in interface com.github.tommyettinger.crux.Point4<Point4Int>
    • xi

      public int xi()
      Specified by:
      xi in interface com.github.tommyettinger.crux.Point4<Point4Int>
    • xi

      public Point4Int xi(int next)
      Specified by:
      xi in interface com.github.tommyettinger.crux.Point4<Point4Int>
    • y

      public float y()
      Specified by:
      y in interface com.github.tommyettinger.crux.Point4<Point4Int>
    • y

      public Point4Int y(float next)
      Specified by:
      y in interface com.github.tommyettinger.crux.Point4<Point4Int>
    • yi

      public int yi()
      Specified by:
      yi in interface com.github.tommyettinger.crux.Point4<Point4Int>
    • yi

      public Point4Int yi(int next)
      Specified by:
      yi in interface com.github.tommyettinger.crux.Point4<Point4Int>
    • z

      public float z()
      Specified by:
      z in interface com.github.tommyettinger.crux.Point4<Point4Int>
    • z

      public Point4Int z(float next)
      Specified by:
      z in interface com.github.tommyettinger.crux.Point4<Point4Int>
    • zi

      public int zi()
      Specified by:
      zi in interface com.github.tommyettinger.crux.Point4<Point4Int>
    • zi

      public Point4Int zi(int next)
      Specified by:
      zi in interface com.github.tommyettinger.crux.Point4<Point4Int>
    • w

      public float w()
      Specified by:
      w in interface com.github.tommyettinger.crux.Point4<Point4Int>
    • w

      public Point4Int w(float next)
      Specified by:
      w in interface com.github.tommyettinger.crux.Point4<Point4Int>
    • wi

      public int wi()
      Specified by:
      wi in interface com.github.tommyettinger.crux.Point4<Point4Int>
    • wi

      public Point4Int wi(int next)
      Specified by:
      wi in interface com.github.tommyettinger.crux.Point4<Point4Int>
    • set

      public Point4Int set(float x, float y, float z, float w)
      Specified by:
      set in interface com.github.tommyettinger.crux.Point4<Point4Int>
    • set

      public Point4Int set(int x, int y, int z, int w)
    • add

      public Point4Int add(float x, float y, float z, float w)
    • sub

      public Point4Int sub(float x, float y, float z, float w)
    • subtract

      public Point4Int subtract(float x, float y, float z, float w)
    • scl

      public Point4Int scl(float scalar)
    • scale

      public Point4Int scale(float scalar)
    • scl

      public Point4Int scl(float x, float y, float z, float w)
    • scale

      public Point4Int scale(float x, float y, float z, float w)
    • mul

      public Point4Int mul(float scalar)
      Multiplies each component of this by the given scalar, in-place, and returns this. This is an alias for scl(float).
      Parameters:
      scalar - a float that will be multiplied with each component
      Returns:
      this, for chaining
    • multiply

      public Point4Int multiply(float scalar)
      Multiplies each component of this by the given scalar, in-place, and returns this. This is an alias for scl(float).
      Parameters:
      scalar - a float that will be multiplied with each component
      Returns:
      this, for chaining
    • mul

      public Point4Int mul(float x, float y, float z, float w)
      Multiplies each component of this by the corresponding scalar, in-place, and returns this. This is an alias for scl(float, float, float, float).
      Parameters:
      x - a float that will be multiplied with x
      y - a float that will be multiplied with y
      Returns:
      this, for chaining
    • multiply

      public Point4Int multiply(float x, float y, float z, float w)
      Multiplies each component of this by the corresponding scalar, in-place, and returns this. This is an alias for scl(float, float, float, float).
      Parameters:
      x - a float that will be multiplied with x
      y - a float that will be multiplied with y
      Returns:
      this, for chaining
    • add

      public Point4Int add(int x, int y, int z, int w)
    • sub

      public Point4Int sub(int x, int y, int z, int w)
    • subtract

      public Point4Int subtract(int x, int y, int z, int w)
    • plus

      public Point4Int plus(float scalar)
      Specified by:
      plus in interface com.github.tommyettinger.crux.PointN<Point4Int>
    • minus

      public Point4Int minus(float scalar)
      Specified by:
      minus in interface com.github.tommyettinger.crux.PointN<Point4Int>
    • times

      public Point4Int times(float scalar)
      Specified by:
      times in interface com.github.tommyettinger.crux.PointN<Point4Int>
    • scl

      public Point4Int scl(int scalar)
    • scale

      public Point4Int scale(int scalar)
    • scl

      public Point4Int scl(int x, int y, int z, int w)
    • scale

      public Point4Int scale(int x, int y, int z, int w)
    • mul

      public Point4Int mul(int scalar)
      Multiplies each component of this by the given scalar, in-place, and returns this. This is an alias for scl(int).
      Parameters:
      scalar - an int that will be multiplied with each component
      Returns:
      this, for chaining
    • multiply

      public Point4Int multiply(int scalar)
      Multiplies each component of this by the given scalar, in-place, and returns this. This is an alias for scl(int).
      Parameters:
      scalar - an int that will be multiplied with each component
      Returns:
      this, for chaining
    • mul

      public Point4Int mul(int x, int y, int z, int w)
      Multiplies each component of this by the corresponding scalar, in-place, and returns this. This is an alias for scl(int, int, int, int).
      Parameters:
      x - an int that will be multiplied with x
      y - an int that will be multiplied with y
      Returns:
      this, for chaining
    • multiply

      public Point4Int multiply(int x, int y, int z, int w)
      Multiplies each component of this by the corresponding scalar, in-place, and returns this. This is an alias for scl(int, int, int, int).
      Parameters:
      x - an int that will be multiplied with x
      y - an int that will be multiplied with y
      Returns:
      this, for chaining
    • div

      public Point4Int div(Point4Int point)
      Specified by:
      div in interface com.github.tommyettinger.crux.PointN<Point4Int>
    • divide

      public Point4Int divide(float scalar)
      Specified by:
      divide in interface com.github.tommyettinger.crux.PointN<Point4Int>
    • addProduct

      public Point4Int addProduct(com.github.tommyettinger.crux.Point4<?> vec, float scalar)
    • mulAdd

      public Point4Int mulAdd(com.github.tommyettinger.crux.Point4<?> vec, float scalar)
    • mulAdd

      public Point4Int mulAdd(com.github.tommyettinger.crux.Point4<?> vec, com.github.tommyettinger.crux.Point4<?> mulVec)
    • addProduct

      public Point4Int addProduct(com.github.tommyettinger.crux.Point4<?> vec, com.github.tommyettinger.crux.Point4<?> mulVec)
    • limit

      public Point4Int limit(float limit)
    • limit2

      public Point4Int limit2(float limit2)
    • limitSquared

      public Point4Int limitSquared(float limit2)
    • clampLength

      public Point4Int clampLength(float min, float max)
    • setLength

      public Point4Int setLength(float len)
    • setLength2

      public Point4Int setLength2(float len2)
    • dot

      public float dot(com.github.tommyettinger.crux.Point4<?> other)
    • dot

      public static float dot(com.github.tommyettinger.crux.Point4<?> a, com.github.tommyettinger.crux.Point4<?> b)
    • lerp

      public Point4Int lerp(com.github.tommyettinger.crux.Point4<?> target, float alpha)
      Description copied from interface: PointNInt
      Linear-interpolates from this point toward target, moving a distance proportional to alpha and changing this point in-place if possible. If this point is not PointN.mutable(), this will return a new or pooled point. The alpha is expected to be in the 0 to 1 range, inclusive.
      Specified by:
      lerp in interface com.github.tommyettinger.crux.PointNInt<Point4Int, com.github.tommyettinger.crux.Point4<?>>
      Specified by:
      lerp in interface PointNInt<Point4Int, com.github.tommyettinger.crux.Point4<?>>
      Parameters:
      target - any point with the same dimension to move toward
      alpha - between 0 and 1, inclusive
      Returns:
      this point after modifications, if possible, or a new PointNInt if this is immutable
    • interpolate

      public Point4Int interpolate(com.github.tommyettinger.crux.Point4<?> target, float alpha, com.github.tommyettinger.digital.Interpolations.Interpolator interpolation)
      Description copied from interface: PointNInt
      Calls PointNInt.lerp(PointN, float) with the alpha determined by the given interpolation. Simply returns lerp(target, interpolation.apply(alpha)) .
      Specified by:
      interpolate in interface PointNInt<Point4Int, com.github.tommyettinger.crux.Point4<?>>
      Parameters:
      target - any point with the same dimension to move toward
      alpha - between 0 and 1, inclusive
      interpolation - an Interpolator from digital, such as Interpolations.smooth
      Returns:
      this point after modifications, if possible, or a new PointNInt if this is immutable
    • clampEach

      public Point4Int clampEach(int min, int max)
      For each component, this clamps it between min and max, inclusive.
      Parameters:
      min - the minimum value allowable for any component, inclusive
      max - the maximum value allowable for any component, inclusive
      Returns:
      this, after modifications
    • get

      public int get(int index)
      Gets the component at the specified index. Kotlin-compatible using square-bracket indexing.
      Specified by:
      get in interface com.github.tommyettinger.crux.PointNInt<Point4Int, com.github.tommyettinger.crux.Point4<?>>
      Specified by:
      get in interface PointNInt<Point4Int, com.github.tommyettinger.crux.Point4<?>>
      Parameters:
      index - which component to get, in order
      Returns:
      the component
    • setAt

      public Point4Int setAt(int index, int value)
      Sets the component at the specified index to the specified value.
      Specified by:
      setAt in interface com.github.tommyettinger.crux.PointNInt<Point4Int, com.github.tommyettinger.crux.Point4<?>>
      Specified by:
      setAt in interface PointNInt<Point4Int, com.github.tommyettinger.crux.Point4<?>>
      Parameters:
      index - which component to set, in order
      value - the value to assign at index
      Returns:
      this, for chaining
    • equals

      public boolean equals(Object o)
      Specified by:
      equals in interface com.github.tommyettinger.ds.PrimitiveCollection<Integer>
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface com.github.tommyettinger.ds.PrimitiveCollection<Integer>
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Converts this Point4Int to a string in the format (x,y,z,w).
      Overrides:
      toString in class Object
      Returns:
      a string representation of this object.
    • fromString

      public Point4Int fromString(String s)
      Sets this Point4Int to the value represented by the specified string according to the format of toString().
      Parameters:
      s - the string.
      Returns:
      this point for chaining
    • add

      public boolean add(int c)
      Not supported; this collection is fixed-size.
      Specified by:
      add in interface com.github.tommyettinger.ds.PrimitiveCollection.OfInt
      Parameters:
      c - ignored
      Returns:
      never returns
      Throws:
      UnsupportedOperationException - always
    • remove

      public boolean remove(int c)
      Not supported; this collection is fixed-size.
      Specified by:
      remove in interface com.github.tommyettinger.ds.PrimitiveCollection.OfInt
      Parameters:
      c - ignored
      Returns:
      never returns
      Throws:
      UnsupportedOperationException - always
    • clear

      public void clear()
      Not supported; this collection is fixed-size.
      Specified by:
      clear in interface com.github.tommyettinger.ds.PrimitiveCollection<Integer>
      Throws:
      UnsupportedOperationException - always
    • contains

      public boolean contains(int c)
      Compares c with the components of this collection using ==; if any are considered equal, this returns true.
      Specified by:
      contains in interface com.github.tommyettinger.ds.PrimitiveCollection.OfInt
      Parameters:
      c - an int to be compared using ==
      Returns:
      true if any component of this collection is equal to c via == comparison
    • size

      public int size()
      Specified by:
      size in interface com.github.tommyettinger.ds.PrimitiveCollection<Integer>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface com.github.tommyettinger.ds.PrimitiveCollection<Integer>
    • notEmpty

      public boolean notEmpty()
      Specified by:
      notEmpty in interface com.github.tommyettinger.ds.PrimitiveCollection<Integer>
    • iterator

      public PointNIntIterator iterator()
      Specified by:
      iterator in interface com.github.tommyettinger.ds.PrimitiveCollection<Integer>
      Specified by:
      iterator in interface com.github.tommyettinger.ds.PrimitiveCollection.OfInt