nvidia-texture-tools/src/nvmath/Plane.cpp

28 lines
748 B
C++
Raw Normal View History

2008-04-17 06:58:43 +00:00
// This code is in the public domain -- castanyo@yahoo.es
#include "Plane.h"
#include "Plane.inl"
2008-04-17 06:58:43 +00:00
#include "Matrix.h"
namespace nv
{
2010-05-27 23:19:24 +00:00
Plane transformPlane(const Matrix& m, Plane::Arg p)
{
Vector3 newVec = transformVector(m, p.vector());
2008-04-17 06:58:43 +00:00
2010-05-27 23:19:24 +00:00
Vector3 ptInPlane = p.offset() * p.vector();
ptInPlane = transformPoint(m, ptInPlane);
2008-04-17 06:58:43 +00:00
2010-05-27 23:19:24 +00:00
return Plane(newVec, ptInPlane);
}
Vector3 planeIntersection(Plane::Arg a, Plane::Arg b, Plane::Arg c)
{
return dot(a.vector(), cross(b.vector(), c.vector())) * (
a.offset() * cross(b.vector(), c.vector()) +
c.offset() * cross(a.vector(), b.vector()) +
b.offset() * cross(c.vector(), a.vector()));
}
} // nv namespace