Files
Webcam/include/framework/geometry/plane.cpp

47 lines
1.1 KiB
C++

/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#include "geometry/plane.h"
#include "math/matrix4.h"
using namespace GS;
//------------------------------------------------------------------------------
void Plane::Set(const Vector4 *_p, const Vector4 &_n, const Matrix4 *mtx)
{
if (mtx)
{
if (_p)
mtx->Apply(&p, _p);
else p = mtx->GetRow(3);
mtx->ApplyRotation(&n, &_n);
}
else
{
if (_p)
p = *_p;
else p.Set(0, 0, 0, 1);
n = _n;
}
d = -p.Dot(n);
}
void Plane::Set(const Vector4 _p[3], const Matrix4 *mtx)
{
Vector4 _n = (_p[1] - _p[0]).Cross(_p[2] - _p[0]);
Set(&_p[0], _n, mtx);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
Plane::Plane()
{
d = 0;
p.Set();
n.Set();
}
//------------------------------------------------------------------------------