POV-Ray : Newsgroups : povray.general : Constructing a solid tetrahedron by 4 triangles Server Time
2 Nov 2024 15:27:17 EDT (-0400)
  Constructing a solid tetrahedron by 4 triangles (Message 1 to 7 of 7)  
From: Amir ni
Subject: Constructing a solid tetrahedron by 4 triangles
Date: 5 Feb 2009 07:45:01
Message: <web.498adf1b1f5de9ab792c7d270@news.povray.org>
Hi friends, I wanna make a solid tetrahedron using 4 triangles. I am using the
following code, but the object's inside is empty (I noticed it, when I used
difference command to subtract 4 spheres from the tetrahedron.


This is the code I am using:



//---------------------------------------
global_settings {  assumed_gamma 1.0 }

#include "colors.inc"

//---------------------------------------
camera{ ultra_wide_angle
        angle 75
        right x*image_width/image_height
     location  <2 , 3 , -4>
        look_at   <0,0,0> }
//---------------------------------------
light_source{ <0,0,-2500>
              color rgb<1,1,1> }
//---------------------------------------
background {color  rgb<1,1,1>}
//---------------------------------------

#declare d =1.05;



difference{

 object{
  union {
   triangle { < 1,  1,  1>,  <-1,  1, -1>,  < 1, -1, -1> }
   triangle { <-1,  1, -1>,  <-1, -1,  1>,  < 1, -1, -1> }
   triangle { < 1,  1,  1>,  < 1, -1, -1>,  <-1, -1,  1> }
   triangle { < 1,  1,  1>,  <-1, -1,  1>,  <-1,  1, -1> }
  }
  pigment{ color rgb<1,0,0> }
 }


 sphere { < 1,  1,  1> , d}
 sphere { <1,  -1, -1> ,  d}
 sphere {  < -1,  1,  -1> ,  d}
 sphere { <  -1,  -1,  1> ,  d}

}


Post a reply to this message

From: m a r c
Subject: Re: Constructing a solid tetrahedron by 4 triangles
Date: 5 Feb 2009 09:55:43
Message: <498afdef@news.povray.org>

web.498adf1b1f5de9ab792c7d270@news.povray.org...
> Hi friends, I wanna make a solid tetrahedron using 4 triangles. I am using 
> the
> following code, but the object's inside is empty (I noticed it, when I 
> used
> difference command to subtract 4 spheres from the tetrahedron.
>
You should arrange your triangles as a mesh instead a union.
then put a inside_vector after triangle definitions this way

Marc

difference{

 object{
  mesh {
   triangle { < 1,  1,  1>,  <-1,  1, -1>,  < 1, -1, -1> }
   triangle { <-1,  1, -1>,  <-1, -1,  1>,  < 1, -1, -1> }
   triangle { < 1,  1,  1>,  < 1, -1, -1>,  <-1, -1,  1> }
   triangle { < 1,  1,  1>,  <-1, -1,  1>,  <-1,  1, -1> }
 inside_vector z
  }

  pigment{ color rgb<1,0,0> }

 }


 sphere { < 1,  1,  1> , d}
 sphere { <1,  -1, -1> ,  d}
 sphere {  < -1,  1,  -1> ,  d}
 sphere { <  -1,  -1,  1> ,  d}

}


Post a reply to this message

From: m a r c
Subject: Re: Constructing a solid tetrahedron by 4 triangles
Date: 5 Feb 2009 09:58:34
Message: <498afe9a@news.povray.org>

498afdef@news.povray.org...
>
oh and if you want your whole object to have the same pigment, put the 
pigment in the CSG rather than in the mesh

Marc


Post a reply to this message

From: stevenvh
Subject: Re: Constructing a solid tetrahedron by 4 triangles
Date: 5 Feb 2009 11:30:03
Message: <web.498b133ff5dfc3fc0721a1d0@news.povray.org>
"Amir_ni" <nomail@nomail> wrote:
> Hi friends, I wanna make a solid tetrahedron using 4 triangles. I am using the
> following code, but the object's inside is empty (I noticed it, when I used

This generic pyramid is solid (CSG):

// pyramid 1 unit high, 1 unit radius
#macro Pyramid_N ( NSides )
  #local Height = 1;
  #local Radius = 1/2;
  #local SW2 = Radius * cos( 2 * pi / NSides / 2 );
  #local SW = 2 * SW2;
  #local Alpha_rad = atan( SW / Height );
  #local Alpha_deg = Alpha_rad * 180 / pi;
  #local H2 = 1.01 * Height / cos ( Alpha_rad );

  #local Side = 0;
  intersection {
    #while (Side < NSides)
      box { < -2, 0, -2 >, < 0, 2, 2 >
        rotate z * Alpha_deg  translate SW2 * x  rotate y * ( Side * 360 /
NSides )
      }
      #local Side = Side + 1;
    #end
    cylinder { 0 < 0, Height + 1.01, 0 > Radius }
    rotate y * 360 / NSides / 2
  }
#end

object {
  Pyramid_N (4)
  pigment { color Red }
}


Post a reply to this message

From: Amir ni
Subject: Re: Constructing a solid tetrahedron by 4 triangles
Date: 5 Feb 2009 12:45:05
Message: <web.498b24a6f5dfc3f792c7d270@news.povray.org>
Marc,Steven! Thanks for your help. good luck!


Post a reply to this message

From: clipka
Subject: Re: Constructing a solid tetrahedron by 4 triangles
Date: 6 Feb 2009 11:55:00
Message: <web.498c6a9af5dfc3fbdc576310@news.povray.org>
"Amir_ni" <nomail@nomail> wrote:
> Hi friends, I wanna make a solid tetrahedron using 4 triangles. I am using the
> following code, but the object's inside is empty (I noticed it, when I used
> difference command to subtract 4 spheres from the tetrahedron.

Try using a mesh or mesh2 object instead; they are fully "inside aware" if your
mesh is closed.


Post a reply to this message

From: Nicolas George
Subject: Re: Constructing a solid tetrahedron by 4 triangles
Date: 6 Feb 2009 15:52:55
Message: <498ca327$1@news.povray.org>
"Amir_ni"  wrote in message
<web.498adf1b1f5de9ab792c7d270@news.povray.org>:
> Hi friends, I wanna make a solid tetrahedron using 4 triangles. I am using the
> following code, but the object's inside is empty (I noticed it, when I used
> difference command to subtract 4 spheres from the tetrahedron.

I am pretty sure the "correct" way to do a tetrahedron is the intersection
of four planes (which, fortunately, are actually half-spaces; otherwise, the
previous sentence would be mathematically stupid).


Post a reply to this message

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