POV-Ray : Newsgroups : povray.general : Suggestion for new object : Re: Suggestion for new object Server Time
14 Aug 2024 01:20:23 EDT (-0400)
  Re: Suggestion for new object  
From: Mark R 
Date: 15 Jul 1998 23:26:58
Message: <35AD650C.201A891A@usa.net>
Here's a rather altered version of Colefax's metabox macro, which I changed to
work create a tetrahedron. I haven't tested it a whole lot and I'm not certain
that the signs in front of the 'vcross' functions are right all the time--I
arrived at this by more trial and error than I would like--but it *seems* to
work. Anyway, the syntax would be

tetrahedron (P1, P2, P3, P4)

and as far as I can tell, the order of the points doesn't matter.

//-----------Tetrahedron Macro

#macro tetrahedron (P1, P2, P3, P4)
	#local _TH_centroid = (P1 + P2 + P3 + P4) / 4;
	#local _TH_normal1 = vcross(P2 - P3, P2 - P4);
	#local _TH_normal2 = -vcross(P1 - P3, P1 - P4);
	#local _TH_normal3 = vcross(P1 - P4, P2 - P4);
	#local _TH_normal4 = -vcross(P1 - P3, P2 - P3);

#if (vdot(_TH_normal1,_TH_centroid) > vdot(_TH_normal1,P2))
	#local _TH_normal1 = 0 - _TH_normal1;
#end
#if (vdot(_TH_normal2,_TH_centroid) > vdot(_TH_normal2,P1))
	#local _TH_normal2 = 0 - _TH_normal2;
#end
#if (vdot(_TH_normal3,_TH_centroid) > vdot(_TH_normal3,P2))
	#local _TH_normal3 = 0 - _TH_normal3;
#end
#if (vdot(_TH_normal4,_TH_centroid) > vdot(_TH_normal4,P2))
	#local _TH_normal4 = 0 - _TH_normal4;
#end

intersection {
  plane {_TH_normal1, 0 translate P2}
  plane {_TH_normal2, 0 translate P1}
  plane {_TH_normal3, 0 translate P1}
  plane {_TH_normal4, 0 translate P1} }
#end


Post a reply to this message

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