1 #ifndef LOWSTRETCHSPHEREPARAMETRIZATION_HEADER
2 #define LOWSTRETCHSPHEREPARAMETRIZATION_HEADER
22 std::pair< float, float >* param)
const;
26 float epsilon,
bool* uwrap,
bool* vwrap)
const
32 float epsilon,
size_t uextent,
size_t vextent,
35 template<
class IteratorT >
36 void Optimize(IteratorT begin, IteratorT end,
float epsilon);
38 void Serialize(std::ostream* o,
bool binary)
const;
47 std::pair< float, float >* param)
const
50 float slength =
s.length();
59 param->first = std::acos(l[2]) * m_sphere->
Radius();
60 param->second = std::atan2(l[1], l[0]) * radius;
65 float uangle = u / m_sphere->
Radius();
66 float cosu = std::cos(uangle);
67 float sinu = std::sin(uangle);
68 float radius = sinu * m_sphere->
Radius();
69 float vangle =
v / radius;
70 float sinv = std::sin(vangle);
71 float cosv = std::cos(vangle);
81 float uangle = u / m_sphere->
Radius();
82 float cosu = std::cos(uangle);
83 float sinu = std::sin(uangle);
84 float radius = sinu * m_sphere->
Radius();
85 float vangle =
v / radius;
86 float sinv = std::sin(vangle);
87 float cosv = std::cos(vangle);
95 template<
class IteratorT >
103 float minUangle =
float(
M_PI), maxUangle = 0;
104 if (end - begin <= 1)
108 for (IteratorT i = begin; i != end; ++i)
111 float slength =
s.length();
118 float uangle = std::acos(h);
119 if (minUangle > uangle)
123 if (maxUangle < uangle)
128 float centerUangle = (minUangle + maxUangle) / 2;
131 q.RotationRad(-2 * (centerUangle -
float(
M_PI / 2)), m_frame[0][0], m_frame[0][1], m_frame[0][2]);
133 q.Rotate(m_frame[2], &newNormal);
134 m_frame.FromNormal(newNormal);
139 for (IteratorT i = begin; i != end; ++i)
142 float slength =
s.length();
150 float uangle = std::acos(l[2]);
151 if (uangle * m_sphere->
Radius() <
float(
M_PI) * m_sphere->
Radius() - 2 * epsilon
152 && uangle * m_sphere->
Radius() >
float(-
M_PI) * m_sphere->
Radius() + 2 * epsilon)
154 vangles.
push_back(std::atan2(l[1], l[0]));
157 std::sort(vangles.
begin(), vangles.
end());
161 for (
size_t i = 1; i < vangles.
size(); ++i)
163 float gap = vangles[i] - vangles[i - 1];
167 lower = vangles[i - 1];
173 float rotationAngle = (lower + upper) / 2;
174 m_frame.RotateOnNormal(rotationAngle +
float(
M_PI));