回答編集履歴

1

2023/02/05 15:30

投稿

melian
melian

スコア19618

test CHANGED
@@ -1,14 +1,9 @@
1
1
  題意を満たしているかどうかは判りませんが、こんな感じで。
2
2
  ```java
3
- public double Norm(){
4
- return Math.sqrt(this.InProd(this));
5
- }
6
-
7
- public double angle(vector v){
3
+ public double angle(vector v){
8
4
  double theta;
9
- // theta = this.InProd(v)/Math.sqrt(this.InProd(this)*v.InProd(v));
5
+ vector vNorm = this.mul(Math.sqrt(v.InProd(v)));
10
- // theta = Math.acos(theta);
11
- theta = Math.acos(this.InProd(v) / this.mul(v.Norm()).Norm());
6
+ theta = Math.acos(this.InProd(v) / Math.sqrt(vNorm.InProd(vNorm)));
12
7
  theta = theta * 180.0 / Math.PI;
13
8
  return theta;
14
9
  }