Cody

Problem 558. Is the Point in a Triangle?

Solution 3034195

Submitted on 2 Oct 2020 by ivan fernandez
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
Triangle = [0, 0; 1, 0; 1, 1]; Points = [0, 0.5] y_correct = 0; assert(isequal(your_fcn_name(Points,Triangle),y_correct))

Points = 0 0.5000 szp = 1 2 appartiene = 1 mn = 0 mx = 1 pt1 = 0 0 pt3 = 1 0 pt3 = 1 1 pt2 = 1 0 m1 = 0 q1 = 0 y1 = function_handle with value: @(x)m1*x+q1 m2 = -Inf q2 = Inf y2 = function_handle with value: @(x)m2*x+q2 m3 = 1 q3 = 0 y3 = function_handle with value: @(x)m3*x+q3 sz = 1 2 pt = 0 0.5000 x = 0 y = 0.5000 yv1 = 0 yv2 = NaN yv2 = Inf yv3 = 0 appartiene = 0 appartiene1 = 0

2   Pass
Triangle = [0, 0; 1, 0; 1, 1]; Points = [0.8, 0.5] y_correct = 1; assert(isequal(your_fcn_name(Points,Triangle),y_correct))

Points = 0.8000 0.5000 szp = 1 2 appartiene = 1 mn = 0 mx = 1 pt1 = 0 0 pt3 = 1 0 pt3 = 1 1 pt2 = 1 0 m1 = 0 q1 = 0 y1 = function_handle with value: @(x)m1*x+q1 m2 = -Inf q2 = Inf y2 = function_handle with value: @(x)m2*x+q2 m3 = 1 q3 = 0 y3 = function_handle with value: @(x)m3*x+q3 sz = 1 2 pt = 0.8000 0.5000 x = 0.8000 y = 0.5000 yv1 = 0 yv2 = NaN yv2 = Inf yv3 = 0.8000 appartiene1 = 1

3   Pass
Triangle = [0.8147, 0.9134; 0.9058, 0.6324; 0.1270, 0.0975]; Points = [0.8, 0.7; 0.9, 0.4] y_correct = [1 0]; assert(isequal(your_fcn_name(Points,Triangle),y_correct))

Points = 0.8000 0.7000 0.9000 0.4000 szp = 2 2 appartiene = 1 1 mn = 0.1270 mx = 0.9058 pt3 = 0.9058 0.6324 pt1 = 0.1270 0.0975 pt2 = 0.8147 0.9134 m1 = 1.1864 q1 = -0.0532 y1 = function_handle with value: @(x)m1*x+q1 m2 = -3.0845 q2 = 3.4264 y2 = function_handle with value: @(x)m2*x+q2 m3 = 0.6868 q3 = 0.0103 y3 = function_handle with value: @(x)m3*x+q3 sz = 2 2 pt = 0.8000 0.7000 x = 0.8000 y = 0.7000 yv1 = 0.8960 yv2 = 0.9587 yv3 = 0.5597 pt = 0.9000 0.4000 x = 0.9000 y = 0.4000 yv1 = 1.0146 yv2 = 0.6503 yv3 = 0.6284 appartiene = 1 0 appartiene1 = 1 0

Suggested Problems

More from this Author1

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!