POV-Ray : Newsgroups : povray.advanced-users : Use Slope pattern for Planting distribution? Server Time
6 Oct 2024 17:24:47 EDT (-0400)
  Use Slope pattern for Planting distribution? (Message 16 to 25 of 25)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Warp
Subject: Re: Use Slope pattern for Planting distribution?
Date: 14 Dec 2006 07:01:26
Message: <45813d16@news.povray.org>
Thomas de Groot <t.d### [at] internldotnet> wrote:
> so.... what do you think?

  Yes, there's no mention of the returned vector being normalized. Thus
it may not be wise to assume it is, and thus it would be wise to use
vnormalize(), just in case.

-- 
                                                          - Warp


Post a reply to this message

From: Thomas de Groot
Subject: Re: Use Slope pattern for Planting distribution?
Date: 14 Dec 2006 09:16:58
Message: <45815cda@news.povray.org>
"Warp" <war### [at] tagpovrayorg> schreef in bericht 
news:45813d16@news.povray.org...
> Thomas de Groot <t.d### [at] internldotnet> wrote:
>> so.... what do you think?
>
>  Yes, there's no mention of the returned vector being normalized. Thus
> it may not be wise to assume it is, and thus it would be wise to use
> vnormalize(), just in case.
>

OK. There is something that I am missing here obviously. When you mention 
normalize, I think normal. To tell the truth, I have never thought about the 
difference, and as things work perfectly well (in the case of trace to plant 
my trees) I never thought further. However, I wonder about the difference. I 
read the docs, but except for hardly two lines of text, I find no mention of 
what the importance of vnormalize() is and what it is supposed to do. Could 
you please explain?

Thomas


Post a reply to this message

From: Gilles Tran
Subject: Re: Use Slope pattern for Planting distribution?
Date: 14 Dec 2006 12:26:45
Message: <45818955@news.povray.org>

45813d16@news.povray.org...
> Thomas de Groot <t.d### [at] internldotnet> wrote:
>> so.... what do you think?
>
>  Yes, there's no mention of the returned vector being normalized. Thus
> it may not be wise to assume it is, and thus it would be wise to use
> vnormalize(), just in case.

Just ran a test with the Makesnow macro and it looks to be normalized indeed 
(all vlength(Norm)=1). It's just not documented probably.

G.


Post a reply to this message

From: Warp
Subject: Re: Use Slope pattern for Planting distribution?
Date: 14 Dec 2006 14:26:55
Message: <4581a57f@news.povray.org>
Thomas de Groot <t.d### [at] internldotnet> wrote:
> OK. There is something that I am missing here obviously. When you mention 
> normalize, I think normal. To tell the truth, I have never thought about the 
> difference

  Despite the similarity in the names of the terms, a normal vector and a
normalized vector talk about two different things:

  - A normal vector is a vector perpendicular to a surface (or line in 2D)
at a certain point.
  - A normalized vector is a vector of length 1.

  Thus a normalized normal vector is a normal vector of length 1.

  The dot product returns values between 0 and 1 only if the two vectors
are normalized.
  (More specifically, the dot product is the product of the lengths of
the two vectors and the cosine of the angle between them. Naturally if
both lengths are 1, the result is just the cosine.)

-- 
                                                          - Warp


Post a reply to this message

From: Thomas de Groot
Subject: Re: Use Slope pattern for Planting distribution?
Date: 15 Dec 2006 02:57:35
Message: <4582556f@news.povray.org>
"Warp" <war### [at] tagpovrayorg> schreef in bericht 
news:4581a57f@news.povray.org...
>
>  Despite the similarity in the names of the terms, a normal vector and a
> normalized vector talk about two different things:
>
>  - A normal vector is a vector perpendicular to a surface (or line in 2D)
> at a certain point.
>  - A normalized vector is a vector of length 1.
>
>  Thus a normalized normal vector is a normal vector of length 1.
>
>  The dot product returns values between 0 and 1 only if the two vectors
> are normalized.
>  (More specifically, the dot product is the product of the lengths of
> the two vectors and the cosine of the angle between them. Naturally if
> both lengths are 1, the result is just the cosine.)
>

Thanks Warp! This makes it clear for me. Perhaps it would be a suggestion to 
add something like this in the documentation? I think that would be useful.

Thomas


Post a reply to this message

From: Thomas de Groot
Subject: Re: Use Slope pattern for Planting distribution?
Date: 15 Dec 2006 02:59:57
Message: <458255fd$1@news.povray.org>
"Gilles Tran" <tra### [at] inapgfr> schreef in bericht 
news:45818955@news.povray.org...

