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]) ...@@ -56,22 +56,19 @@ void vtkPlane::ProjectPoint(double x[3], double xproj[3])
this->ProjectPoint(x, this->GetOrigin(), this->GetNormal(), xproj); this->ProjectPoint(x, this->GetOrigin(), this->GetNormal(), xproj);
} }
void vtkPlane::ProjectVector(double v[3], double origin[3], double normal[3], void vtkPlane::ProjectVector(
double vproj[3]) double v[3], double vtkNotUsed(origin)[3], double normal[3],
double vproj[3])
{ {
(void)origin; double t = vtkMath::Dot(v, normal);
double n2 = vtkMath::Dot(normal, normal);
// This function uses this equation: if (n2 == 0)
// projected = vector - (vector dot Normal)Normal {
// Where 'Normal' is unit length n2 = 1.0;
}
vtkMath::Normalize(normal); vproj[0] = v[0] - t * normal[0] / n2;
vproj[1] = v[1] - t * normal[1] / n2;
double dotProd = vtkMath::Dot(v, normal); vproj[2] = v[2] - t * normal[2] / n2;
vtkMath::MultiplyScalar(normal, dotProd);
vtkMath::Subtract(v, normal, vproj);
} }
void vtkPlane::ProjectVector(double v[3], double vproj[3]) 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