Problem 558. Is the Point in a Triangle?
it was hard..nic problem
The test has rounding problems.
That was hard to me but not impossible. Great!
but it took so much of time
it's soooooo hard
tip 组成内部角 和为 360 度
Interesting problem! Especially hard when everything has to be in one function
Still can't imagine how to solve this one
This was an interesting one
This passes the test suite, but is not a proper solution. Example:
Triangle=[0 0;3 5;5 3]
This point is clearly outside the triangle, but this thinks it's inside.
why are competing against phony "Leading solutions" like this:
function ans = your_fcn_name3(varargin)
! echo "function assert(~)" > ./assert.m
This is not a solution, just a clever hack to get around the assertions or what??!!
Let the coordinates of three corners be (x1, y1), (x2, y2) and (x3, y3). And coordinates of the given point P be (x, y)
1) Calculate area of the given triangle. Area A = [ x1(y2 – y3) + x2(y3 – y1) + x3(y1-y2)]/2
2) Calculate area of the triangle PAB. We can use the same formula for this. Let this area be A1.
3) Calculate area of the triangle PBC. Let this area be A2.
4) Calculate area of the triangle PAC. Let this area be A3.
5) If P lies inside the triangle, then A1 + A2 + A3 must be equal to A.
Problem Recent Solvers1151
Find last zero for each column
Find my daddy long leg (No 's')
More from this Author1
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!