Problem 2083. Independent direction vectors of a plane
Solution Stats
Problem Comments
-
10 Comments
For the vectors to be independent, the test suite should have assert(dot(v1,v2)==0).
instead of assert(dot(v1,v2)~=0) ...
I agree. First, I did not succeed for that reason.
I am curious about the 26-node solution.
This is unfortunately suffering from many issues.
1. Many cases (planes parallel to one or two axes) aren't covered in the test suite.
2. Exact equality tests are used for floating-point comparisons, which can lead to spurious failures.
3. assert(dot(v1, v2) ~= 0) doesn't make sense, as remarked.
4. Neither would assert(dot(v1, v2) == 0), however, since the direction vectors are required to be (linearly) independent, not orthogonal.
Christian, I think the assertion dot(v1,v2)~=0 is placed to ensure that the two vectors are not parallel and therefore are independent.
I have modified the assert conditions and added some test cases to reflect planes parallel to axis/axes.
Thank you, Dyuman!
The test suite doesn't work for me?!
I think it should be -2d not only -d:
assert(abs(sum([a b c].*(v1+[0 0 d/c]))-2d)<1e-4)
And it could be way more readable:
assert(abs(a*v1(1) + b*v1(2) + c*v1(3) - d) < 1e-4)
How did some people solve this?!?
yup
nice
Solution Comments
Show commentsProblem Recent Solvers23
Suggested Problems
-
Find the longest sequence of 1's in a binary sequence.
6659 Solvers
-
Return the largest number that is adjacent to a zero
5507 Solvers
-
Find the peak 3n+1 sequence value
2564 Solvers
-
Generate N equally spaced intervals between -L and L
935 Solvers
-
Right Triangle Side Lengths (Inspired by Project Euler Problem 39)
2027 Solvers
More from this Author10
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!