Skip to content

ricardojoserf/triangle-position

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

triangle-position

Triangle position given 3 coordinates and 3 radios or 4 coordinates and 4 radios

  • tripos.py: triangulate ONE coordinate from 3 coordinates + 3 ratios

  • quapos.py: triangulate one AREA calculating 4 points from the 4 coordinates + 4 ratios (like executing tripos.py 4 times with 4 coordinates)


3 coordinates

python tripos.py -c1 {coord_1} -c2 {coord_2} -c3 {coord_3} -r1 {ratio_1} -r2 {ratio_2} -r3 {ratio_3}

Example 1:

python tripos.py -c1 40.443580,-3.727077 -c2 40.452052,-3.725831 -c3 40.451418,-3.717722 -r1 0.65 -r2 0.75
-r3 0.65

Screenshot

Result using Plotly:

Screenshot

Result not using Plotly (Matplotlib does not need Access Token or API KEY is not a good option):

Screenshot

Example 2. Changing C3:

python tripos.py -c1 40.443580,-3.727077 -c2 40.452052,-3.725831 -c3 40.443587,-3.715664 -r1 0.65 -r2 0.75
-r3 0.65

Screenshot

Result using Plotly:

Screenshot

Result using Basemap:

Screenshot


4 coordinates

python quapos.py -c1 {coord_1} -c2 {coord_2} -c3 {coord_3} -c4 {coord_4} -r1 {ratio_1} -r2 {ratio_2} -r3 {ratio_3}
-r4 {ratio_4}

Coordinates and ratios must fit this scheme (yes, made with Paint), so the coordinate to calculate is "inside the box":

Screenshot

Example:

python quapos.py -c1 40.443587,-3.715664 -c2 40.451418,-3.717722 -c3 40.452052,-3.725831 -c4 40.443580,-3.727077
-r1 0.47 -r2 0.5 -r3 0.82 -r4 0.785

Screenshot

Result using Basemap (calculated area in yellow):

Screenshot

Result using Plotly:

Screenshot


Installation


Note

Tested both in Python2.x (2.7.15rc1) and Python 3.x (3.6.7)