POV-Ray : Newsgroups : povray.general : normals function Server Time
3 Aug 2024 20:16:03 EDT (-0400)
  normals function (Message 5 to 14 of 14)  
<<< Previous 4 Messages Goto Initial 10 Messages
From: Warp
Subject: Re: normals function
Date: 10 Jan 2004 19:31:55
Message: <4000997b@news.povray.org>
m1j <mik### [at] hotmailcom> wrote:
> It has been over 12 years for me and this I do not remember in my math.
> Would have been nice. But thanks all for the help. I thought that vcross
> was for this but my brain just was not putting every thing together.

  The cross-product of two vectors is defined as a vector which is
perpendicular to both and which length is the product of the lengths
of the two vectors multiplied by the sine of the angle between them.
The direction of this perpendicular vector is defined by the handedness
rule (first vector is thumb, second vector is index, result is middle
finger).

  One could wonder why the definition has to be this complicated, but
the idea is that calculating the cross-product of two vectors is very
easy to do with only multiplications and additions (ie you don't need
trigonometry at all).
  If the first vector is <ux, uy, uz> and the second is <vx, vy, vz>
then their cross-product is <uy*vz-uz*vy, uz*vx-ux*vz, ux*vy-uy*vx>.
(This result vector has the properties described above.)

  The most useful property of the cross-product is its perpendicularity,
