POV-Ray : Newsgroups : povray.general : normals function Server Time
7 Nov 2024 04:52:42 EST (-0500)
  normals function (Message 1 to 10 of 14)  
Goto Latest 10 Messages Next 4 Messages >>>
From: m1j
Subject: normals function
Date: 9 Jan 2004 21:00:02
Message: <web.3fff5c25782a2a3b6b19de950@news.povray.org>
Does povray have a built in function to calculate the norm of a triangle
from 3 vectors?

If not how whould I do this. I am not finding or understanding how to do
this.


Post a reply to this message

From: Tim Nikias v2 0
Subject: Re: normals function
Date: 9 Jan 2004 21:13:53
Message: <3fff5fe1$1@news.povray.org>
> Does povray have a built in function to calculate the norm of a triangle
> from 3 vectors?
>
> If not how whould I do this. I am not finding or understanding how to do
> this.

It's actually very easy with POV-SDL when you know where the three corners
are: First, generate two vectors: Point 2 minus Point 1, that's Vector one,
and Point 3 minus Point 1, that's Vector 2. Now, use vcross(Vector1,
Vector2) and voila! You've got the surface normal.

With a little research using google and the internet, you'd find more
insightful information, but that's simply a basic approach.

vcross calculates the cross-product of two vectors, which is actually a
vector, which is perpendicular to both given vectors. And how did you get
these? Subtracting one point from another calculates a vector which is
actually the direction and distance from Point 1 to point 2 and 3 (when you
do Point3-Point1, its actually "going from Point1 to Point3" what you get,
hence subtracting the same point from the other two, but that doesn't really
matter for the cross-product).

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>
Email: tim.nikias (@) nolights.de


Post a reply to this message

From: Warp
Subject: Re: normals function
Date: 9 Jan 2004 21:20:18
Message: <3fff6162@news.povray.org>
m1j <mik### [at] hotmailcom> wrote:
> Does povray have a built in function to calculate the norm of a triangle
> from 3 vectors?

  vcross(Vertex2-Vertex1, Vertex3-Vertex1)

> If not how whould I do this. I am not finding or understanding how to do
> this.

  Some high-school level math book is very useful for these things...

-- 
#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: m1j
Subject: Re: normals function
Date: 10 Jan 2004 13:50:01
Message: <web.400049479e7183876b19de950@news.povray.org>
Warp wrote:
>m1j <mik### [at] hotmailcom> wrote:
>> Does povray have a built in function to calculate the norm of a triangle
>> from 3 vectors?
>
>  vcross(Vertex2-Vertex1, Vertex3-Vertex1)
>
>> If not how whould I do this. I am not finding or understanding how to do
>> this.
>
>  Some high-school level math book is very useful for these things...

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.
>
>#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: 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

Goto Latest 10 Messages Next 4 Messages >>>

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