We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Instead of the plane intersection method, should use vector math for finding the nearest point on skew vectors, something like:
pub fn nearest_point(&self, other: &Ray) -> Option<Vec3> { let delta_p = other.origin - self.origin; let v1_squared = self.direction.dot(self.direction); let v2_squared = other.direction.dot(other.direction); let v1_dot_v2 = self.direction.dot(other.direction); let determinant = v1_dot_v2.powi(2) - v1_squared * v2_squared; if determinant.abs() > f32::MIN { let delta_p_v1 = delta_p.dot(self.direction); let delta_p_v2 = delta_p.dot(other.direction); let t = (1.0 / determinant) * (v2_squared * delta_p_v1 - v1_dot_v2 * delta_p_v2); let result = self.origin + self.direction * t; Some(result) } else { // The lines are parallel! None } }
This should be more robust to camera view changes and translating at far distances with perspective cameras.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Instead of the plane intersection method, should use vector math for finding the nearest point on skew vectors, something like:
This should be more robust to camera view changes and translating at far distances with perspective cameras.
The text was updated successfully, but these errors were encountered: