MCPcopy Create free account
hub / github.com/Kitware/VTK / SetNormal

Method SetNormal

Filters/Sources/vtkPlaneSource.cxx:199–235  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Set the normal to the plane. Will modify the Origin, Point1, and Point2 instance variables as necessary (i.e., rotate the plane around its center).

Source from the content-addressed store, hash-verified

197// Set the normal to the plane. Will modify the Origin, Point1, and Point2
198// instance variables as necessary (i.e., rotate the plane around its center).
199void vtkPlaneSource::SetNormal(double N[3])
200{
201 double n[3], rotVector[3], theta;
202
203 // make sure input is decent
204 n[0] = N[0];
205 n[1] = N[1];
206 n[2] = N[2];
207 if (vtkMath::Normalize(n) == 0.0)
208 {
209 vtkErrorMacro(<< "Specified zero normal");
210 return;
211 }
212
213 // Compute rotation vector using a transformation matrix.
214 // Note that if normals are parallel then the rotation is either
215 // 0 or 180 degrees.
216 double dp = vtkMath::Dot(this->Normal, n);
217 if (dp >= 1.0)
218 {
219 return; // zero rotation
220 }
221 else if (dp <= -1.0)
222 {
223 theta = 180.0;
224 rotVector[0] = this->Point1[0] - this->Origin[0];
225 rotVector[1] = this->Point1[1] - this->Origin[1];
226 rotVector[2] = this->Point1[2] - this->Origin[2];
227 }
228 else
229 {
230 vtkMath::Cross(this->Normal, n, rotVector);
231 theta = vtkMath::DegreesFromRadians(acos(dp));
232 }
233
234 this->Rotate(theta, rotVector);
235}
236
237//------------------------------------------------------------------------------
238// Set the normal to the plane. Will modify the Origin, Point1, and Point2

Callers 15

AppendMethod · 0.45
rectGrid.pyFile · 0.45
testClipMethod · 0.45
testCutMethod · 0.45
testUnstructuredMethod · 0.45
testClipOnNormalMethod · 0.45
TestClipOutline.pyFile · 0.45
test_clipMethod · 0.45
test_tablebasedclipMethod · 0.45

Calls 5

RotateMethod · 0.95
NormalizeFunction · 0.50
DotFunction · 0.50
CrossFunction · 0.50
acosFunction · 0.50

Tested by 15

test_clipMethod · 0.36
test_tablebasedclipMethod · 0.36
ReflectFunction · 0.36
TestUnstructuredGridFunction · 0.36
TestClipClosedSurface1Function · 0.36
TestClipClosedSurface2Function · 0.36
TestArcSourceFunction · 0.36
TestPlaneSourceFunction · 0.36
TestEllipseArcSourceFunction · 0.36