POV-Ray : Newsgroups : povray.advanced-users : A macro I'm proud of I think (public Beta) : Re: A macro I'm proud of I think (public Beta) Server Time
30 Jul 2024 00:31:30 EDT (-0400)
  Re: A macro I'm proud of I think (public Beta)  
From: Tor Olav Kristensen
Date: 3 May 2001 20:19:31
Message: <3AF1F567.A679D7E2@hotmail.com>
Dan Johnson wrote:
> 
> A while ago I was working on a big complicated image, and I wanted
> to make a precise plane intersection shape far away from the origin.
> I quickly realized that although I knew exact locations, planes are
> described around the origin.  It only takes three points to define 
> a plane, but for use in plane intersections there is an inside and
> an outside, so I decided to use a fourth point to decide witch side
> of the plane is inside.  I thought I could write a macro to do it in
> 15 minutes, I was very wrong.  I think it finally works now, but I
> thought that a few days ago before I found some huge bugs.  If you
> find any bugs or have suggestions, please comment.
>...

I think that the macro below will do the same.


#macro FourPointPlane(p1, p2, p3, pInside)

  #local vA = p2 - p1;
  #local vB = p3 - p1;
  #local vC = pInside - p1;
  #local vN = vcross(vA, vB);
  #local STP = vdot(vN, vC); // Scalar Triple Product of vA, vB and vC
  #if (STP = 0) // Check for coplanar vectors
    #error "\nMacro FourPointPlane: All points lie in the same plane.\n"
  #else
    #local vN = (STP > 0 ? -1 : 1)*vnormalize(vN);
    plane { vN, vdot(p1, vN) }
  #end // if

#end // macro FourPointPlane


- But I haven't tested it much. Sorry.

I also have some suggestions for some of
your support macros if you are interested.


-- 
Best regards,

Tor Olav

mailto:tor### [at] hotmailcom
http://hjem.sol.no/t-o-k/tokpicts.html
http://www.crosswinds.net/~tok


Post a reply to this message

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