Commit 00e31d88 authored by David Gobbi's avatar David Gobbi Committed by Code Review
Browse files

Merge topic 'plane-project-vector' into master

ba3c24c3 ProjectVector method was modifying plane normal.
parents d9bd55f5 ba3c24c3
......@@ -56,22 +56,19 @@ void vtkPlane::ProjectPoint(double x[3], double xproj[3])
this->ProjectPoint(x, this->GetOrigin(), this->GetNormal(), xproj);
}
void vtkPlane::ProjectVector(double v[3], double origin[3], double normal[3],
double vproj[3])
void vtkPlane::ProjectVector(
double v[3], double vtkNotUsed(origin)[3], double normal[3],
double vproj[3])
{
(void)origin;
// This function uses this equation:
// projected = vector - (vector dot Normal)Normal
// Where 'Normal' is unit length
vtkMath::Normalize(normal);
double dotProd = vtkMath::Dot(v, normal);
vtkMath::MultiplyScalar(normal, dotProd);
vtkMath::Subtract(v, normal, vproj);
double t = vtkMath::Dot(v, normal);
double n2 = vtkMath::Dot(normal, normal);
if (n2 == 0)
{
n2 = 1.0;
}
vproj[0] = v[0] - t * normal[0] / n2;
vproj[1] = v[1] - t * normal[1] / n2;
vproj[2] = v[2] - t * normal[2] / n2;
}
void vtkPlane::ProjectVector(double v[3], double vproj[3])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment