POV-Ray : Newsgroups : povray.general : Macro I'd like to see... Server Time
1 Nov 2024 12:22:47 EDT (-0400)
  Macro I'd like to see... (Message 1 to 10 of 12)  
Goto Latest 10 Messages Next 2 Messages >>>
From: Rich
Subject: Macro I'd like to see...
Date: 9 Jul 2000 11:57:18
Message: <8F6C6BC70spammindspringcom@204.213.191.228>
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.  The macro 
should be able to place an object (b) anywhere on the other object (a), 
rotated according (I guess) to the normal of (a) at the point (b) will be 
placed.  I'm mostly interested in spheres and torii for (a), but ones that 
have been scaled in various axis PRIOR to having (b) placed.  If the macro 
could handle any of POV's primitives, that would be cool too.  It would 
also be cool to have some control over where (b) is placed on (a); with a 
sphere I suppose a vector from the center could be used.  No idea how a 
torus would handle it... maybe a flag to use the first or second surface 
hit?

  What I'm thinking of is something like this:

#declare B = [definition of object to be placed on surface of A]
#declare A = [definition of object that will have B placed on it]
#declare loop = 0;
#declare C = union {
  #while (loop < 11)
    Place(A, B, [vector??], [first or second??], [random])
    #declare loop = loop + 1;
  #end
}

  Is this an impossible dream??  I have looked at MegaPOV's trace function, 
but it goes over my head even if I stand up while I read about it.  <smile>    
If it's possible and an explanation of how to go about doing it were 
available I could take a hack at it myself.

-- 
Rich Allen
(Remove SPAM from my address to reply by e-mail)


Post a reply to this message

From: Warp
Subject: Re: Macro I'd like to see...
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

From: Lewis
Subject: Re: Macro I'd like to see...
Date: 9 Jul 2000 15:12:25
Message: <3968DC08.22A28554@netvision.net.il>
trace should do it, it's not even heard to understand, try it.

Rich 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.  The macro
> should be able to place an object (b) anywhere on the other object (a),
> rotated according (I guess) to the normal of (a) at the point (b) will be
> placed.  I'm mostly interested in spheres and torii for (a), but ones that
> have been scaled in various axis PRIOR to having (b) placed.  If the macro
> could handle any of POV's primitives, that would be cool too.  It would
> also be cool to have some control over where (b) is placed on (a); with a
> sphere I suppose a vector from the center could be used.  No idea how a
> torus would handle it... maybe a flag to use the first or second surface
> hit?
> 
>   What I'm thinking of is something like this:
> 
> #declare B = [definition of object to be placed on surface of A]
> #declare A = [definition of object that will have B placed on it]
> #declare loop = 0;
> #declare C = union {
>   #while (loop < 11)
>     Place(A, B, [vector??], [first or second??], [random])
>     #declare loop = loop + 1;
>   #end
> }
> 
>   Is this an impossible dream??  I have looked at MegaPOV's trace function,
> but it goes over my head even if I stand up while I read about it.  <smile>
> If it's possible and an explanation of how to go about doing it were
> available I could take a hack at it myself.
> 
> --
> Rich Allen
> (Remove SPAM from my address to reply by e-mail)


Post a reply to this message

From: Warp
Subject: Re: Macro I'd like to see...
Date: 9 Jul 2000 15:40:12
Message: <3968d51c@news.povray.org>
Lewis <nle### [at] netvisionnetil> wrote:
: trace should do it, it's not even heard to understand, try it.

  trace() can place a _point_ on the surface, not another object.

-- 
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

From: Rune
Subject: Re: Macro I'd like to see...
Date: 9 Jul 2000 18:39:25
Message: <3968ff1d@news.povray.org>
"Warp" wrote:
> Lewis wrote:
> : trace should do it, it's not even heard to understand, try it.
>
>   trace() can place a _point_ on the surface, not another object.

It can also find the normal, so shouldn't a reorient macro + the translate
keyword do the trick?

Greetings,

Rune
--
Updated July 10: http://rsj.mobilixnet.dk
3D images, include files, stereograms, tutorials,
The POV Desktop Theme, The POV-Ray Logo Contest,
music, 350+ raytracing jokes, and much more!


