## core.math Class Vec3

```java.lang.Object core.math.Vec3
```

public class Vec3
extends java.lang.Object

Store and operate on a 3-dimensional vector = < (x, y, z) >. This class stores and operates on a 3-dimensional vector. Methods that begin with a capital letter modify 'this', while methods that begin with a lowercase letter create a new Vec3 to store the result.

Version:
1.0
Author:
Andreas Sundquist

 Field Summary `static Vec3[]` `Cartesian`           should not be modified Cartesian array of the cartesian axes `static Vec3` `Invalid`           should not be modified Invalid = an invalid Vec3 `static double` `tolerance`           should not be modified tolerance the per-component zero-value maximum ` double` `x`           x, y, and z are the components of this vector `static Vec3` `Xhat`           should not be modified Xhat = the unit x-axis ` double` `y`           x, y, and z are the components of this vector `static Vec3` `Yhat`           should not be modified Yhat = the unit x-axis ` double` `z`           x, y, and z are the components of this vector `static Vec3` `Zero`           should not be modified Zero = the zero vector `static Vec3` `Zhat`           should not be modified Zhat = the unit x-axis

 Constructor Summary `Vec3()`           Constructs a new Vec3 = (0, 0, 0) ```Vec3(double x, double y, double z)```           Constructs a new Vec3 = (x, y, z) `Vec3(Vec v)`           Constructs a new Vec3 = 'v' Requires: 'v' has dimension 3 `Vec3(Vec3 v)`           Constructs a new Vec2 = 'v'

 Method Summary ` Vec3` ```add(double x, double y, double z)```           Returns: a new Vec3 that is the sum of 'this' and (x, y, z) ` Vec3` ```Add(double x, double y, double z)```           Adds (x, y, z) to 'this' Returns: resulting 'this' ` Vec3` `add(Vec3 v)`           Returns: a new Vec3 that is the sum of 'this' and 'v' ` Vec3` `Add(Vec3 v)`           Adds 'v' to 'this' Returns: resulting 'this' ` Vec3` ```addscaled(double x, double y, double z, double s)```           Returns: a new Vecc3 that is the sum of 'this' and 's * (x, y, z)' ` Vec3` ```AddScaled(double x, double y, double z, double s)```           Adds 's * (x, y, z)' to 'this' Returns: resulting 'this' ` Vec3` ```addscaled(Vec3 v, double s)```           Returns: a new Vec3 that is the sum of 'this' and 's*v' ` Vec3` ```AddScaled(Vec3 v, double s)```           Adds 's*v' to 'this' Returns: resulting 'this' ` Vec3` `copy()`           Returns a copy of 'this' ` Vec3` `cross(Vec3 b)`           Returns: a new Vec3 that is the cross product of 'this' and 'b' ` Vec3` `Cross(Vec3 b)`           Sets 'this' to be the cross product of 'this' and 'b' Returns: resulting 'this' ` Vec3` ```Cross(Vec3 a, Vec3 b)```           Sets 'this' to be the cross product of 'a' and 'b' Returns: resulting 'this' ` double` ```dot(double x, double y, double z)```           Returns: the dot product of 'this' and (x, y, z) ` double` `dot(Vec3 v)`           Returns: the dot product of 'this' and 'v' ` boolean` `equals(Vec3 v)`           Returns: true if 'this' equals 'v', false otherwise ` Vec3` `getNew()`           Returns a new Vec2 = (0, 0, 0) ` boolean` `isZero()`           Returns: true if 'this' is zero, false otherwise ` double` `len()`           Returns: the magnitude of 'this' ` double` `len2()`           Returns: the magnitude squared of 'this' ` double` `len3()`           Returns: the magnitude cubed of 'this' ` Vec3` `neg()`           Returns: a new Vec3 that is the opposite of 'this' ` Vec3` `Neg()`           Negates 'this' Returns: resulting 'this' ` Vec3` `para(Vec3 d)`           Returns: a new Vec3 that is the component of 'this' parallel to 'd' Requires: 'd' is not zero ` Vec3` `Para(Vec3 d)`           Isolates the component of 'this' parallel to 'd' Returns: resulting 'this' Requires: 'd' is not zero ` Vec3` `paraunit(Vec3 d)`           Returns: a new Vec3 that is the component of 'this' parallel to 'd' Requires: 'd' has unit magnitude ` Vec3` `ParaUnit(Vec3 d)`           Isolates the component of 'this' parallel to 'd' Returns: resulting 'this' Requires: 'd' has unit magnitude ` Vec3` `perp(Vec3 d)`           Returns: a new Vec2 that is the component of 'this' perpendicular to 'd' Requires: 'd' is not zero ` Vec3` `Perp(Vec3 d)`           Isolates the component of 'this' perpendicular to 'd' Returns: resulting 'this' Requires: 'd' is not zero ` Vec3` `perpunit(Vec3 d)`           Returns: a new Vec3 that is the component of 'this' perpendicular to 'd' Requires: 'd' has unit magnitude ` Vec3` `PerpUnit(Vec3 d)`           Isolates the component of 'this' perpendicular to 'd' Returns: resulting 'this' Requires: 'd' has unit magnitude ` Vec3` `scale(double s)`           Returns: a new Vec3 that is 's*this' ` Vec3` `Scale(double s)`           Scales 'this' by 's' Returns: resulting 'this' ` Vec3` `scale(Vec3 v)`           Returns: a new Vec3 that is 'this' with its components scaled by 'v' ` Vec3` `Scale(Vec3 v)`           Scales each component of 'this' by the corresponding component of 'v' Returns: resulting 'this' ` Vec3` ```Set(double x, double y, double z)```           Sets 'this' to (x, y, z) Returns: resulting 'this' ` Vec3` `Set(Vec v)`           Sets 'this' to 'v' Returns: resulting 'this' Requires: 'v' has dimension 3 ` Vec3` `Set(Vec3 v)`           Sets the value of 'this' to that of 'v' Returns: resulting 'this' ` Vec3` `SetZero()`           Sets 'this' to zero Returns: resulting 'this' ` Vec3` ```sub(double x, double y, double z)```           Returns: a new Vec3 that is the difference between 'this' and (x, y, z) ` Vec3` ```Sub(double x, double y, double z)```           Subtracts (x, y, z) from 'this' Returns: resulting 'this' ` Vec3` `sub(Vec3 v)`           Returns: a new Vec3 that is the difference between 'this' and 'v' ` Vec3` `Sub(Vec3 v)`           Subtracts 'v' from 'this' Returns: resulting 'this' ` Vec` `toVec()`           Returns: a new Vec that is < 3, 'this' > ` javax.vecmath.Vector3d` `toVector3d()`           Returns: a new Vector3d that equals 'this' ` javax.vecmath.Vector3f` `toVector3f()`           Returns: a new Vector3f that equals 'this' ` Vec3` `unit()`           Returns: a new Vec3 that is 'this' scaled to unit magnitude Requires: 'this' is not zero ` Vec3` `Unit()`           Rescales 'this' to be of unit magnitude Returns: resulting 'this' Requires: 'this' is not zero

 Methods inherited from class java.lang.Object `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

 Field Detail

### x

`public double x`
x, y, and z are the components of this vector

### y

`public double y`
x, y, and z are the components of this vector

### z

`public double z`
x, y, and z are the components of this vector

### Zero

`public static Vec3 Zero`
should not be modified Zero = the zero vector

### Xhat

`public static Vec3 Xhat`
should not be modified Xhat = the unit x-axis

### Yhat

`public static Vec3 Yhat`
should not be modified Yhat = the unit x-axis

### Zhat

`public static Vec3 Zhat`
should not be modified Zhat = the unit x-axis

### Cartesian

`public static Vec3[] Cartesian`
should not be modified Cartesian array of the cartesian axes

### Invalid

`public static Vec3 Invalid`
should not be modified Invalid = an invalid Vec3

### tolerance

`public static double tolerance`
should not be modified tolerance the per-component zero-value maximum

 Constructor Detail

### Vec3

`public Vec3()`
Constructs a new Vec3 = (0, 0, 0)

### Vec3

`public Vec3(Vec3 v)`
Constructs a new Vec2 = 'v'

### Vec3

```public Vec3(double x,
double y,
double z)```
Constructs a new Vec3 = (x, y, z)

### Vec3

`public Vec3(Vec v)`
Constructs a new Vec3 = 'v' Requires: 'v' has dimension 3

 Method Detail

### getNew

`public Vec3 getNew()`
Returns a new Vec2 = (0, 0, 0)

### copy

`public Vec3 copy()`
Returns a copy of 'this'

### Set

`public Vec3 Set(Vec3 v)`
Sets the value of 'this' to that of 'v' Returns: resulting 'this'

### Set

```public Vec3 Set(double x,
double y,
double z)```
Sets 'this' to (x, y, z) Returns: resulting 'this'

### Set

`public Vec3 Set(Vec v)`
Sets 'this' to 'v' Returns: resulting 'this' Requires: 'v' has dimension 3

### SetZero

`public Vec3 SetZero()`
Sets 'this' to zero Returns: resulting 'this'

### isZero

`public boolean isZero()`
Returns: true if 'this' is zero, false otherwise

### equals

`public boolean equals(Vec3 v)`
Returns: true if 'this' equals 'v', false otherwise

### Add

`public Vec3 Add(Vec3 v)`
Adds 'v' to 'this' Returns: resulting 'this'

### Add

```public Vec3 Add(double x,
double y,
double z)```
Adds (x, y, z) to 'this' Returns: resulting 'this'

### add

`public Vec3 add(Vec3 v)`
Returns: a new Vec3 that is the sum of 'this' and 'v'

### add

```public Vec3 add(double x,
double y,
double z)```
Returns: a new Vec3 that is the sum of 'this' and (x, y, z)

### AddScaled

```public Vec3 AddScaled(Vec3 v,
double s)```
Adds 's*v' to 'this' Returns: resulting 'this'

### AddScaled

```public Vec3 AddScaled(double x,
double y,
double z,
double s)```
Adds 's * (x, y, z)' to 'this' Returns: resulting 'this'

### addscaled

```public Vec3 addscaled(Vec3 v,
double s)```
Returns: a new Vec3 that is the sum of 'this' and 's*v'

### addscaled

```public Vec3 addscaled(double x,
double y,
double z,
double s)```
Returns: a new Vecc3 that is the sum of 'this' and 's * (x, y, z)'

### Sub

`public Vec3 Sub(Vec3 v)`
Subtracts 'v' from 'this' Returns: resulting 'this'

### Sub

```public Vec3 Sub(double x,
double y,
double z)```
Subtracts (x, y, z) from 'this' Returns: resulting 'this'

### sub

`public Vec3 sub(Vec3 v)`
Returns: a new Vec3 that is the difference between 'this' and 'v'

### sub

```public Vec3 sub(double x,
double y,
double z)```
Returns: a new Vec3 that is the difference between 'this' and (x, y, z)

### Neg

`public Vec3 Neg()`
Negates 'this' Returns: resulting 'this'

### neg

`public Vec3 neg()`
Returns: a new Vec3 that is the opposite of 'this'

### dot

`public double dot(Vec3 v)`
Returns: the dot product of 'this' and 'v'

### dot

```public double dot(double x,
double y,
double z)```
Returns: the dot product of 'this' and (x, y, z)

### len

`public double len()`
Returns: the magnitude of 'this'

### len2

`public double len2()`
Returns: the magnitude squared of 'this'

### len3

`public double len3()`
Returns: the magnitude cubed of 'this'

### Scale

`public Vec3 Scale(double s)`
Scales 'this' by 's' Returns: resulting 'this'

### scale

`public Vec3 scale(double s)`
Returns: a new Vec3 that is 's*this'

### Scale

`public Vec3 Scale(Vec3 v)`
Scales each component of 'this' by the corresponding component of 'v' Returns: resulting 'this'

### scale

`public Vec3 scale(Vec3 v)`
Returns: a new Vec3 that is 'this' with its components scaled by 'v'

### Unit

`public Vec3 Unit()`
Rescales 'this' to be of unit magnitude Returns: resulting 'this' Requires: 'this' is not zero

### unit

`public Vec3 unit()`
Returns: a new Vec3 that is 'this' scaled to unit magnitude Requires: 'this' is not zero

### Cross

`public Vec3 Cross(Vec3 b)`
Sets 'this' to be the cross product of 'this' and 'b' Returns: resulting 'this'

### Cross

```public Vec3 Cross(Vec3 a,
Vec3 b)```
Sets 'this' to be the cross product of 'a' and 'b' Returns: resulting 'this'

### cross

`public Vec3 cross(Vec3 b)`
Returns: a new Vec3 that is the cross product of 'this' and 'b'

### Para

`public Vec3 Para(Vec3 d)`
Isolates the component of 'this' parallel to 'd' Returns: resulting 'this' Requires: 'd' is not zero

### para

`public Vec3 para(Vec3 d)`
Returns: a new Vec3 that is the component of 'this' parallel to 'd' Requires: 'd' is not zero

### ParaUnit

`public Vec3 ParaUnit(Vec3 d)`
Isolates the component of 'this' parallel to 'd' Returns: resulting 'this' Requires: 'd' has unit magnitude

### paraunit

`public Vec3 paraunit(Vec3 d)`
Returns: a new Vec3 that is the component of 'this' parallel to 'd' Requires: 'd' has unit magnitude

### Perp

`public Vec3 Perp(Vec3 d)`
Isolates the component of 'this' perpendicular to 'd' Returns: resulting 'this' Requires: 'd' is not zero

### perp

`public Vec3 perp(Vec3 d)`
Returns: a new Vec2 that is the component of 'this' perpendicular to 'd' Requires: 'd' is not zero

### PerpUnit

`public Vec3 PerpUnit(Vec3 d)`
Isolates the component of 'this' perpendicular to 'd' Returns: resulting 'this' Requires: 'd' has unit magnitude

### perpunit

`public Vec3 perpunit(Vec3 d)`
Returns: a new Vec3 that is the component of 'this' perpendicular to 'd' Requires: 'd' has unit magnitude

### toVec

`public Vec toVec()`
Returns: a new Vec that is < 3, 'this' >

### toVector3d

`public javax.vecmath.Vector3d toVector3d()`
Returns: a new Vector3d that equals 'this'

### toVector3f

`public javax.vecmath.Vector3f toVector3f()`
Returns: a new Vector3f that equals 'this'