> 45813d16@news.povray.org...
>> Thomas de Groot <t.d### [at] internldotnet> wrote:
>>> so.... what do you think?
>>
>>  Yes, there's no mention of the returned vector being normalized. Thus
>> it may not be wise to assume it is, and thus it would be wise to use
>> vnormalize(), just in case.
>
> Just ran a test with the Makesnow macro and it looks to be normalized 
> indeed (all vlength(Norm)=1). It's just not documented probably.
>

Thanks Gilles! That is nice to know. A good piece of information for the 
documentation I guess.

Thomas


Post a reply to this message

From: Warp
Subject: Re: Use Slope pattern for Planting distribution?
Date: 15 Dec 2006 03:59:35
Message: <458263f6@news.povray.org>
Thomas de Groot <t.d### [at] internldotnet> wrote:
> Thanks Warp! This makes it clear for me. Perhaps it would be a suggestion to 
> add something like this in the documentation? I think that would be useful.

  I don't think the purpose of the documentation is to be an all-encompassing
mathematics tutorial. While mathematics is certainly very useful (and often
necessary) to use POV-Ray, the documentation should be about POV-Ray, not
about mathematics. I think it's fair that the documentation assumes that
the reader has some previous knowledge on math.

-- 
                                                          - Warp


Post a reply to this message

From: Warp
Subject: Re: Use Slope pattern for Planting distribution?
Date: 15 Dec 2006 04:02:10
Message: <45826491@news.povray.org>
Gilles Tran <tra### [at] inapgfr> wrote:
> Just ran a test with the Makesnow macro and it looks to be normalized indeed 
> (all vlength(Norm)=1). It's just not documented probably.

  I think a more definitive way would be to check from the source code
if all objects return a normalized vector (or if the implementation of
trace() normalizes the vector before it returns it).

  It's highly possible that all objects normalize the normal vector they
return, because it's most useful that way (eg. for lighting calculations
and basically everything else where normals are used). However, it might
also be possible that some objects do not normalize the vector for
efficiency reasons...

-- 
                                                          - Warp


Post a reply to this message

From: Thomas de Groot
Subject: Re: Use Slope pattern for Planting distribution?
Date: 15 Dec 2006 05:25:32
Message: <4582781c@news.povray.org>
"Warp" <war### [at] tagpovrayorg> schreef in bericht 
news:458263f6@news.povray.org...
>  I don't think the purpose of the documentation is to be an 
> all-encompassing
> mathematics tutorial. While mathematics is certainly very useful (and 
> often
> necessary) to use POV-Ray, the documentation should be about POV-Ray, not
> about mathematics. I think it's fair that the documentation assumes that
> the reader has some previous knowledge on math.
>

Hmm.. Yes... However, normalize is mentioned nowhere in the docs, except at 
vnormalize (and then very succintly) and in some examples without further 
comment. Without going too mathematical, imho that is too little for the 
average POV-Ray user (like me).

Thomas


Post a reply to this message

From: user
Subject: Re: Use Slope pattern for Planting distribution?
Date: 9 Jan 2007 13:00:25
Message: <45a3d839@news.povray.org>
Kirk Andrews <kir### [at] hotmailcom> wrote:
> Honestly, I've had a lot of difficulty understanding exactly how that works.
>  When you use the trace command to return the "normal", what exactly is
> being returned?  And perhaps someone might provide a short example code of
> how I might use that?

   Some basic vector math knowledge could be of great help when designing
thing with POV-Ray... :P

   A normal vector is a vector perpendicular (ie. at 90 degrees) to the
surface. In layman terms, a normal is a vector which points directly
away from the surface at that intersection point.

   You can use this normal vector to calculate the steepness of the surface
at that point.
   One simple way of doing this is using the dot product (vdot() function
in povray): Assuming that 'y' is up in your terrain and the normal vector
is normalized (ie. its length is 1; this can be done with vnormalize() just
in case), then the dot product of the normal vector and 'y' will give the
cosine of the angle between these two vectors. In other words, if the normal
vector has the same direction as 'y', the result of the dot product will
be 1 and if the normal vector is perpendicular to 'y' (ie. at 90 degrees)
then the result will be 0. Other directions of the normal vector will give
values in between 0 and 1 (not linearly, though, but that doesn't matter).

   In other words, if you do this:

#declare VD = vdot(vnormalize(TheNormalVectorYouGotWithTrace), y);

now VD will have a value between 0 and 1. 1 means completely vertical,
0 means completely horizontal. If you want to avoid putting a plant on
a surface which is too steep, try doing so only when VD > 0.2 or so
(try different values until you are happy).

   If you know the exact angle which you want to be the limit, then you
can simply compare VD with cos(radians(TheAngle)).

-- 
                                                           - Warp


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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