Guest User

Vector3f.java

a guest
Aug 13th, 2012
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.37 KB | None | 0 0
  1. package elec0.utils;
  2.  
  3. public class Vector3f
  4. {
  5.     private float x, y, z;
  6.    
  7.     public Vector3f() { }
  8.     public Vector3f(float x, float y, float z)
  9.     {this.x = x; this.y = y; this.z = z;}
  10.    
  11.     public float getX()
  12.     {return x;}
  13.     public float getY()
  14.     {return y;}
  15.     public float getZ()
  16.     {return z;}
  17.    
  18.     public void setX(float x)
  19.     {this.x = x;}
  20.     public void setY(float y)
  21.     {this.y = y;}
  22.     public void setZ(float z)
  23.     {this.z = z;}
  24.     public void set(Vector3f toSet)
  25.     {x = toSet.getX();y = toSet.getY();z = toSet.getZ();}
  26.     public void set(float x, float y, float z)
  27.     {this.x = x; this.y = y; this.z = z;}
  28.    
  29.     public void addToX(float x)
  30.     {this.x += x;}
  31.     public void addToY(float y)
  32.     {this.y += y;}
  33.     public void addToZ(float z)
  34.     {this.z += z;}
  35.     public void addTo(Vector3f addTo)
  36.     {x += addTo.getX();y += addTo.getY();z += addTo.getZ();}
  37.     public void addTo(float x, float y, float z)
  38.     {this.x += x; this.y += y; this.z += z;}
  39.    
  40.     static public Vector3f subtractVector3f(Vector3f first, Vector3f second)
  41.     {return new Vector3f(first.getX() - second.getX(), first.getY() - second.getY(), first.getZ() - second.getZ());}
  42.    
  43.     static public float innerProduct(Vector3f first, Vector3f second)
  44.     {
  45.         return (first.getX()*second.getX() + first.getY()*second.getY() + first.getZ()*second.getZ());
  46.     }
  47.    
  48.     public String getDebug()
  49.     {
  50.         return ("x: " + x + ", y: " + y + ", z: " + z);
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment