How to resolve the algorithm Find if a point is within a triangle step by step in the J programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Find if a point is within a triangle step by step in the J programming language
Table of Contents
Problem Statement
Find if a point is within a triangle.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Find if a point is within a triangle step by step in the J programming language
Source code in the j programming language
area=: [:| 0.5-/ .*@,.+. NB. signed area of triangle
I3=: =i.3 NB. identity matrix
inside=: {{ (area y)=+/area"1|:(I3*x)+(1-I3)*y }}
0j0 inside 1.5j2.4 5.1j_3.1 _3.8j1.2
1
0j1 inside 1.5j2.4 5.1j_3.1 _3.8j1.2
1
3j1 inside 1.5j2.4 5.1j_3.1 _3.8j1.2
0
5.414285714285714j14.349206349206348 inside 0.1j1r9 12.5j100r3 25j100r9
1
5.414285714285714j14.349206349206348 inside 0.1j1r9 12.5j100r3 _12.5j100r6
1
You may also check:How to resolve the algorithm Run-length encoding step by step in the SQL programming language
You may also check:How to resolve the algorithm FizzBuzz step by step in the dc programming language
You may also check:How to resolve the algorithm Balanced brackets step by step in the Ring programming language
You may also check:How to resolve the algorithm Regular expressions step by step in the Sather programming language
You may also check:How to resolve the algorithm Hofstadter Figure-Figure sequences step by step in the D programming language