Problem 61165. Breaking straight lines
Let P be a point in Oxy plane and let p be a 1×2 array representing an one-degree or zero-degree polynomials, if its first entry is a non-zero constant or a zero constant, respectively.
Break the given line by building a piecewise linear function constituted by two branches:
- one branch stands for the parent polynomial p;
- and another branch stands for the perpendicular line, r, to p that passes by the point P (see figure below).
Given (P, p), find
- R, the breaking point;
- r, the 1×2 array that represents the perpendicular line. If r violates the definition of a function, return r = ''.
input: (P, p)
output: (R, r)
Solution Stats
Problem Comments
-
1 Comment
Matthew Bolyard
on 26 Jan 2026 at 16:16
Running into numerical precision issues again, some testcases are using isequal instead of isapprox :)
Solution Comments
Show commentsProblem Recent Solvers4
Suggested Problems
-
4 Solvers
More from this Author17
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!