Package r3 provides 3D vectors and boxes and operations on them.



    This section is empty.


    This section is empty.


    func Cos

    func Cos(p, q Vec) float64

      Cos returns the cosine of the opening angle between p and q.

      func Norm

      func Norm(p Vec) float64

        Norm returns the Euclidean norm of p

        |p| = sqrt(p_x^2 + p_y^2 + p_z^2).

        func Norm2

        func Norm2(p Vec) float64

          Norm returns the Euclidean squared norm of p

          |p|^2 = p_x^2 + p_y^2 + p_z^2.


          type Box

          type Box struct {
          	Min, Max Vec

            Box is a 3D bounding box.

            type Vec

            type Vec struct {
            	X, Y, Z float64

              Vec is a 3D vector.

              func Unit

              func Unit(p Vec) Vec

                Unit returns the unit vector colinear to p. Unit returns {NaN,NaN,NaN} for the zero vector.

                func (Vec) Add

                func (p Vec) Add(q Vec) Vec

                  Add returns the vector sum of p and q.

                  func (Vec) Cross

                  func (p Vec) Cross(q Vec) Vec

                    Cross returns the cross product p×q.

                    func (Vec) Dot

                    func (p Vec) Dot(q Vec) float64

                      Dot returns the dot product p·q.

                      func (Vec) Scale

                      func (p Vec) Scale(f float64) Vec

                        Scale returns the vector p scaled by f.

                        func (Vec) Sub

                        func (p Vec) Sub(q Vec) Vec

                          Sub returns the vector sum of p and -q.

                          Source Files