MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / angleCos

Method angleCos

src/main/java/field/linalg/Vec3.java:1191–1196  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 1

angleMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected