POV-Ray : Newsgroups : povray.newusers : how to make a 2D image from 3D image : Re: how to make a 2D image from 3D image Server Time
28 Jul 2024 16:15:50 EDT (-0400)
  Re: how to make a 2D image from 3D image  
From: Chris B
Date: 19 Jun 2008 05:22:50
Message: <485a256a@news.povray.org>
"vinhphunguyen" <nvi### [at] gmailcom> wrote in message 
news:web.485a0fbd5fabdd0ab979a58c0@news.povray.org...
> Hi Chris,
>
> I have two intersecting spheres as follows:
>
> #declare sphere1=
> sphere{ <0,0,0>, 5.0  pigment { color Red}}
>
> #declare sphere2=
> sphere{ <7,0,0>, 5.0  pigment { color Green}}
>
>
> #declare grains=merge{
>  object{sphere1}
>  object{sphere2}
> }
>
> Therefore, the common region of these two spheres has mixed color (Red and
> Green). However, I would like to have this intersection region Red 
> colored,
> instead. I have found a way to do this: using more CSG operations
>
> #declare grains=union{
>  object{sphere1}
>  difference{
>   object{sphere2}
>   object{sphere1}
>  }
> }
>
> But I think that this way is time-consuming in case that I have thousand 
> spheres
> or even more. There exists another better way for this? If so, please show 
> me
> the way to go.
>
> Thank you very much.
>
> Vinh Phu
>

Well the obvious question is; If these represent grains in a solid 
substance, shouldn't they be discrete 3D spheres? ie. why would there be 
circumstances where the section through the substance would expose circles 
that overlap?

Assuming though that this is not a problem in the circumstances you are 
trying to emulate, then I've had the following 3 ideas (no perfect answers 
spring to my mind):

1) There are alternative, more efficient ways to approximate this sort of 
grainy effect using textures rather than defining actual 'grain' objects. 
For example, I think you could use a color_map with a spotted pattern, zero 
turbulence and transparency to give you a pattern of similarly coloured 
spheres. The transparency would enable you to overlay several such textures, 
each defined using a different color_map to give you overlapping spheres 
where the top-most layer would take precedence. However, in your first post 
you indicated that you had specific positions and radii that you wanted to 
define, which would be problematic with the randomised nature of texture 
patterns.

2) If the precise positions and radii are important, then you may be able to 
work out ways of making it easier to code through knowledge of your dataset. 
If you know that certain sets of spheres don't overlap you could build 
different unions of spheres and subsequently 'difference' the unions. For 
example, if you know that there are not any red spheres that overlap, you 
can create a union of all red spheres and another for green. You can then 
do:

 #declare grains=union{
  object{AllRedSpheres}
  difference{
   object{AllGreenSpheres}
   object{AllRedSpheres}
  }
 }

3) It is also possible to specify locations for points that can be used in 
textures using DF3 density files, although the precision of the locations is 
limited by the resolution of the file you define. These files are most 
frequently used within 'media', but can also be used in pigment definitions 
along with colour maps. This is not something I've tried, so I don't know 
whether this would achieve anything like what you need, but it may provide a 
means of combining the two techniques above. ie. use a DF3 file to store the 
positions of all of the red spheres and another one for all green spheres 
and combine them as a layered texture. If this works it would probably be a 
lot of effort and only worthwhile if you have a large number of similar 
datasets that you need to visualise.

Regards,
Chris B.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.