Package healpix.essentials

## Class Vec3

- java.lang.Object
- - healpix.essentials.Vec3

    public class Vec3
    extends java.lang.Object

Cartesian 3-vector. Instead of using the javax.vecmath.Vector3d class, this separate class was implemented for two reasons: first, to avoid the external dependency from vecmath.jar, and also because the function Vector3d.angle(Vector3d v1) is too inaccurate for usage in Healpix for very small angles.

### Field Summary

Fields
`double` `x`
`double` `y`
`double` `z`

### Constructor Summary

Constructors
`Vec3()` Default constructor.
`Vec3​(double[] arr)`
`Vec3​(double x1, double y1, double z1)` Creation from individual components
`Vec3​(Pointing ptg)` Conversion from `Pointing`
`Vec3​(Vec3 v)`
`Vec3​(Zphi zphi)` Conversion from `Zphi`

### Method Summary

All Methods Instance Methods Concrete Methods
`Vec3` `add​(Vec3 v)` Vector addition
`double` `angle​(Vec3 v1)` Angle between two vectors.
`Vec3` `cross​(Vec3 v)` Vector cross product.
`double` `dot​(Vec3 v1)` Computes the dot product of the this vector and `v1`.
`boolean` `equals​(java.lang.Object o)`
`void` `flip()` Invert the signs of all components
`Vec3` `flipped()`
`int` `hashCode()`
`double` `length()` Vector length
`double` `lengthSquared()` Squared vector length
`Vec3` `mul​(double n)` Vector scaling.
`Vec3` `norm()` Return normalized vector
`void` `normalize()` Normalize the vector
`void` `scale​(double n)` Scale the vector by a given factor
`Vec3` `sub​(Vec3 v)` Vector subtraction
`double[]` `toArray()`
`void` `toArray​(double[] arr)`
`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

#### y

    public double y

#### z

    public double z

### Constructor Detail

#### Vec3

    public Vec3()

Default constructor.

#### Vec3

    public Vec3​(Vec3 v)

#### Vec3

    public Vec3​(double x1,
                double y1,
                double z1)

Creation from individual components

#### Vec3

    public Vec3​(Pointing ptg)

Conversion from `Pointing`

#### Vec3

    public Vec3​(Zphi zphi)

Conversion from `Zphi`

#### Vec3

    public Vec3​(double[] arr)

### Method Detail

#### length

    public final double length()

Vector length

Returns:
  the length of the vector.

#### lengthSquared

    public final double lengthSquared()

Squared vector length

Returns:
  the squared length of the vector.

#### normalize

    public void normalize()

Normalize the vector

#### norm

    public Vec3 norm()

Return normalized vector

#### angle

    public final double angle​(Vec3 v1)

Angle between two vectors.

Parameters:
  `v1` - another vector
Returns:
  the angle in radians between this vector and `v1`; constrained to the range [0,PI].

#### cross

    public Vec3 cross​(Vec3 v)

Vector cross product.

Parameters:
  `v` - another vector
Returns:
  the vector cross product between this vector and `v`

#### mul

    public Vec3 mul​(double n)

Vector scaling.

Parameters:
  `n` - the scale number to be multiply to the coordinates `x,y,z`
Returns:
  the vector with coordinates multiplied by `n`

#### flip

    public void flip()

Invert the signs of all components

#### flipped

    public Vec3 flipped()

#### scale

    public void scale​(double n)

Scale the vector by a given factor

Parameters:
  `n` - the scale factor

#### dot

    public final double dot​(Vec3 v1)

Computes the dot product of the this vector and `v1`.

Parameters:
  `v1` - another vector
Returns:
  dot product

#### add

    public Vec3 add​(Vec3 v)

Vector addition

Parameters:
  `v` - the vector to be added
Returns:
  addition result

#### sub

    public Vec3 sub​(Vec3 v)

Vector subtraction

Parameters:
  `v` - the vector to be subtracted
Returns:
  subtraction result

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `java.lang.Object`

#### toArray

    public double[] toArray()

#### toArray

    public void toArray​(double[] arr)

#### equals

    public boolean equals​(java.lang.Object o)

Overrides:
  `equals` in class `java.lang.Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `java.lang.Object`