Class Vec3


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

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

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

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Vec3 add​(Vec3 other)
      add two vectors (neither will be modified)
      static Vec3 deserialize​(org.json.JSONArray json)
      Parses Vec3 from an json object.
      Vec3 div​(int scale)
      divides vector by a scalar value (this will not be modified)
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      Vec3 mul​(double scale)
      multiply vector by a scalar value (this will not be modified)
      Vec3 negate()
      negates a vector (this will not be modified)
      org.json.JSONArray serialize()
      Serializes a Vec3 to a json object.
      Vec3 sub​(Vec3 other)
      subtract two vectors (neither will be modified)
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • x

        public double x
        x coordinate
      • y

        public double y
        y coordinate
      • z

        public double z
        z coordinate
    • Constructor Detail

      • Vec3

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

      • add

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

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

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

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

        public Vec3 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
      • deserialize

        public static Vec3 deserialize​(org.json.JSONArray json)
        Parses Vec3 from an json object.
        Parameters:
        json - input json
        Returns:
        parsed vector or null on error.
      • serialize

        public org.json.JSONArray serialize()
        Serializes a Vec3 to a json object.
        Returns:
        serialized json object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object