which is used a lot in computer graphics for calculating normal vectors.

  (Another useful operator is the dot-product, but that's another story.)

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Stephen McAvoy
Subject: Re: normals function
Date: 11 Jan 2004 04:18:18
Message: <825200dr314odhi26lhm1qcah9tbjba24r@4ax.com>
On 10 Jan 2004 19:31:55 -0500, Warp <war### [at] tagpovrayorg> wrote:

>  (Another useful operator is the dot-product, but that's another story.)

Well tell it please, your cross-product story was iluminating. 
Regards
        Stephen


Post a reply to this message

From: Warp
Subject: Re: normals function
Date: 11 Jan 2004 10:56:24
Message: <40017227@news.povray.org>
Stephen McAvoy <mcavoys[at]aolDOTcom> wrote:
> >  (Another useful operator is the dot-product, but that's another story.)

> Well tell it please, your cross-product story was iluminating. 
> Regards

  The result of the dot-product of two vectors is a scalar which is the
product of the lengths of the two vectors multiplied with the cosine of
the angle between them.
  The good thing about the dot-product is that it's very easy to calculate
with multiplications and additions only. The dot-product of <ux, uy, uz>
and <vx, vy, vz> is ux*vx+uy*vy+uz*vz.

  When the two vectors are unit vectors, their dot-product is simply the
cosine of the angle between them (because the product of their lengths
is 1).
  This property is very useful for many things. For example the lighting
at a certain point in a surface is proportional to the cosine of the angle 
between the normal vector and the vector which points towards the light
source. This is very fast to calculate with the dot-product (when the
two vectors have been normalized).

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Christopher James Huff
Subject: Re: normals function
Date: 11 Jan 2004 12:00:07
Message: <cjameshuff-A7A76E.12002011012004@netplex.aussie.org>
In article <40017227@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

>   The good thing about the dot-product is that it's very easy to calculate
> with multiplications and additions only. The dot-product of <ux, uy, uz>
> and <vx, vy, vz> is ux*vx+uy*vy+uz*vz.

And it's worth mentioning what happens when you compute the dot product 
of a vector with one of the natural basis vectors (x, y, and z). Given 
the vector V = < a, b, c>:
V dot x = a*1 + b*0 + c*0 = a
V dot y = a*0 + b*1 + c*0 = b
V dot z = a*0 + b*0 + c*1 = c

So writing vdot(A, x) is the same as writing A.x, which happens to be 
the notation used in mathematics for dot products...though it actually 
comes from C, where it is used to refer to a member of a struct.

Anyway, that means acos(A.x) means the same thing as acos(vdot(A, x)): 
the angle in radians between the vector and the x axis.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Stephen McAvoy
Subject: Re: normals function
Date: 11 Jan 2004 14:29:43
Message: <q09300h9mla6kqn837qifvk46tjoen3j7o@4ax.com>
On 11 Jan 2004 10:56:24 -0500, Warp <war### [at] tagpovrayorg> wrote:

>  The result of the dot-product of two vectors is a scalar which is...

Thanks Warp and to you Christopher

Regards
        Stephen


Post a reply to this message

From: Warp
Subject: Re: normals function
Date: 11 Jan 2004 20:31:17
Message: <4001f8e5@news.povray.org>
Christopher James Huff <cja### [at] earthlinknet> wrote:
> Anyway, that means acos(A.x) means the same thing as acos(vdot(A, x)): 
> the angle in radians between the vector and the x axis.

  Only if A is a unit vector. (If it isn't, you need to normalize
it first.)

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Mikael Pohjola
Subject: Re: normals function
Date: 13 Jan 2004 10:27:12
Message: <opr1pzvldo0x9foi@news.povray.org>
On 11 Jan 2004 10:56:24 -0500, Warp <war### [at] tagpovrayorg> wrote:
>   The result of the dot-product of two vectors is a scalar which is the
> product of the lengths of the two vectors multiplied with the cosine of
> the angle between them.
>   The good thing about the dot-product is that it's very easy to 
> calculate
> with multiplications and additions only. The dot-product of <ux, uy, uz>
> and <vx, vy, vz> is ux*vx+uy*vy+uz*vz.

I think you left out the most useful thing: the dot-product is 0 when the 
two vectors are perpendicular to each other (since the cosine of 90 
degrees is 0)

-- 
light_source{20*y,1}#macro _(M,X,Y,P)#macro L(N,D)#if(N)#declare 
P=P+D;box{-
0.5,0.5translate z*mod(9*P.gray,4)pigment{rgb P}rotate 45*x+clock*y 
translate
P}L(N-1,D)#end#end#if(M)L(mod(M,8)<mod(X,3)mod(Y,3)1>-1)_(div(M,8)div(X,3)div
(Y,3)P)#end#end _(2301603551,12850,60365,20*z-5*x)plane{y,-9pigment{rgb 1}}


Post a reply to this message

From: Warp
Subject: Re: normals function
Date: 13 Jan 2004 15:19:58
Message: <400452ee@news.povray.org>
Mikael Pohjola <emp### [at] cchutfi> wrote:
> I think you left out the most useful thing: the dot-product is 0 when the 
> two vectors are perpendicular to each other (since the cosine of 90 
> degrees is 0)

  It certainly is useful, but why is it *the most* useful feature?-)

-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

From: Christopher James Huff
Subject: Re: normals function
Date: 14 Jan 2004 16:23:07
Message: <cjameshuff-4E69DA.16232414012004@netplex.aussie.org>
In article <opr1pzvldo0x9foi@news.povray.org>,
 Mikael Pohjola <emp### [at] cchutfi> wrote:

> I think you left out the most useful thing: the dot-product is 0 when the 
> two vectors are perpendicular to each other (since the cosine of 90 
> degrees is 0)

I'd say this is even more useful: if the dot product is > 0, the vectors 
point in roughly the same direction (less than 90 degree angle), if it 
is < 0, they point in opposite directions (greater than 90 degree 
angle). And there are many other uses...finding intersections with 
various objects, for example. (the plane intersection equation is little 
more than two dot products)

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Christopher James Huff
Subject: Re: normals function
Date: 14 Jan 2004 16:27:17
Message: <cjameshuff-375047.16273514012004@netplex.aussie.org>
In article <4001f8e5@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

> Christopher James Huff <cja### [at] earthlinknet> wrote:
> > Anyway, that means acos(A.x) means the same thing as acos(vdot(A, x)): 
> > the angle in radians between the vector and the x axis.
> 
>   Only if A is a unit vector. (If it isn't, you need to normalize
> it first.)

Right...I always forget to say that. And to clarify, it's only the part 
about the angle that's wrong: acos(A.x) only means the angle in radians 
if A is unit-length, it does mean the same thing as acos(vdot(A, x)). 
You need acos(A.x/vlength(A)) or acos(vdot(A, x)/vlength(A)). Or, given 
two arbitrary vectors, acos(vdot(A, B)/(vlength(A)*vlength(B)))

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

<<< Previous 4 Messages Goto Initial 10 Messages

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