POV-Ray : Newsgroups : povray.advanced-users : Re: What is the frontside of a triangle? Server Time
25 Nov 2024 05:35:18 EST (-0500)
  Re: What is the frontside of a triangle? (Message 1 to 9 of 9)  
From: Tim Nikias v2 0
Subject: Re: What is the frontside of a triangle?
Date: 8 Jul 2003 12:56:00
Message: <3f0af7a0@news.povray.org>
The problem is how you define the triangle. Normally,
a triangle's corners are given in clockwise-direction
(or counterclockwise). The corners can then just be
fed into a little algorithm calculating the surface-normal,
and thus determine its front- and backside.
Normally, a program will require either clockwise or
counter-clockwise corners. I'm not too sure which approach
POV-Ray takes, but you could just experiment and find
out yourself.

Regards,
Tim

-- 
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights


> Hi,
>
> can anyone tell me how POV decide what the front or back side
> of a triangle is?
> I can't figure it out, because if you try the following code it changes
> every time.
> If you changes the triangle, then everything changes again.
>
> #declare TR1 =
> //  triangle {<0.1,0,0>, <0.1,1,0>, <1,1,-1>  // try this also
>   triangle {<0.1,0,0>, <0.1,1,0>, <1,1,1>
>     texture {
>       pigment { rgb <.2, .2, .8> }
>       finish {ambient 1} }
>    interior_texture {
>       pigment { rgb <.8, .8, .2> }
>       finish {ambient 1} }
>   }
>
> object { TR1 }
> object { TR1 rotate <0,180,0> }
> object { TR1 rotate <0,180,0> translate <0,1,0> }
> object { TR1 rotate <0,180,0> translate <-1,0,0> }
> object { TR1 translate <0,-1,0> }
> object { TR1 translate <0,-1,0> rotate <0,180,0> }
> object { TR1 translate <0,-1,0> rotate <0,180,0>
>              translate <-1,0,0> }
> object { TR1 translate <0,-1,0> rotate <0,180,0>
>              translate <-1,-1,0> rotate <0,180,0> }
>
> camera { location <0.0, 0.0, -5.0>
>          right x*image_width/image_height
>          look_at   <0.0, 0.0,  0.0> }
>
>
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.495 / Virus Database: 294 - Release Date: 30.06.2003


Post a reply to this message

From: ABX
Subject: Re: What is the frontside of a triangle?
Date: 8 Jul 2003 12:58:43
Message: <estlgv4fv47b0959hobe61tcgql5he8q4a@4ax.com>
On Tue, 8 Jul 2003 18:44:14 +0200, "Jaap Frank" <jjf### [at] xs4allnl> wrote:
> can anyone tell me how POV decide what the front or back side
> of a triangle is?

The answer is hidden in manual in first sentence of "6.5.2 Finite Patch
Primitives" chapter  :-)

ABX


Post a reply to this message

From: Christopher James Huff
Subject: Re: What is the frontside of a triangle?
Date: 8 Jul 2003 13:03:34
Message: <cjameshuff-498B38.12010308072003@netplex.aussie.org>
In article <3f0af44b@news.povray.org>, "Jaap Frank" <jjf### [at] xs4allnl> 
wrote:

> can anyone tell me how POV decide what the front or back side
> of a triangle is?

It does it by taking the cross product of two sides of the triangle. The 
"front" or "outside is determined by the order of the vertices. 
"triangle {A, B, C}" faces in the opposite direction of  "triangle {A, 
C, B}".

I think the side from which the vertices appear to wind counterclockwise 
is the one that is "outside", but you should test it to be sure.

-- 
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: Shay
Subject: Re: What is the frontside of a triangle?
Date: 8 Jul 2003 14:29:58
Message: <3f0b0da6@news.povray.org>
"Tim Nikias v2.0" <tim### [at] gmxde> wrote in message
news:3f0af7a0@news.povray.org...
| Normally, a program will require either clockwise or
| counter-clockwise corners. I'm not too sure which
| approach POV-Ray takes, but you could just experiment
| and find out yourself.
|

This only works in POV-Ray when the triangles are within a mesh
statement. A union of triangles, or a list of triangles as in the
example behaves differently.

 -Shay


Post a reply to this message

From: Jaap Frank
Subject: Re: What is the frontside of a triangle?
Date: 8 Jul 2003 14:53:55
Message: <3f0b1343$1@news.povray.org>
"Shay" <sah### [at] simcopartscom> wrote in message news:3f0b0da6@news.povray.org...
>
> "Tim Nikias v2.0" <tim### [at] gmxde> wrote in message
> news:3f0af7a0@news.povray.org...
> | Normally, a program will require either clockwise or
> | counter-clockwise corners. I'm not too sure which
> | approach POV-Ray takes, but you could just experiment
> | and find out yourself.
> |
>
> This only works in POV-Ray when the triangles are within a mesh
> statement. A union of triangles, or a list of triangles as in the
> example behaves differently.
>
>  -Shay

I'm afraid this isn't correct for meshes too.
See my conversation with ABX.
The 'inside_vector' by the way, doesn't help to determine
the inside or outside of the triangles for the textures. I think
it's used for CSG only.

Jaap Frank


Post a reply to this message

