|
![](/i/fill.gif) |
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] hotmail com
http://hjem.sol.no/t-o-k/tokpicts.html
http://www.crosswinds.net/~tok
Post a reply to this message
|
![](/i/fill.gif) |