You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 6, 2022. It is now read-only.
public static void Reject(ref Vector3D vector, ref Vector3D direction, out Vector3D result)
{
// Optimized: float inv_denom = 1.0f / Vector3.Dot(normal, normal);
double invDenom;
Vector3D.Dot(ref direction, ref direction, out invDenom);
invDenom = 1.0 / invDenom;
// meaning invDenom = 1 / b·b = 1 / |b|*|b|*cos(0) = 1 / b^2
// Optimized: float d = Vector3.Dot(normal, p) * inv_denom;
double d;
Vector3D.Dot(ref direction, ref vector, out d);
d = d * invDenom;
// meaning d = a·b * invDenom = a·b / b^2
// Optimized: Vector3 n = normal * inv_denom;
Vector3D n;
n.X = direction.X * invDenom;
n.Y = direction.Y * invDenom;
n.Z = direction.Z * invDenom;
// Optimized: return p - d * n;
result.X = vector.X - d * n.X;
result.Y = vector.Y - d * n.Y;
result.Z = vector.Z - d * n.Z;
// meaning result = a - b * d / b^2 = a - b * a·b / b^4
// where a is the target vector and b is the direction
}
What this does is that it returns a - b * (a·b) / b^4 where a is the target vector and b is the direction vector.
The rejection of vector a from vector b should be a - b * (a · b) / b^2, and the only way the function works is when b^2 =b^4
What this does is that it returns a - b * (a·b) / b^4 where a is the target vector and b is the direction vector.
The rejection of vector a from vector b should be a - b * (a · b) / b^2, and the only way the function works is when b^2 =b^4