Post a reply to this message

From: Chris Huff
Subject: Re: Macro I'd like to see...
Date: 9 Jul 2000 19:38:02
Message: <chrishuff-6D1A7E.18382109072000@news.povray.org>
In article <8F6C6BC70spammindspringcom@204.213.191.228>, 
SrP### [at] mindspringcom (Rich) wrote:

>   Is this an impossible dream??  I have looked at MegaPOV's trace 
> function, but it goes over my head even if I stand up while I read 
> about it.  <smile>    If it's possible and an explanation of how to 
> go about doing it were available I could take a hack at it myself.

The trace() function is not difficult to understand. It just finds the 
first intersection point of a line with an object, and optionally the 
normal.
An approximation would be quite easy to do, with the trace() function 
and the ReOrient() macro. This wouldn't be perfect, and on many 
combinations of surfaces would give slightly incorrect results(the 
objects intersecting in the area of contact), but should be adequate for 
most purposes.

-- 
Christopher James Huff - Personal e-mail: chr### [at] maccom
TAG(Technical Assistance Group) e-mail: chr### [at] tagpovrayorg
Personal Web page: http://homepage.mac.com/chrishuff/
TAG Web page: http://tag.povray.org/


Post a reply to this message

From: Warp
Subject: Re: Macro I'd like to see...
Date: 9 Jul 2000 19:56:00
Message: <39691110@news.povray.org>
Rune <run### [at] inamecom> wrote:
: It can also find the normal, so shouldn't a reorient macro + the translate
: keyword do the trick?

  But how can you be sure that the object is not partially inside the surface?

-- 
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

From: Rich
Subject: Re: Macro I'd like to see...
Date: 9 Jul 2000 22:03:57
Message: <8F6CC1DF5spammindspringcom@204.213.191.228>
chr### [at] maccom (Chris Huff) wrote in <chrishuff-
6D1A7E.18382109072000@news.povray.org>:
>The trace() function is not difficult to understand. It just finds the 
>first intersection point of a line with an object, and optionally the 
>normal.
>An approximation would be quite easy to do, with the trace() function 
>and the ReOrient() macro. This wouldn't be perfect, and on many 
>combinations of surfaces would give slightly incorrect results(the 
>objects intersecting in the area of contact), but should be adequate for 
>most purposes.

  Thanks Chris.  I've re-read the MegaPOV docs regarding trace and I think 
I can get something going now.  I guess the only question I have now is how 
do I figure out the 'start' vector for arbitrary areas of the object being 
traced.  I guess I'll just have to go the trial-and-error route, geometry 
was far from my favorite class way back when I was in school.  <grin>  Hmm, 
can anyone supply a formula in POV code that will, assuming <0,0,0> as the 
base vector, take an angle, rotation around the y axis, and minimum radius, 
and return a new vector?  
  Warp: I understand your concern for matching surfaces, but I'm actually 
not worried about that bit.  I should have asked for a point on a surface, 
sorry.  I'm thinking of something like short pipe sections covering parts 
of a stretched sphere, that sort of thing, so it won't matter if parts of 
the small objects are embedded in the surface of the target object.  
  Anyway, if I get something figured out I'll post it.  Thanks everyone!

-- 
Rich Allen
(Remove SPAM from my address to reply by e-mail)


Post a reply to this message

From: Bob Hughes
Subject: Re: Macro I'd like to see...
Date: 9 Jul 2000 22:06:33
Message: <39692fa9@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message news:39691110@news.povray.org...
| Rune <run### [at] inamecom> wrote:
| : It can also find the normal, so shouldn't a reorient macro + the translate
| : keyword do the trick?
|
|   But how can you be sure that the object is not partially inside the
surface?

Why not trace both?  But of course the surface terrain would have to be
suitable still.


Post a reply to this message

From: Mark Wagner
Subject: Re: Macro I'd like to see...
Date: 10 Jul 2000 01:09:40
Message: <39695a94@news.povray.org>
Try vegetate.inc at http://www.geocities.com/rengaw03/PovRay.html

Mark


Post a reply to this message

Goto Latest 10 Messages Next 2 Messages >>>

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