POV-Ray : Newsgroups : povray.general : Macro I'd like to see... : Re: Macro I'd like to see... Server Time
9 Aug 2024 13:26:33 EDT (-0400)
  Re: Macro I'd like to see...  
From: Warp
Date: 9 Jul 2000 14:06:35
Message: <3968bf2a@news.povray.org>
Rich <SrP### [at] mindspringcom> wrote:
:   This may already exist; if so a URL would be welcome!  What I'd like to 
: be able to do is place objects on the surface of another object.

  Holy cow! That's a pretty difficult thing you are asking for.
  Calculating the intersection curve/point of two arbitrary surfaces is
often impossible (at least analytically) and even when possible very hard.
It's easy only for the simplest surfaces (planes, spheres...).
  Placing a point on the surface of an object is rather easy with the
trace() function (in megapov), but placing another object is a lot harder.
Placing a sphere may succeed rather well (unless the other surface is very
chaotic), but if you try with any more complicated objects, it may be
near to impossible.

  You could try this:
  - Trace many rays with trace() from the interior of the object to be placed
towards the other object.
  - For each ray, get its intersection point with the first object and the
intersection point with the second object.
  - If for all rays the first intersection point is closer to the starting
point than the second point, then the object to be placed is too far. Move
it closer.
  - If for any ray the first point is farther than the second point, the
first object intersects the second one. Move it farther away.
  - Do this until the smallest difference between the two points is small
enough.

  This algorithm is far from fool-proof, but may work in many cases. It's
also slow.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

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