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

Home » Public Forums » archive » Re: Mapping on Objekts...
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: Mapping on Objekts... [message #8512] Thu, 20 March 1997 00:00
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
JD Smith writes:

> David:
>
> View of (cylindrical) cheesecake from above (sliced into N=8
> pieces):
> ___
> Outer Crust----->/ \
> | |
> \ ___ /
>
>
> Perhaps they don't make New York-style Cheesecake in Colorado?
>
>
> I hear they can be Fed Ex'd for pittance.

Ah, yes. If you would have said "sort of like the circumference
of a Rocky Mountain Oyster" I would have understood immediately. :-)

I hear they have New York Cheesecake in Boulder, but it's hard
to find out here in the sticks where I live. Perhaps you should
sponsor a contest with a cheesecake as the prize and I would
try to win it. :-)

Cheers!

David

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
2642 Bradbury Court, Fort Collins, CO 80521
Phone: 970-221-0438 Fax: 970-221-4762
E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
-----------------------------------------------------------
Re: Mapping on Objekts... [message #8513 is a reply to message #8512] Thu, 20 March 1997 00:00 Go to previous message
J.D. Smith is currently offline  J.D. Smith
Messages: 214
Registered: August 1996
Senior Member
Hey Folks,

If you liked the cylinder, here's one that's even more fun (is it possible?!?).

Herr Moebius' Strip:


Put in a file and .run it. Same conditions as with cylinder apply.

Enjoy,

JD

;; BEGIN MOEBIUS STRIP CODE

scale3,xrange=[0,1],yrange=[0,1],zrange=[0,1],AZ=80,AX=50
N=125
phi=findgen(N)/(N-1)*2*!PI
;; define angle of strip section rotation
thet=phi/2
;; set up base radius of strip
Ro=.5
;; define half width of strip
d=.3
;; define the radius at the top and bottom (as defined at phi=0)
Rtop=Ro-d*sin(thet) ;radius at top
Rbottom=Ro+d*sin(thet) ;radius at bottom
zc=d*cos(thet) ;height
;; convert polar to rectangular (top and bottom)
cv=cv_coord(FROM_POLAR=[rotate(phi,1),rotate(Rtop,1)],/TO_RE CT)
xctop=cv(0,*) & yctop=cv(1,*)
cv=cv_coord(FROM_POLAR=[rotate(phi,1),rotate(Rbottom,1)],/TO _RECT)
xcbot=cv(0,*) & ycbot=cv(1,*)

;; get some example data
file=filepath('people.dat',subdir='examples/data')
openr,un,/get_lun,file
d=bytarr(192,192)
readu,un,d
free_lun,un
s=size(d)

set_plot,'Z'
erase
;; render Moebius in strips
for i=0,N-2 do begin
x=[xcbot(i),xctop(i),xctop(i+1),xcbot(i+1)]+.5
y=[ycbot(i),yctop(i),yctop(i+1),ycbot(i+1)]+.5
z=[-zc(i),zc(i),zc(i+1),-zc(i+1)]+.5
left=round(float(i)/N*(s(1)-1)) & right=round(float(i+1)/N*(s(1)-1))
top=s(2)-1 & bot=0
polyfill,x,y,z,/T3D,PATTERN=d(left:right,bot:top),/IMAGE_INT ERP, $
IMAGE_COORD=[[0,0],[0,top],[right-left,top],[right-left,0]]
endfor
im=tvrd()
set_plot,'X'
tv,im
end
Re: Mapping on Objekts... [message #8517 is a reply to message #8512] Thu, 20 March 1997 00:00 Go to previous message
J.D. Smith is currently offline  J.D. Smith
Messages: 214
Registered: August 1996
Senior Member
David Fanning wrote:
>
> JD Smith <jdsmith@astrosun.tn.cornell.edu> gives us a nice piece of
> code for rendering an image on a cylinder, and for that I am extremely
> grateful. I just have one question: What does he mean when he says he broke
> the cylinder up into sections "like the outer crust on slices of
> cheesecake"!?
>
> I've been pondering this for over an hour now and I am no closer
> to enlightenment. :-)

David:

View of (cylindrical) cheesecake from above (sliced into N=8
pieces):
___
Outer Crust----->/ \
| |
\ ___ /


Perhaps they don't make New York-style Cheesecake in Colorado?


I hear they can be Fed Ex'd for pittance.


JD
Re: Mapping on Objekts... [message #8518 is a reply to message #8512] Thu, 20 March 1997 00:00 Go to previous message
J.D. Smith is currently offline  J.D. Smith
Messages: 214
Registered: August 1996
Senior Member
P.S.

___
> Outer Crust----->/ \
> | |
> \ ___ /

Don't forget a fixed spacing font!
Re: Mapping on Objekts... [message #8523 is a reply to message #8512] Wed, 19 March 1997 00:00 Go to previous message
J.D. Smith is currently offline  J.D. Smith
Messages: 214
Registered: August 1996
Senior Member
David Fanning wrote:
>
> I've never really tried this with a zylinder, but I think I could get it to
> work. You do it in the C-buffer, with the Pattern and Image_Coord
> keywords. (Image_Coord matches the coordinates of the image in
> Pattern with the vertices specified in the positional argument
> to Polyfill. For a zylinder you may have to do the rendering in narrow strips
> to make the edges more or less a smooth curve. (Guess this depends on
> how your zylinder is rendered on the display.)
>
> Cheers!
>
> David
>
> P.S. You can find a good description of how to do these Z-buffer
> tricks in my soon-to-be announced IDL Programming Guide. I am
> very pleased with the new graphics sections. It may be the
> best material I have ever written on IDL techniques. :-)

Well, it's a little harder than you might think. My difficulty has to do with setting up the
coordinates in polyfill so that the region you want is actually specified. For a cylinder, I broke it
up into semi-rectangular sections (like the outer crust on slices of cheesecake). The problem is, I
couldn't find a way to get polyfill to accept vertex coordinates to define the cylinder *sides* (not the
circular top or bottom). I tried all sorts of variations, even full rectangular indices formed with:

;; form the indices to get [0,0,1,1,0,1,1,2,2,1,2,2,3,3,2...]
;flag=0
;for i=0,N-1 do begin
; if flag eq 1 then begin
; inds=[inds,[i,i,i+1,i+1,i]]
; endif else begin
; flag=1
; inds=[i,i,i+1,i+1,i]
; endelse
;endfor

None of these gave the desired results. The best I could do is every other section (like a circular of
teeth with gaps). So, instead of trying to give polyfill the entire list at once, I filled each
section, one at a time. This worked just fine. The code follows. Simply put it in a file and say .run
file. Here are some caveats: If N (the number of sections) is larger than the number of columns in
your data, the code will work, but will not make pretty results. You could congrid your array to be
larger, if necessary (or reduce N). Also, note that, for some reason, passing polyfill the *subset* of
the array and giving IMAGE_COORD's with respect to the subset is much faster that passing the entire
array and using the real coordinates (but why I can't imagine). I got good results with N ~= data
columns/2.


;; BEGIN CYLINDER MAP CODE

;; set up 3-D scaling
scale3,xrange=[0,1],yrange=[0,1],zrange=[0,1],AZ=0
N=100 ;number of sections of cylinder

;; get x and y coordinates of a circle -- you can change the circle's
;; shape here -- a fun example: replace the yc=.5.. statement by the
;; commented statement to its right
xc=findgen(N)/(N-1)*!PI*2 & yc=xc
xc=.5*(1+cos(xc+!PI/2))
yc=.5*(1+sin(yc+!PI/2)) ; yc=.5*(1+sin(yc+!PI/2)+.1*sin(N/10*yc))

;; get some example data
file=filepath('people.dat',subdir='examples/data')
openr,un,/get_lun,file
d=bytarr(192,192)
readu,un,d
free_lun,un
s=size(d)

;; go to Z-buffer
oldname=!D.NAME & set_plot,'Z'
erase

;;draw each section individually
for i=0,N-2 do begin
;; setup coordinates defining the current section of the cylinder
x=[xc(i),xc(i+1),xc(i+1),xc(i)]
y=[yc(i),yc(i+1),yc(i+1),yc(i)]
z=[0,0,1,1]
;; setup image coordinates to pin to vertices overlaying this section -- screwy for N > s(1)
left=round(float(i)/N*(s(1)-1)) & right=round(float(i+1)/N*(s(1)-1))
top=s(2)-1 & bot=0
;; fill the section with image piece.. IMAGE_INTERP makes things smooth
polyfill,x,y,z,/T3D,PATTERN=d(left:right,bot:top), /IMAGE_INTERP,$
IMAGE_COORD=[[0,0],[right-left,0],[right-left,top],[0,top]]
endfor

im=tvrd() ; read in the image
set_plot,oldname ;switch back to your display device
tv,im
end

;; END CYLINDER MAP CODE


Hope this helps.

JD
Re: Mapping on Objekts... [message #8525 is a reply to message #8523] Wed, 19 March 1997 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
JD Smith <jdsmith@astrosun.tn.cornell.edu> gives us a nice piece of
code for rendering an image on a cylinder, and for that I am extremely
grateful. I just have one question: What does he mean when he says he broke
the cylinder up into sections "like the outer crust on slices of
cheesecake"!?

I've been pondering this for over an hour now and I am no closer
to enlightenment. :-)

David

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
2642 Bradbury Court, Fort Collins, CO 80521
Phone: 970-221-0438 Fax: 970-221-4762
E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
-----------------------------------------------------------
Re: Mapping on Objekts... [message #8536 is a reply to message #8523] Tue, 18 March 1997 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Christian Lenz <cnlenz@uni-paderborn.de> writes:

> A long time ago, I read something about mapping of Pictures on a cube. I
> thing it was in the IDL Basics, but i can't find it again.
>
> Now I would like to map a picture on a outside of a zylinder. Has anyone
> a tip for me?

I've never really tried this with a zylinder, but I think I could get it to
work. You do it in the C-buffer, with the Pattern and Image_Coord
keywords. (Image_Coord matches the coordinates of the image in
Pattern with the vertices specified in the positional argument
to Polyfill. For a zylinder you may have to do the rendering in narrow strips
to make the edges more or less a smooth curve. (Guess this depends on
how your zylinder is rendered on the display.)

Cheers!

David

P.S. You can find a good description of how to do these Z-buffer
tricks in my soon-to-be announced IDL Programming Guide. I am
very pleased with the new graphics sections. It may be the
best material I have ever written on IDL techniques. :-)

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
2642 Bradbury Court, Fort Collins, CO 80521
Phone: 970-221-0438 Fax: 970-221-4762
E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
-----------------------------------------------------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Dual Installation of IDL 4 and IDL 5
Next Topic: Digital Alpha, Windows NT and IDL

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

Current Time: Thu Oct 09 14:23:22 PDT 2025

Total time taken to generate the page: 0.88111 seconds