From: Shay
Subject: Re: What is the frontside of a triangle?
Date: 8 Jul 2003 15:19:10
Message: <3f0b192e@news.povray.org>
"Jaap Frank" <jjf### [at] xs4allnl> wrote in message
news:3f0b1343$1@news.povray.org...
|
| I'm afraid this isn't correct for meshes too.

I'm not making this up.
Cut and paste this code:

camera {location <0,0,-5>  look_at <0,0,0>}

#local P1a = <-2,0,0>;
#local P2a = <0,0,0>;
#local P3a = <-1,1,0>;

#local P1b = P1a+<2,0,0>;
#local P2b = P2a+<2,0,0>;
#local P3b = P3a+<2,0,0>;

#local OuTex = texture{pigment{rgb <1,0,0>}finish{ambient 1}}
#local InTex = texture{pigment{rgb <0,1,0>}finish{ambient 1}}

union { // ignores point order
  triangle {P1a, P2a, P3a}
  triangle {P1b, P3b, P2b}
  texture{OuTex} interior_texture{InTex}
  translate <0,1,0>
}

mesh { // uses point order
  triangle {P1a, P2a, P3a}
  triangle {P1b, P3b, P2b}
  texture{OuTex} interior_texture{InTex}
  translate <0,-1,0>
}

 -Shay


Post a reply to this message

From: Jaap Frank
Subject: Re: What is the frontside of a triangle?
Date: 8 Jul 2003 17:07:37
Message: <3f0b3299$1@news.povray.org>
"Shay" <sah### [at] simcopartscom> wrote in message news:3f0b192e@news.povray.org...
>
> Cut and paste this code:
>
> camera {location <0,0,-5>  look_at <0,0,0>}
>
>   texture{OuTex} interior_texture{InTex}
>   .....
>   translate <0,-1,0>
> }
>
I've changed some things.
The union is plane wrong. The order of transformations
give different results too.
But I think something goes wrong with the mesh too.
If the order of the vertices fixes the front side, then
rotation should give the other sides, but this does not happen,
or am I thinking wrong?

// Changed code of Shay:
camera {location <0,0,-8>  look_at <0,0,0>}

#local P1a = <-2,2.5,0>;
#local P2a = <0,2.5,0>;
#local P3a = <-1,3.5,0>;

#local P1b = P1a+<2,0,0>;
#local P2b = P2a+<2,0,0>;
#local P3b = P3a+<2,0,0>;

#local T = <0,4,0>;

#local OuTex = texture{pigment{rgb <1,0,0>}finish{ambient 1}}
#local InTex = texture{pigment{rgb <0,1,0>}finish{ambient 1}}

union { // ignores point order
  triangle {P1a, P2a, P3a}
  triangle {P1b, P3b, P2b}
  texture{OuTex} interior_texture{InTex}
}

union { // ignores point order
  triangle {P1a, P2a, P3a}
  triangle {P1b, P3b, P2b}
  texture{OuTex} interior_texture{InTex}
  translate <0,-1,0>  rotate <0,180,0>
}

union { // ignores point order
  triangle {P1a, P2a, P3a}
  triangle {P1b, P3b, P2b}
  texture{OuTex} interior_texture{InTex}
   rotate <0,180,0> translate <0,-2,0>
}

mesh { // uses point order
  triangle {P1a-T, P2a-T, P3a-T}
  triangle {P1b-T, P3b-T, P2b-T}
  texture{OuTex} interior_texture{InTex}
}

mesh { // uses point order
  triangle {P1a-T, P2a-T, P3a-T}
  triangle {P1b-T, P3b-T, P2b-T}
  texture{OuTex} interior_texture{InTex}
  rotate <0,180,0> translate <0,-1,0>
}

mesh { // uses point order
  triangle {P1a-T, P2a-T, P3a-T}
  triangle {P1b-T, P3b-T, P2b-T}
  texture{OuTex} interior_texture{InTex}
  translate <0,-2,0> rotate <0,180,0>
}


Jaap Frank


Post a reply to this message

From: Shay
Subject: Re: What is the frontside of a triangle?
Date: 8 Jul 2003 17:22:37
Message: <3f0b361d@news.povray.org>
"Jaap Frank" <jjf### [at] xs4allnl> wrote in message
news:3f0b3299$1@news.povray.org...

I looked at your code, and the mesh behaves perfectly. Remember that the
"back" of the red triangle is green and vice-versa. This means that when
you flip the two of them <0,180,0>, you will see an image which looks
the same as before the flip. Try rotating by <180,0,0> (before
subtracting T) and see what I mean.

 -Shay


Post a reply to this message

From: Jaap Frank
Subject: Re: What is the frontside of a triangle?
Date: 8 Jul 2003 17:37:17
Message: <3f0b398d@news.povray.org>
"Shay" <sah### [at] simcopartscom> wrote in message news:3f0b361d@news.povray.org...
>
> "Jaap Frank" <jjf### [at] xs4allnl> wrote in message
> news:3f0b3299$1@news.povray.org...
>
> I looked at your code, and the mesh behaves perfectly. Remember that the
> "back" of the red triangle is green and vice-versa. This means that when
> you flip the two of them <0,180,0>, you will see an image which looks
> the same as before the flip. Try rotating by <180,0,0> (before
> subtracting T) and see what I mean.
>
>  -Shay

After rotating my mind with <0,180,0> I see that you are right.
Now I've to figure out what's going on in my mesh.

Thanks,

Jaap Frank


Post a reply to this message

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