Class Point3Int

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

public class Point3Int extends Object implements com.github.tommyettinger.crux.Point3<Point3Int>, PointNInt<Point3Int, com.github.tommyettinger.crux.Point3<?>>, com.github.tommyettinger.ds.PrimitiveCollection.OfInt
A mutable 3D point with int components implementing Point3, 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
     
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    add(float x, float y, float z)
     
    boolean
    add(int c)
    Not supported; this collection is fixed-size.
    add(int x, int y, int z)
     
    add(com.github.tommyettinger.crux.Point3<?> point)
     
    add(Point3Int point)
     
    addProduct(com.github.tommyettinger.crux.Point3<?> vec, float scalar)
     
    addProduct(com.github.tommyettinger.crux.Point3<?> vec, com.github.tommyettinger.crux.Point3<?> 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.Point3<?> point)
     
    int
    distanceSquared(com.github.tommyettinger.crux.Point3<?> point)
     
    div(Point3Int point)
     
    divide(float scalar)
     
    float
    dot(com.github.tommyettinger.crux.Point3<?> other)
     
    static float
    dot(com.github.tommyettinger.crux.Point3<?> a, com.github.tommyettinger.crux.Point3<?> b)
     
    int
    dst2(com.github.tommyettinger.crux.Point3<?> point)
     
    float
    dst2(Point3Int point)
     
    boolean
     
    boolean
    Returns true if this type of point uses float or double for its components, or false otherwise.
    Sets this Point3Int 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.Point3<?> 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.Point3<?> 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)
    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)
    Multiplies each component of this by the corresponding scalar, in-place, and returns this.
    mul(com.github.tommyettinger.crux.Point3<?> point)
     
    mul(Point3Int point)
     
    mulAdd(com.github.tommyettinger.crux.Point3<?> vec, float scalar)
     
    mulAdd(com.github.tommyettinger.crux.Point3<?> vec, com.github.tommyettinger.crux.Point3<?> 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)
    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)
    Multiplies each component of this by the corresponding scalar, in-place, and returns this.
    multiply(com.github.tommyettinger.crux.Point3<?> 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)
     
    scale(int scalar)
     
    scale(int x, int y, int z)
     
    scale(com.github.tommyettinger.crux.Point3<?> point)
     
    scl(float scalar)
     
    scl(float x, float y, float z)
     
    scl(int scalar)
     
    scl(int x, int y, int z)
     
    scl(com.github.tommyettinger.crux.Point3<?> point)
     
    scl(Point3Int point)
     
    set(float x, float y, float z)
     
    set(int x, int y, int z)
     
    set(com.github.tommyettinger.crux.Point3<?> point)
     
    set(Point3Int 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)
     
    sub(int x, int y, int z)
     
    sub(com.github.tommyettinger.crux.Point3<?> point)
     
    sub(Point3Int point)
     
    subtract(float x, float y, float z)
     
    subtract(int x, int y, int z)
     
    subtract(com.github.tommyettinger.crux.Point3<?> point)
     
    times(float scalar)
     
    Converts this Point3Int to a string in the format (x,y,z).
    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.Point3

    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
  • Constructor Details

    • Point3Int

      public Point3Int()
    • Point3Int

      public Point3Int(int x, int y, int z)
    • Point3Int

      public Point3Int(Point3Int p)
    • Point3Int

      public Point3Int(com.github.tommyettinger.crux.Point3<?> 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<Point3Int>
      Specified by:
      floatingPoint in interface com.github.tommyettinger.crux.PointNInt<Point3Int, com.github.tommyettinger.crux.Point3<?>>
      Specified by:
      floatingPoint in interface PointNInt<Point3Int, com.github.tommyettinger.crux.Point3<?>>
      Returns:
      false
    • cpy

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

      public Point3Int copy()
    • len2

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

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

      public Point3Int set(com.github.tommyettinger.crux.Point3<?> point)
    • sub

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

      public Point3Int sub(com.github.tommyettinger.crux.Point3<?> point)
    • subtract

      public Point3Int subtract(com.github.tommyettinger.crux.Point3<?> point)
    • add

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

      public Point3Int add(com.github.tommyettinger.crux.Point3<?> point)
    • scl

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

      public Point3Int scl(com.github.tommyettinger.crux.Point3<?> point)
    • scale

      public Point3Int scale(com.github.tommyettinger.crux.Point3<?> point)
    • mul

      public Point3Int mul(Point3Int point)
    • mul

      public Point3Int mul(com.github.tommyettinger.crux.Point3<?> point)
    • multiply

      public Point3Int multiply(com.github.tommyettinger.crux.Point3<?> point)
    • dst2

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      public Point3Int zi(int next)
      Specified by:
      zi in interface com.github.tommyettinger.crux.Point3<Point3Int>
    • set

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

      public Point3Int set(int x, int y, int z)
    • add

      public Point3Int add(float x, float y, float z)
    • sub

      public Point3Int sub(float x, float y, float z)
    • subtract

      public Point3Int subtract(float x, float y, float z)
    • scl

      public Point3Int scl(float scalar)
    • scale

      public Point3Int scale(float scalar)
    • scl

      public Point3Int scl(float x, float y, float z)
    • scale

      public Point3Int scale(float x, float y, float z)
    • mul

      public Point3Int 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 Point3Int 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 Point3Int mul(float x, float y, float z)
      Multiplies each component of this by the corresponding scalar, in-place, and returns this. This is an alias for scl(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 Point3Int multiply(float x, float y, float z)
      Multiplies each component of this by the corresponding scalar, in-place, and returns this. This is an alias for scl(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 Point3Int add(int x, int y, int z)
    • sub

      public Point3Int sub(int x, int y, int z)
    • subtract

      public Point3Int subtract(int x, int y, int z)
    • plus

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

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

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

      public Point3Int scl(int scalar)
    • scale

      public Point3Int scale(int scalar)
    • scl

      public Point3Int scl(int x, int y, int z)
    • scale

      public Point3Int scale(int x, int y, int z)
    • mul

      public Point3Int 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 Point3Int 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 Point3Int mul(int x, int y, int z)
      Multiplies each component of this by the corresponding scalar, in-place, and returns this. This is an alias for scl(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 Point3Int multiply(int x, int y, int z)
      Multiplies each component of this by the corresponding scalar, in-place, and returns this. This is an alias for scl(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 Point3Int div(Point3Int point)
      Specified by:
      div in interface com.github.tommyettinger.crux.PointN<Point3Int>
    • divide

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

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

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

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

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

      public Point3Int limit(float limit)
    • limit2

      public Point3Int limit2(float limit2)
    • limitSquared

      public Point3Int limitSquared(float limit2)
    • clampLength

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

      public Point3Int setLength(float len)
    • setLength2

      public Point3Int setLength2(float len2)
    • dot

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

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

      public Point3Int lerp(com.github.tommyettinger.crux.Point3<?> 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<Point3Int, com.github.tommyettinger.crux.Point3<?>>
      Specified by:
      lerp in interface PointNInt<Point3Int, com.github.tommyettinger.crux.Point3<?>>
      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 Point3Int interpolate(com.github.tommyettinger.crux.Point3<?> 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<Point3Int, com.github.tommyettinger.crux.Point3<?>>
      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 Point3Int 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<Point3Int, com.github.tommyettinger.crux.Point3<?>>
      Specified by:
      get in interface PointNInt<Point3Int, com.github.tommyettinger.crux.Point3<?>>
      Parameters:
      index - which component to get, in order
      Returns:
      the component
    • setAt

      public Point3Int 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<Point3Int, com.github.tommyettinger.crux.Point3<?>>
      Specified by:
      setAt in interface PointNInt<Point3Int, com.github.tommyettinger.crux.Point3<?>>
      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 Point3Int to a string in the format (x,y,z).
      Overrides:
      toString in class Object
      Returns:
      a string representation of this object.
    • fromString

      public Point3Int fromString(String s)
      Sets this Point3Int 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