Exemple #1
0
Plane& Plane::setFromCoplanarPoints( const Vector3& a, const Vector3& b, const Vector3& c) {

  auto v1 = Vector3();
  auto v2 = Vector3();

  auto normal = v1.subVectors( c, b ).cross( v2.subVectors( a, b ) ).normalize();

  // Q: should an error be thrown if normal is zero (e.g. degenerate plane)?
  setFromNormalAndCoplanarPoint( normal, a );

  return *this;

}
Exemple #2
0
Plane& Plane::applyMatrix4( const Matrix4& matrix, const Matrix3& normalMatrix) {

  auto v1 = Vector3();
  auto v2 = Vector3();
  //auto m1 = Matrix3();

  // compute new normal based on theory here:
  // http://www.songho.ca/opengl/gl_normaltransform.html
  auto newNormal = v1.copy( normal ).applyMatrix3( normalMatrix );

  auto newCoplanarPoint = coplanarPoint( v2 );
  newCoplanarPoint.applyMatrix4( matrix );

  setFromNormalAndCoplanarPoint( newNormal, newCoplanarPoint );

  return *this;

}
Exemple #3
0
Plane& Plane::applyMatrix4(const Matrix4& matrix, const Matrix3* optionalNormalMatrix)
{
    Vector3 v1;
    Vector3 v2;

    // compute new normal based on theory here:
    // http://www.songho.ca/opengl/gl_normaltransform.html
    Matrix3 normalMatrix;
    if (!optionalNormalMatrix) {
        optionalNormalMatrix = &(normalMatrix.getNormalMatrix(matrix));
    }
    Vector3 newNormal = v1.copy( normal() ).applyMatrix3( *optionalNormalMatrix );

    Vector3 newCoplanarPoint = coplanarPoint();
    newCoplanarPoint.applyMatrix4( matrix );

    setFromNormalAndCoplanarPoint( newNormal, newCoplanarPoint );

    return *this;
}