POV-Ray : Newsgroups : povray.advanced-users : Can't figure out a formula! : Can't figure out a formula! Server Time
30 Jul 2024 14:28:10 EDT (-0400)
  Can't figure out a formula!  
From: Jeff Lee
Date: 19 May 1999 13:22:04
Message: <3742e52c.0@news.povray.org>
Hi there,

I have a sinking feeling that this is a pathetically basic question,
though I know the advanced users have the best background to answer it,
which is why I'm posting it here:

I'm trying to write a macro that takes three points, and creates a plane
which is rotated and translated to intersect all three points.  Now, I
think I've figured out how to get the normal of the triangle described
by the points, but I'm not sure exactly how to turn that into an angle.

Here's what I've got so far:

#macro safeatan(a,b) #if (a|b) degrees(atan2(a,b)) #else 0.0 #end #end

#macro MakePlane( a, b, c )
  #local n = vnormalize( vcross( b-a, c-a ));
  #debug concat( "Normal: <", str(n.x,0,5), ",", str(n.y,0,5),",",
str(n.z,0,5),">\n" )

  #local d  = <safeatan(n.z,n.y),      // This is the bit that needs
               180+safeatan(n.x,n.z),  //  help.
               -safeatan(n.x,n.y)>;

  #debug concat( "Angle: <", str(d.x,0,5), ",", str(d.y,0,5),",",
str(d.z,0,5),">\n" )

  plane { y, 0 rotate d translate a }
#end

Any help would be greatly appreciated.


-- 
Jeff Lee         shi### [at] gatenet         http://www.gate.net/~shipbrk/


Post a reply to this message

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