Finding points within a 4-sided shape not parallel to the axes

ZoraxDoom

New Member
Joined
Mar 16, 2015
Messages
3
Sorry for the super weird title, but it's the best I can describe the problem.

The actual problem is that I have a large amount of data received from GPS trackers on several vehicles. It describes the position of the vehicle at a given time in terms of it Latitude and Longitude. One reading every 15 seconds.

I have to filter this data to only count points within a certain area. The problem here is that the area is not parallel to the axes.

Example: I have a lot of lines (straight, curved, bendy, the whole lot) travelling from bottom left to top right, in a messy, unorganized manner. Lets say from the Origin to a range of destinations in the top right corner.

I also have a square who's 4 corners are A (1,5), B (5,7), C (3,1), and D(7,3)

I need to find the points that cross through this region only.

Therefore, I can't solve it by trying to find all co-ordinates with 1<X<7 and 1<Y<7, as that would catch points that don't fit in my range (such as (1,4) or (7,5)). I need a more complex solution.

The best idea I have so far to solve this is either:
1) Define 4 lines (AC, AB, CB and BD) and use nested if conditions to find points that fit within all 4 lines, or
2) Define some sort of 'hitbox' range/matrix, and carry out checks on each value to see if they fall within it.

The reason I am here is because I do not know if VBA for Excel 2010 has the functionality to carry out either of those methods; and if it does, I have no idea how to go about writing the code.

Google, MS Office support site, and a search site all weren't of much help...mainly because I have no idea what search terms to use lol. The 'hitbox' idea came from a programmer friend of mine, and while it's feasible in Java, I couldn't find any way to implement it into VBA.

Also, I don't know if option 2) is actually feasible. The GPS Coordinates that go up to 5 decimal places and have thousands of values within the range I'm working with. I fear it might be too hard to write and/or be too resource intensive.

So yea...any support or guidance would be appreciated! I think Option 1) is the way to go, but if you have any other ideas then do please let me know. I'm open to suggestions!

I'd have attached an image with this post, but I can't use image hosting sites on work internet, so will do so at home.

Thank you so much for the help! :)
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
FWIW I have currently implemented a quick workaround, using a smaller parallel square within the 4 points. It catches less data, but no wrong data. Was easy to write but sacrifices some accuracy - ideally i'd like to get a really accurate solution in place in the long term.
 
Upvote 0
Sorry for the super weird title, but it's the best I can describe the problem.

The actual problem is that I have a large amount of data received from GPS trackers on several vehicles. <x<7 and="" 1<y<7,="" as="" that="" would="" catch="" points="" don't="" fit="" in="" my="" range="" (such="" (1,4)="" or="" (7,5)).="" i="" need="" a="" more="" complex="" solution.
It describes the position of the vehicle at a given time in terms of its Latitude and Longitude. I have one reading for every 15 seconds.I have to filter this data to only count points within a certain area. The problem here is that the area is not parallel to the axes.
I have a lot of lines (straight, curved, bendy, the whole lot) travelling from bottom left to top right, in a messy, unorganized manner. Lets say they start from the Origin, and are going to a range of destinations in the top right corner.
I also have an area who's 4 corners are A (1,5), B (5,7), C (3,1), and D(7,3)
I need to find the points that cross through this region and this region only.
Therefore, I can't solve it by trying to find all co-ordinates with 1<=X<=7 and 1<=Y<=7 as this would catch values out of my range like (2,2) and (6,7).
I could brute force it and define a range of acceptable Y values per X value, but I've just simplified the values here...im actually dealing with thousands of thousands of values...I have no idea how I'd even begin going about it.
The best idea I have so far to solve this is either:
1) Define 4 lines (AC, AB, CB and BD) and use nested if conditions to find points that fit within all 4 lines, or
2) Define some sort of 'hitbox' range/matrix, and carry out checks on each value to see if they fall within it.

The reason I am here is because I do not know if VBA for Excel 2010 has the functionality to carry out either of those methods; and if it does, I have no idea how to go about writing the code.

Google, MS Office support site, and a search site all weren't of much help...mainly because I have no idea what search terms to use lol. The 'hitbox' idea came from a programmer friend of mine, and while it's feasible in Java, I couldn't find any way to implement it into VBA.

Also, I don't know if option 2) is actually feasible. The GPS Coordinates that go up to 5 decimal places and have thousands of values within the range I'm working with. I fear it might be too hard to write and/or be too resource intensive.

Found some mistakes/ambiguity in my main post. Fixed it.

Appreciate any input :)


</x<7>
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top