1 #ifndef LOWSTRETCHTORUSPARAMETRIZATION_HEADER
2 #define LOWSTRETCHTORUSPARAMETRIZATION_HEADER
23 std::pair< float, float >* param)
const;
27 float epsilon,
bool* uwrap,
bool* vwrap)
const
33 float epsilon,
size_t uextent,
size_t vextent,
36 template<
class IteratorT >
37 void Optimize(IteratorT begin, IteratorT end,
float epsilon);
39 void Serialize(std::ostream* o,
bool binary)
const;
43 float MinorFrameRotation()
const;
44 float MajorFrameRotation()
const;
53 std::pair< float, float >* param)
const
56 float planex =
s.dot(m_hcs[0].Data());
57 float planey =
s.dot(m_hcs[1].Data());
58 param->first = std::atan2(planey, planex);
62 float majorRadiusAngle = std::atan2(minorVec[1], minorVec[0]);
63 m_minorFrame.ToLocal(minorVec, &minorL);
64 param->second = std::atan2(minorL[1], minorL[0]);
73 + std::cos(majorRadiusAngle) * m_torus->
MinorRadius();
74 param->first = param->first * majorRadius;
82 minorL[0] = std::cos(vangle);
83 minorL[1] = std::sin(vangle);
84 m_minorFrame.ToGlobal(minorL, &minorVec);
85 float majorRadiusAngle = std::atan2(minorVec[1], minorVec[0]);
91 + std::cos(majorRadiusAngle) * m_torus->
MinorRadius();
92 float uangle = u / majorRadius;
105 minorL[0] = std::cos(vangle);
106 minorL[1] = std::sin(vangle);
107 m_minorFrame.ToGlobal(minorL, &minorVec);
108 float majorRadiusAngle = std::atan2(minorVec[1], minorVec[0]);
115 + std::cos(majorRadiusAngle) * m_torus->
MinorRadius();
116 float uangle = u / majorRadius;
125 template<
class IteratorT >
136 for (IteratorT i = begin; i != end; ++i, ++j)
139 float planex =
s.dot(nframe[0].Data());
140 float planey =
s.dot(nframe[1].Data());
141 uangles[j] = std::atan2(planey, planex);
145 vangles[j] = std::atan2(minorVec[1], minorVec[0]);
153 std::sort(vangles.
begin(), vangles.
end());
154 std::sort(uangles.begin(), uangles.end());
156 float maxGap = uangles.front() + 2 *
float(
M_PI) - uangles.back();
157 float lower = uangles.back(), upper = uangles.front() + 2 *
float(
M_PI);
158 for (
size_t i = 1; i < uangles.size(); ++i)
160 float gap = uangles[i] - uangles[i - 1];
164 lower = uangles[i - 1];
169 float rotationAngle = (lower + upper) / 2;
170 nframe.RotateOnNormal(rotationAngle +
float(
M_PI));
171 m_hcs[0] = nframe[0];
172 m_hcs[1] = nframe[1];
175 lower = vangles.
back();
177 for (
size_t i = 1; i < vangles.
size(); ++i)
179 float gap = vangles[i] - vangles[i - 1];
183 lower = vangles[i - 1];
187 rotationAngle = (lower + upper) / 2;
188 m_minorFrame.Canonical();
189 m_minorFrame.RotateFrame(rotationAngle +
float(
M_PI));