MCPcopy Create free account
hub / github.com/BIMCoderLiang/LNLib / ComputeTangent

Method ComputeTangent

src/LNLib/Algorithm/Interpolation.cpp:348–376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

346}
347
348bool LNLib::Interpolation::ComputeTangent(const std::vector<XYZ>& throughPoints, std::vector<XYZ>& tangents)
349{
350 int size = throughPoints.size();
351 if (size < 5) return false;
352
353 tangents.resize(size);
354 for (int k = 2; k < size - 2; k++)
355 {
356 LNLib::XYZ qk_1 = Getqk(throughPoints, k - 1);
357 LNLib::XYZ qk = Getqk(throughPoints, k);
358 LNLib::XYZ qk1 = Getqk(throughPoints, k + 1);
359 LNLib::XYZ qk2 = Getqk(throughPoints, k + 2);
360
361 tangents[k] = GetTk(qk_1, qk, qk1, qk2);
362 }
363
364 int n = size - 1;
365 LNLib::XYZ q0 = 2 * Getqk(throughPoints, 1) - Getqk(throughPoints, 2);
366 LNLib::XYZ q_1 = 2 * q0 - Getqk(throughPoints, 1);
367 LNLib::XYZ qn1 = 2 * Getqk(throughPoints, n) - Getqk(throughPoints, n - 1);
368 LNLib::XYZ qn2 = 2 * qn1 - Getqk(throughPoints, n);
369
370 tangents[0] = GetTk(q_1, q0, Getqk(throughPoints, 1), Getqk(throughPoints, 2));
371 tangents[1] = GetTk(q0, Getqk(throughPoints, 1), Getqk(throughPoints, 2), Getqk(throughPoints, 3));
372 tangents[n - 1] = GetTk(Getqk(throughPoints, n - 2), Getqk(throughPoints, n - 1), Getqk(throughPoints, n), qn1);
373 tangents[n] = GetTk(Getqk(throughPoints, n - 1), Getqk(throughPoints, n), qn1, qn2);
374
375 return true;
376}
377
378std::vector<LNLib::XYZ> LNLib::Interpolation::ComputeTangent(const std::vector<XYZ>& throughPoints)
379{

Callers

nothing calls this directly

Calls 3

GetqkFunction · 0.85
GetTkFunction · 0.85
XYZClass · 0.50

Tested by

no test coverage detected