comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Inscribed circle
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Inscribed circle [message #83698] Wed, 27 March 2013 13:38
arayamelo.pablo is currently offline  arayamelo.pablo
Messages: 4
Registered: March 2013
Junior Member
Thanks!

I will adapt it to my code.
On Wednesday, March 27, 2013 7:43:46 PM UTC+1, rrya...@gmail.com wrote:
> On Wednesday, March 27, 2013 9:40:25 AM UTC-4, arayame...@gmail.com wrote:
>
>> On Wednesday, March 27, 2013 2:34:29 PM UTC+1, rr...@stsci.edu wrote:
>
>>
>
>>> On Wednesday, March 27, 2013 6:32:49 AM UTC-4, arayame...@gmail.com wrote:
>
>>
>
>>>
>
>>
>
>>>> Dear all,
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> maybe this has been already posted, but I can not seem to find it.
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> I have a contour plot, and I draw a circle on it (region of interest). Is there a way to blank off the area of the square outside of the circle (I though polyfill, but I can just manage squared polygons) or to just make the contour of the circle (region) of interest?
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> Thanks!
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> PS: the contour data is created through triangulate and trigrid.
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> What do you mean "blank off the area?" Is your contour plot made with black lines on a white background and you want to draw a white square? If so, then yes. Polyfill is the easiest way. If you're having trouble, it's almost certainly with either the coordinates you're giving it or their order. Make sure to check the /normal, /data, or /device settings to verify that your data are in the right units. Then check that the order of the polyfill data is correct:
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> x=[left,left,right,right]
>
>>
>
>>>
>
>>
>
>>> y=[top,bottom,bottom,top]
>
>>
>
>>>
>
>>
>
>>> polyfill,x,y
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> That's a basic idea to draw a rectangle, the trick is to find the right values of top, bottom, right, and left. It shouldn't be too tough, but you have to be aware of the units (device vs. data vs. normal).
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> -Russell
>
>>
>
>>
>
>>
>
>> Thanks Russell.
>
>>
>
>>
>
>>
>
>> What I mean with "blank off the area", I mean to fill it with white color. The problem I get with using polyfill in this particular problem is that I want to fill a "waxing moon" area-shape, and with polyfill I just cover rectangles.
>
>
>
>
>
> So, I wrote this quick script to fill a crescent moon with color. I set it to gray and the moon's outline to white, but you should be able to change that...
>
>
>
>
>
>
>
>
>
> xc=5.0 ;x-center of the moon
>
> yc1=1. ;y-center of bottom of moon
>
> yc2=3. ;y-center of top of moon
>
> r1=5. ;radius of bottom of moon
>
> r2=4 ;radius of top of moon
>
>
>
> ;create a window and plot
>
> window,2,retain=2,xsize=600,ysize=600
>
> plot,[0],[0],xr=[0,10],yr=[0,10]
>
>
>
> ;compute the y-coordinate where they're equal
>
> num=(r1*r1-r2*r2)-(yc1*yc1-yc2*yc2)
>
> den=2.*(yc2-yc1)
>
> yequal=num/den
>
>
>
> ;compute the x-coordinate where they're equal
>
> x0=xc-sqrt(r1*r1-(yequal-yc1)*(yequal-yc1))
>
> x1=xc+sqrt(r1*r1-(yequal-yc1)*(yequal-yc1))
>
>
>
> ;create an x variable
>
> n=1000L
>
> x=findgen(n)/(n-1)*(x1-x0)+x0
>
>
>
> ;create the top and bottom of moon
>
> y1=sqrt(r1*r1-(x-xc)*(x-xc))+yc1 ; bottom of moon
>
> y2=sqrt(r2*r2-(x-xc)*(x-xc))+yc2 ; top of moon
>
>
>
> ;make the moon grey
>
> polyfill,[x,reverse(x)],[y1,reverse(y2)],/data,color=100
>
>
>
> ;overplot the outline
>
> oplot,x,y1
>
> oplot,x,y2
Re: Inscribed circle [message #83702 is a reply to message #83698] Wed, 27 March 2013 11:43 Go to previous message
Russell[1] is currently offline  Russell[1]
Messages: 101
Registered: August 2011
Senior Member
On Wednesday, March 27, 2013 9:40:25 AM UTC-4, arayame...@gmail.com wrote:
> On Wednesday, March 27, 2013 2:34:29 PM UTC+1, rr...@stsci.edu wrote:
>
>> On Wednesday, March 27, 2013 6:32:49 AM UTC-4, arayame...@gmail.com wrote:
>
>>
>
>>> Dear all,
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> maybe this has been already posted, but I can not seem to find it.
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> I have a contour plot, and I draw a circle on it (region of interest). Is there a way to blank off the area of the square outside of the circle (I though polyfill, but I can just manage squared polygons) or to just make the contour of the circle (region) of interest?
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> Thanks!
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> PS: the contour data is created through triangulate and trigrid.
>
>>
>
>>
>
>>
>
>> What do you mean "blank off the area?" Is your contour plot made with black lines on a white background and you want to draw a white square? If so, then yes. Polyfill is the easiest way. If you're having trouble, it's almost certainly with either the coordinates you're giving it or their order. Make sure to check the /normal, /data, or /device settings to verify that your data are in the right units. Then check that the order of the polyfill data is correct:
>
>>
>
>>
>
>>
>
>> x=[left,left,right,right]
>
>>
>
>> y=[top,bottom,bottom,top]
>
>>
>
>> polyfill,x,y
>
>>
>
>>
>
>>
>
>> That's a basic idea to draw a rectangle, the trick is to find the right values of top, bottom, right, and left. It shouldn't be too tough, but you have to be aware of the units (device vs. data vs. normal).
>
>>
>
>>
>
>>
>
>> -Russell
>
>
>
> Thanks Russell.
>
>
>
> What I mean with "blank off the area", I mean to fill it with white color. The problem I get with using polyfill in this particular problem is that I want to fill a "waxing moon" area-shape, and with polyfill I just cover rectangles.


So, I wrote this quick script to fill a crescent moon with color. I set it to gray and the moon's outline to white, but you should be able to change that...




xc=5.0 ;x-center of the moon
yc1=1. ;y-center of bottom of moon
yc2=3. ;y-center of top of moon
r1=5. ;radius of bottom of moon
r2=4 ;radius of top of moon

;create a window and plot
window,2,retain=2,xsize=600,ysize=600
plot,[0],[0],xr=[0,10],yr=[0,10]

;compute the y-coordinate where they're equal
num=(r1*r1-r2*r2)-(yc1*yc1-yc2*yc2)
den=2.*(yc2-yc1)
yequal=num/den

;compute the x-coordinate where they're equal
x0=xc-sqrt(r1*r1-(yequal-yc1)*(yequal-yc1))
x1=xc+sqrt(r1*r1-(yequal-yc1)*(yequal-yc1))

;create an x variable
n=1000L
x=findgen(n)/(n-1)*(x1-x0)+x0

;create the top and bottom of moon
y1=sqrt(r1*r1-(x-xc)*(x-xc))+yc1 ; bottom of moon
y2=sqrt(r2*r2-(x-xc)*(x-xc))+yc2 ; top of moon

;make the moon grey
polyfill,[x,reverse(x)],[y1,reverse(y2)],/data,color=100

;overplot the outline
oplot,x,y1
oplot,x,y2
Re: Inscribed circle [message #83713 is a reply to message #83702] Wed, 27 March 2013 06:40 Go to previous message
arayamelo.pablo is currently offline  arayamelo.pablo
Messages: 4
Registered: March 2013
Junior Member
On Wednesday, March 27, 2013 2:34:29 PM UTC+1, rr...@stsci.edu wrote:
> On Wednesday, March 27, 2013 6:32:49 AM UTC-4, arayame...@gmail.com wrote:
>
>> Dear all,
>
>>
>
>>
>
>>
>
>> maybe this has been already posted, but I can not seem to find it.
>
>>
>
>>
>
>>
>
>> I have a contour plot, and I draw a circle on it (region of interest). Is there a way to blank off the area of the square outside of the circle (I though polyfill, but I can just manage squared polygons) or to just make the contour of the circle (region) of interest?
>
>>
>
>>
>
>>
>
>> Thanks!
>
>>
>
>>
>
>>
>
>> PS: the contour data is created through triangulate and trigrid.
>
>
>
> What do you mean "blank off the area?" Is your contour plot made with black lines on a white background and you want to draw a white square? If so, then yes. Polyfill is the easiest way. If you're having trouble, it's almost certainly with either the coordinates you're giving it or their order. Make sure to check the /normal, /data, or /device settings to verify that your data are in the right units. Then check that the order of the polyfill data is correct:
>
>
>
> x=[left,left,right,right]
>
> y=[top,bottom,bottom,top]
>
> polyfill,x,y
>
>
>
> That's a basic idea to draw a rectangle, the trick is to find the right values of top, bottom, right, and left. It shouldn't be too tough, but you have to be aware of the units (device vs. data vs. normal).
>
>
>
> -Russell

Thanks Russell.

What I mean with "blank off the area", I mean to fill it with white color. The problem I get with using polyfill in this particular problem is that I want to fill a "waxing moon" area-shape, and with polyfill I just cover rectangles.
Re: Inscribed circle [message #83714 is a reply to message #83713] Wed, 27 March 2013 06:34 Go to previous message
Russell Ryan is currently offline  Russell Ryan
Messages: 122
Registered: May 2012
Senior Member
On Wednesday, March 27, 2013 6:32:49 AM UTC-4, arayame...@gmail.com wrote:
> Dear all,
>
>
>
> maybe this has been already posted, but I can not seem to find it.
>
>
>
> I have a contour plot, and I draw a circle on it (region of interest). Is there a way to blank off the area of the square outside of the circle (I though polyfill, but I can just manage squared polygons) or to just make the contour of the circle (region) of interest?
>
>
>
> Thanks!
>
>
>
> PS: the contour data is created through triangulate and trigrid.

What do you mean "blank off the area?" Is your contour plot made with black lines on a white background and you want to draw a white square? If so, then yes. Polyfill is the easiest way. If you're having trouble, it's almost certainly with either the coordinates you're giving it or their order. Make sure to check the /normal, /data, or /device settings to verify that your data are in the right units. Then check that the order of the polyfill data is correct:

x=[left,left,right,right]
y=[top,bottom,bottom,top]
polyfill,x,y

That's a basic idea to draw a rectangle, the trick is to find the right values of top, bottom, right, and left. It shouldn't be too tough, but you have to be aware of the units (device vs. data vs. normal).

-Russell
Re: Inscribed circle [message #84721 is a reply to message #83702] Wed, 27 March 2013 13:26 Go to previous message
arayamelo.pablo is currently offline  arayamelo.pablo
Messages: 4
Registered: March 2013
Junior Member
Yep, perfect!

Thanks!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: algorithm question. Can I get rid of the for loop?
Next Topic: Re: volume() command

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:13:41 PDT 2025

Total time taken to generate the page: 0.00844 seconds