We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d33d07d commit 20532a6Copy full SHA for 20532a6
sources/net.sf.j2s.java.core/src/javajs/util/V3d.java
@@ -90,4 +90,17 @@ public final double length() {
90
return Math.sqrt(lengthSquared());
91
}
92
93
+ public final double angle(V3d v1) {
94
+ // return (double)Math.acos(dot(v1)/v1.length()/v.length());
95
+ // Numerically, near 0 and PI are very bad condition for acos.
96
+ // In 3-space, |atan2(sin,cos)| is much stable.
97
+
98
+ double xx = y * v1.z - z * v1.y;
99
+ double yy = z * v1.x - x * v1.z;
100
+ double zz = x * v1.y - y * v1.x;
101
+ double cross = Math.sqrt(xx * xx + yy * yy + zz * zz);
102
103
+ return Math.abs(Math.atan2(cross, dot(v1)));
104
+ }
105
106
0 commit comments