type Vector3 struct {
    X float64    `json:"x"`
    Y float64    `json:"y"`
    Z float64    `json:"z"`
}

func GetAngle(v1 Vector3,v2 Vector3) (angel float64) {
    //求两向量夹角
    a := v1.X * v2.X + v1.Y * v2.Y + v1.Z * v2.Z
    b := math.Sqrt(math.Pow(v1.X,2)+math.Pow(v1.Y,2)+math.Pow(v1.Z,2))*
        math.Sqrt(math.Pow(v2.X,2)+math.Pow(v2.Y,2)+math.Pow(v2.Z,2))
    angel = math.Acos(a/b)
    return
    }

 

相关文章:

  • 2021-07-08
  • 2022-12-23
  • 2021-10-05
  • 2021-05-31
  • 2021-05-29
  • 2021-12-21
  • 2021-11-03
  • 2021-12-05
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
  • 2021-08-17
  • 2021-05-25
  • 2022-12-23
  • 2021-07-21
相关资源
相似解决方案