Skip to content
New issue

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

vector3: return w1 not zero vector #20369

Merged
merged 2 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/AP_Math/tests/test_3d_lines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ TEST(Lines3dTests, ClosestDistBetweenLinePoint)

// check protection agains null length
const Vector3f intersection_null = Vector3f::point_on_line_closest_to_other_point(Vector3f{1.0f, 1.0f, 1.0f}, Vector3f{1.0f, 1.0f, 1.0f}, Vector3f{0.0f, 5.0f, 5.0f});
EXPECT_VECTOR3F_EQ((Vector3f{0.0f, 0.0f, 0.0f}), intersection_null);
EXPECT_VECTOR3F_EQ((Vector3f{1.0f, 1.0f, 1.0f}), intersection_null);
}

TEST(Lines3dTests, SegmentToSegmentCloestPoint)
Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_Math/vector3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ Vector3<T> Vector3<T>::point_on_line_closest_to_other_point(const Vector3<T> &w1
const T line_vec_len = line_vec.length();
// protection against divide by zero
if(::is_zero(line_vec_len)) {
return {0.0f, 0.0f, 0.0f};
return w1;
}

const T scale = 1/line_vec_len;
Expand Down