Return the cosine of the angle between this vector and the supplied vector. Use this instead of Math.cos(angle(v)) . @param v the other vector @return the cosine of the angle @see #angle(Vec3)
(Vec3 v)
| 1189 | * @see #angle(Vec3) |
| 1190 | */ |
| 1191 | public double angleCos(Vec3 v) { |
| 1192 | double length1 = Math.sqrt(x * x + y * y + z * z); |
| 1193 | double length2 = Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z); |
| 1194 | double dot = x * v.x + y * v.y + z * v.z; |
| 1195 | return dot / (length1 * length2); |
| 1196 | } |
| 1197 | |
| 1198 | /** |
| 1199 | * Return the angle between this vector and the supplied vector. |