Esempio n. 1
0
// AngleTheta returns the angle theta between Vector A and Vector B using the dot product
func AngleTheta(vectorA ct.Vector, vectorB ct.Vector) (float64, error) {
	normA := vectorA.Norm()
	normB := vectorB.Norm()

	if normA == 0 || normB == 0 {
		return nil, errors.New("Either Vector A or Vector B is the zero vector")
	}

	dotProduct, err := InnerProduct(vectorA, vectorB)

	if err != nil {
		return nil, err
	}

	theta := math.Acos(dotProduct / (normA * normB))

	return theta
}