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

Method Solve3PointCircle

Common/Core/vtkMath.cxx:3165–3199  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

3163
3164//------------------------------------------------------------------------------
3165double vtkMath::Solve3PointCircle(
3166 const double p1[3], const double p2[3], const double p3[3], double center[3])
3167{
3168 double v21[3], v32[3], v13[3];
3169 double v12[3], v23[3], v31[3];
3170 for (int i = 0; i < 3; ++i)
3171 {
3172 v21[i] = p1[i] - p2[i];
3173 v32[i] = p2[i] - p3[i];
3174 v13[i] = p3[i] - p1[i];
3175 v12[i] = -v21[i];
3176 v23[i] = -v32[i];
3177 v31[i] = -v13[i];
3178 }
3179
3180 double norm12 = vtkMath::Norm(v12);
3181 double norm23 = vtkMath::Norm(v23);
3182 double norm13 = vtkMath::Norm(v13);
3183
3184 double crossv21v32[3];
3185 vtkMath::Cross(v21, v32, crossv21v32);
3186 double normCross = vtkMath::Norm(crossv21v32);
3187
3188 double radius = (norm12 * norm23 * norm13) / (2. * normCross);
3189
3190 double alpha = ((norm23 * norm23) * vtkMath::Dot(v21, v31)) / (2. * normCross * normCross);
3191 double beta = ((norm13 * norm13) * vtkMath::Dot(v12, v32)) / (2. * normCross * normCross);
3192 double gamma = ((norm12 * norm12) * vtkMath::Dot(v13, v23)) / (2. * normCross * normCross);
3193
3194 for (int i = 0; i < 3; ++i)
3195 {
3196 center[i] = alpha * p1[i] + beta * p2[i] + gamma * p3[i];
3197 }
3198 return radius;
3199}
3200
3201//------------------------------------------------------------------------------
3202void vtkMath::PrintSelf(ostream& os, vtkIndent indent)

Callers

nothing calls this directly

Calls 3

NormFunction · 0.70
DotFunction · 0.70
CrossFunction · 0.50

Tested by

no test coverage detected