Already written function to find if a point is within a rectangle? [message #79347] |
Mon, 20 February 2012 13:29  |
Jacare Omoplata
Messages: 6 Registered: February 2012
|
Junior Member |
|
|
Hi,
I'm working with some data that has been extracted from astronomical
images. All the stars in the images have been identified and their x
and y positions are recorded among other information. ( these x and y
position can be converted the Right Ascension (RA) and Declination
(DEC), so the position of the star in the sky can be found )
These images overlap. I want to plot the positions of all the stars
from all the images, but because of image overlaps, some points are
going to be counted twice. Since the RA and DEC are floating point
numbers, for the same star in two images they might be slightly
different. So using the RA and DEC to identify double counts is not
going to work.
I've come up with the following plan.
Start reading in stars by file. After reading each file, get the
boundaries of each image ( they are rectangular ) and store them. For
each star, check whether it is within the region of images already
read. If it is, don't read it in. If it does not lie within the
regions already read, read it in.
So I need a way to find out if a point ( position of a star ) is
within a rectangle ( image boundary ). The rectangle edges are not
strictly horizontal or vertical.
I've found several methods of doing this, and can write a function.
But I can save some time if someone knows if there's already one
available out there.
Thanks.
|
|
|
|
Re: Already written function to find if a point is within a rectangle? [message #79355 is a reply to message #79347] |
Fri, 24 February 2012 14:00   |
JDS
Messages: 94 Registered: March 2009
|
Member |
|
|
On Thursday, February 23, 2012 2:13:18 PM UTC-5, Paulo Penteado wrote:
> On Feb 23, 7:34 am, Craig Markwardt <craig.markwa...@gmail.com> wrote:
>>> I'm thinking of making polygons with a large number of edges, instead
>>> of rectangles, with every data point at the edge of a FITS file as a
>>> vertex. That would minimize the projection error, right?
>>
>> That helps. Special care is probably need around the poles though.
>
> Not only the poles. Also at the longitude boundary. Working with
> polygons in spherical geometry is, in my experience, a pain. Just
> because there is not enough library support for it.
I
On Thursday, February 23, 2012 2:13:18 PM UTC-5, Paulo Penteado wrote:
> On Feb 23, 7:34 am, Craig Markwardt <craig.markwa...@gmail.com> wrote:
>>> I'm thinking of making polygons with a large number of edges, instead
>>> of rectangles, with every data point at the edge of a FITS file as a
>>> vertex. That would minimize the projection error, right?
>>
>> That helps. Special care is probably need around the poles though.
>
> Not only the poles. Also at the longitude boundary. Working with
> polygons in spherical geometry is, in my experience, a pain. Just
> because there is not enough library support for it.
On Thursday, February 23, 2012 2:13:18 PM UTC-5, Paulo Penteado wrote:
> On Feb 23, 7:34 am, Craig Markwardt <craig.markwa...@gmail.com> wrote:
>>> I'm thinking of making polygons with a large number of edges, instead
>>> of rectangles, with every data point at the edge of a FITS file as a
>>> vertex. That would minimize the projection error, right?
>>
>> That helps. Special care is probably need around the poles though.
>
> Not only the poles. Also at the longitude boundary. Working with
> polygons in spherical geometry is, in my experience, a pain. Just
> because there is not enough library support for it.
I
On Thursday, February 23, 2012 2:13:18 PM UTC-5, Paulo Penteado wrote:
> On Feb 23, 7:34 am, Craig Markwardt <craig.markwa...@gmail.com> wrote:
>>> I'm thinking of making polygons with a large number of edges, instead
>>> of rectangles, with every data point at the edge of a FITS file as a
>>> vertex. That would minimize the projection error, right?
>>
>> That helps. Special care is probably need around the poles though.
>
> Not only the poles. Also at the longitude boundary. Working with
> polygons in spherical geometry is, in my experience, a pain. Just
> because there is not enough library support for it.
On Thursday, February 23, 2012 2:13:18 PM UTC-5, Paulo Penteado wrote:
> On Feb 23, 7:34 am, Craig Markwardt <craig.markwa...@gmail.com> wrote:
>>> I'm thinking of making polygons with a large number of edges, instead
>>> of rectangles, with every data point at the edge of a FITS file as a
>>> vertex. That would minimize the projection error, right?
>>
>> That helps. Special care is probably need around the poles though.
>
> Not only the poles. Also at the longitude boundary. Working with
> polygons in spherical geometry is, in my experience, a pain. Just
> because there is not enough library support for it.
I have a few routines for spherical polygons available:
http://tir.astro.utoledo.edu/jdsmith/code/idl.php
JD
|
|
|
Re: Already written function to find if a point is within a rectangle? [message #79356 is a reply to message #79347] |
Fri, 24 February 2012 10:48   |
Jacare Omoplata
Messages: 6 Registered: February 2012
|
Junior Member |
|
|
On Feb 23, 1:05 pm, Greg Hennessy <greg.henne...@cox.net> wrote:
>>> I'm thinking of making polygons with a large number of edges, instead
>>> of rectangles, with every data point at the edge of a FITS file as a
>>> vertex. That would minimize the projection error, right?
>
>> That helps. Special care is probably need around the poles though.
>
> It often helps to convert from ra/dec to unit vectors
> ([cos(ra)*cos(dec),sin(ra)*cos(dec),sin(dec)]) for both
> the star position and the edges of the polygon.
That's brilliant idea!
I'm not going to bother with it for this problem, since I've already
half written the program, and the images are not near the poles or the
longitude boundary. I will definitely use it in the future though.
Thanks.
|
|
|
|
|
|
Re: Already written function to find if a point is within a rectangle? [message #84292 is a reply to message #79354] |
Sat, 18 May 2013 21:19  |
suruchi
Messages: 13 Registered: September 2012
|
Junior Member |
|
|
On Saturday, February 25, 2012 12:03:47 PM UTC+5:30, Jacare Omoplata wrote:
>>
>
>> I have a few routines for spherical polygons available:
>
>>
>
>> http://tir.astro.utoledo.edu/jdsmith/code/idl.php
>
>>
>
>> JD
>
>
>
> Thanks! I will bookmark this page. These programs will definitely be
>
> useful to me!
Hi Jacare
I have been looking for finding overlap of two polygons covering some regions on solar disc images defined in terms of latitude and longitudes. Hence here also spherical geometry comes into picture.. how to match the latitudes and longitudes? Could you suggest how can I achieve this?
|
|
|