Skip to content
Snippets Groups Projects
Commit 8b0cf459 authored by Vincent Nivoliers's avatar Vincent Nivoliers
Browse files

typos in presentation

parent 4997461b
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,8 @@
//{{{ struct vec
struct vec {
vec() {} ;
vec(float x, float y) : x(x), y(y) {}
float x ;
float y ;
......@@ -36,6 +38,11 @@ struct vec {
float length() const {
return sqrt(length2()) ;
}
bool lexicoinf(const vec& rhs) const {
if(x == rhs.x) return y < rhs.y ;
return x < rhs.x ;
}
} ;
//}}}
......@@ -46,12 +53,29 @@ int sign(float x) {
return 0 ;
}
int orient(const vec& v0, const vec& v1) {
int orient(const vec& v0_in, const vec& v1_in) {
vec v0, v1 ;
int factor = 1 ;
if(v0_in.lexicoinf(v1_in)) {
v0 = v0_in ;
v1 = v1_in ;
} else {
v0 = v1_in ;
v1 = v0_in ;
factor = -1 ;
}
//determinant
float d = v0.x*v1.y - v0.y*v1.x ;
return d ;
if(d != 0) return factor*sign(d) ;
//encode as sign
return sign(d) ;
//perturbation
if(v1.y != 0) return factor*sign(v1.y) ;
float a = v0.x - v0.y - v1.x ;
if (a!= 0) return factor*sign(a) ;
return factor*1 ;
}
struct vec_compare {
......@@ -108,7 +132,13 @@ void compute_hull(std::vector<vec>& points, std::vector<vec>& hull) {
//{{{ generate svg
void svg_hull(const std::string& filename, const std::vector<vec>& points, const std::vector<vec>& hull) {
void svg_hull(
const std::string& filename,
const std::vector<vec>& points,
const std::vector<vec>& hull,
float salt = 0
)
{
std::ofstream file(filename) ;
SvgPad svg(file, 1024, 1024) ;
svg.open() ;
......@@ -118,15 +148,35 @@ void svg_hull(const std::string& filename, const std::vector<vec>& points, const
}
size_t hs = hull.size() ;
std::mt19937 mt ;
std::uniform_real_distribution<float> rf(-salt, salt) ;
for(size_t i = 0; i < hs; ++i) {
vec salti(0,0) ;
vec saltip(0,0) ;
if(salt > 0) {
salti.x = rf(mt) ;
salti.y = rf(mt) ;
saltip.x = rf(mt) ;
saltip.y = rf(mt) ;
}
svg.contour_point(hull[i].x, hull[i].y) ;
svg.line(hull[i].x, hull[i].y, hull[(i+1)%hs].x, hull[(i+1)%hs].y) ;
svg.line(
hull[i].x + salti.x,
hull[i].y + salti.y,
hull[(i+1)%hs].x + saltip.x,
hull[(i+1)%hs].y + saltip.y
) ;
}
svg.close() ;
}
void svg_sort(const std::string& filename, const std::vector<vec>& points) {
void svg_sort(
const std::string& filename,
const std::vector<vec>& points)
{
std::ofstream file(filename) ;
SvgPad svg(file, 1024, 1024) ;
svg.open() ;
......@@ -179,20 +229,37 @@ int main() {
//{{{ wicked test
{
std::vector<vec> points ;
std::vector<vec> aligned_points ;
//aligned points
points.emplace_back(0, 0.5) ;
points.emplace_back(0, 1) ;
points.emplace_back(0, 0) ;
points.emplace_back(0, 0.8) ;
//make the hull non flat
points.emplace_back(1, 0.5) ;
//hull
std::vector<vec> hull ;
compute_hull(points, hull) ;
svg_hull("/tmp/hull_aligned.svg", points, hull) ;
aligned_points.emplace_back(0, 1) ;
aligned_points.emplace_back(0, 0) ;
aligned_points.emplace_back(0, 0.8) ;
aligned_points.emplace_back(0, 0.5) ;
int indices[4] = {0, 1, 2, 3} ;
int permutation_index = 0 ;
//test every permutation of the input
do {
std::vector<vec> points ;
for(unsigned int i = 0; i < 4; ++i) {
points.push_back(aligned_points[indices[i]]) ;
}
//make the hull non flat
points.emplace_back(1, 0.5) ;
//hull
std::vector<vec> hull ;
compute_hull(points, hull) ;
//export
std::stringstream ss ;
ss << "/tmp/hull_aligned_" << permutation_index << ".svg" ;
svg_hull(ss.str(), points, hull, 0.02) ;
//move to next permutation
++ permutation_index ;
}while(std::next_permutation(indices, indices + 4)) ;
}
//}}}
......
......@@ -270,7 +270,7 @@
}
\frame{
\frametitle{Simulation de simplicité (Edelsbrnner \& Mücke 90)}
\frametitle{Simulation de simplicité (Edelsbrunner \& Mücke 90)}
\begin{center}
\begin{myblock}{0.8\li}
......@@ -285,7 +285,7 @@
\textbf{Principe :}
\begin{itemize}
\item $\sum_{k=0}^n 2^k = 2^{k+1} - 1$
\item $\prod_{k=0}^n\eps^{2^k} = \eps^{\sum_{k=0}^n2^k} = \eps^{2^{k+1} - 1} >> \eps^{2^{k+1}}$
\item $\prod_{k=0}^n\eps^{2^k} = \eps^{\sum_{k=0}^n2^k} = \eps^{2^{n+1} - 1} >> \eps^{2^{n+1}}$
\end{itemize}
}
......@@ -294,10 +294,10 @@
\begin{equation*}
\begin{pmatrix}
p_{0,0} + \eps{0,0} & p_{0,1} + \eps{0,1} & \cdots & p_{0,d} + \eps{0,d-1} & 1 \\
p_{1,0} + \eps{1,0} & p_{1,1} + \eps{1,1} & \cdots & p_{1,d} + \eps{1,d-1} & 1 \\
p_{0,0} + \eps_{0,0} & p_{0,1} + \eps_{0,1} & \cdots & p_{0,d} + \eps_{0,d-1} & 1 \\
p_{1,0} + \eps_{1,0} & p_{1,1} + \eps_{1,1} & \cdots & p_{1,d} + \eps_{1,d-1} & 1 \\
\vdots & \vdots & \ddots & \vdots \\
p_{d,0} + \eps{d,0} & p_{d,1} + \eps{d,1} & \cdots & p_{d,d-1} + \eps{d,d-1} & 1
p_{d,0} + \eps_{d,0} & p_{d,1} + \eps_{d,1} & \cdots & p_{d,d-1} + \eps_{d,d-1} & 1
\end{pmatrix}
\end{equation*}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment