![Page 1: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/1.jpg)
Geometría Computacional
![Page 2: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/2.jpg)
Geometría: ¿por qué?
●●●●●
![Page 3: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/3.jpg)
Geometría
●●●●
![Page 4: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/4.jpg)
EntidadesGeométricas
![Page 5: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/5.jpg)
Vector(& punto)
ga eg a r r ve r
![Page 6: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/6.jpg)
Vector
u
v w
![Page 7: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/7.jpg)
Punto
uw
Q(4;3)
P(-3;1) v
![Page 8: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/8.jpg)
Longitud de un vector
√
u |u| = √ 4² + 3² = 5
¡us en es núme te !
![Page 9: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/9.jpg)
Suma y resta de vectores
⇒
u v
w = u+v0
![Page 10: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/10.jpg)
Multiplicación de un vector por un número
⇒
u-2u 0v
![Page 11: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/11.jpg)
Producto escalar
⇒ ∡
v
uu*v = 5*3 + (-1)*2 = 13
![Page 12: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/12.jpg)
Perpendicularidad de vectores
⇔ ⊥
⇒
⇒
v
uu*v = 0
![Page 13: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/13.jpg)
Rotación 90º antihoraria
uu*v = 0
v
![Page 14: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/14.jpg)
Proyección de un vector sobre otro
u
w = proy(v,u)
v
w
¡Las y i n ar re t e co n es ra !
![Page 15: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/15.jpg)
Contraproyección de un vector sobre otro
u
w = contra(v,u)
v
w
¡Las t ro c o r a z ul en p e t te !
![Page 16: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/16.jpg)
Producto vectorial (o cruzado)
⇒ ∡
v
u u^v = 4*2 - (-1)*3 = 11
![Page 17: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/17.jpg)
Paralelismo de vectores
⇔
vu^v = 0
u
![Page 18: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/18.jpg)
Giro entre vectores
⇔
u
u^v > 0
v
u
v
u^v < 0
↷
![Page 19: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/19.jpg)
Área signada de un paralelogramo
u
v
14 -13
uv
![Page 20: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/20.jpg)
●●●●
○
●●
Ángulo signado entre vectores
![Page 21: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/21.jpg)
Ángulo signado entre vectores
u
v
-0.86∡uv = atan2(a^b, a*b)
![Page 22: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/22.jpg)
Implementación
struct punto{ ll x, y;};
punto operator+(punto a, punto b){ return {a.x + b.x, a.y + b.y};}punto operator*(ll k, punto a){ return {k*a.x, k*a.y};};
Suma
Multiplicación por un número
¡Usa l lo p e t o r w!typedef long long ll;
![Page 23: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/23.jpg)
Implementación
ll operator*(punto a, punto b){ return a.x*b.x + a.y*b.y;}ll operator^(punto a, punto b){ return a.x*b.y - a.y*b.x;}ll norma2(punto a){ return a*a;}
Producto escalar
Producto vectorial
Longitud al cuadrado(así siempre es un entero)
![Page 24: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/24.jpg)
Implementación
double angulo(punto a, punto b){ return atan2(a^b, a*b);}double norma(punto a){ return hypot(a.x, a.y);}
Ángulo en radianes
Longitud
![Page 25: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/25.jpg)
Recta(& Segmento)
![Page 26: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/26.jpg)
Recta
pd
R
![Page 27: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/27.jpg)
Recta
p
R
q
![Page 28: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/28.jpg)
Segmento
p
S
q
![Page 29: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/29.jpg)
Entidades más complejas
![Page 30: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/30.jpg)
Polígono
typedef vector<punto> poligono;
![Page 31: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/31.jpg)
Convexidad
no-convexo convexo
![Page 32: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/32.jpg)
Simplicidad
simple complejo
![Page 33: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/33.jpg)
Círculo
struct circulo{punto o; int r;
};
![Page 34: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/34.jpg)
Algoritmos
![Page 35: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/35.jpg)
Área & perímetrode un polígono
![Page 36: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/36.jpg)
Área
![Page 37: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/37.jpg)
Área
![Page 38: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/38.jpg)
Área
![Page 39: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/39.jpg)
Área
![Page 40: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/40.jpg)
Área
![Page 41: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/41.jpg)
Área
![Page 42: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/42.jpg)
Área
ll doble_area(poligono &p){ ll a = 0; forn(i, p.size()){ a += p[i]^p[(i+1)%p.size()]; return a > 0 ? a : -a;}
![Page 43: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/43.jpg)
Perímetro
![Page 44: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/44.jpg)
Perímetro
double perimetro(poligono &p){ double l = 0; forn(i, p.size()){ l += norma(p[i] - p[(i+1)%p.size()]); return l;}
![Page 45: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/45.jpg)
Distancias
![Page 46: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/46.jpg)
Distancia punto a recta
pu
q
contr(pq,u)
![Page 47: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/47.jpg)
Distancia punto a segmento
p
q
r
![Page 48: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/48.jpg)
Distancia entre segmentos o rectas
p
qr
s
![Page 49: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/49.jpg)
Intersección de rectas
![Page 50: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/50.jpg)
Intersección
p
u vq
i
![Page 51: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/51.jpg)
Intersección
λ ϕi = p + λu = q + ϕv
λ(p + λu)^v = (q + ϕv)^v
p^v + (λu)^v = q^v + (ϕv)^v λ(u^v) = (q-p)^v
λ = (q-p)^v / (u^v) ϕ
ϕ = (q-p)^u / (u^v)
ϕv es le v, en cϕv ^ v = 0
en / en
no p a l a íqu u ^ v ≠ 0
![Page 52: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/52.jpg)
Intersección de segmentos
λ ϕ
p
rs
q
i
![Page 53: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/53.jpg)
Inclusión
![Page 54: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/54.jpg)
Inclusión ángulo convexo
∊
p
ab
c
![Page 55: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/55.jpg)
Inclusión triángulo
∊
p
ab
c
![Page 56: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/56.jpg)
Inclusión polígono estrictamente convexo
p
![Page 57: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/57.jpg)
Inclusión polígono estrictamente convexo
p
![Page 58: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/58.jpg)
Inclusión polígono estrictamente convexo
p
![Page 59: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/59.jpg)
Inclusión polígono estrictamente convexo
p
![Page 60: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/60.jpg)
Inclusión polígono estrictamente convexo
p
![Page 61: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/61.jpg)
Inclusión polígono no convexo
p
![Page 62: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/62.jpg)
Inclusión polígono no convexo
p
![Page 63: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/63.jpg)
Animación
p
![Page 64: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/64.jpg)
Animación
p
![Page 65: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/65.jpg)
Animación
p
![Page 66: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/66.jpg)
Animación
p
![Page 67: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/67.jpg)
Animación
p
![Page 68: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/68.jpg)
Animación
p
![Page 69: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/69.jpg)
Animación
p
![Page 70: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/70.jpg)
Animación
p
![Page 71: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/71.jpg)
Inclusión polígono no convexo
bool pertenece(poligono &P, punto p){ double a = 0; forn(i, P.size()){ a += angulo(P[i], p, P[(i+1)%P.size()]); return abs(abs(l) - 2*acos(-1)) < 0.0001 ;}
¡el un ép i n ac !
π
![Page 72: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/72.jpg)
Sweep Line
![Page 73: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/73.jpg)
Sweep Line
![Page 74: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/74.jpg)
CHULL(cápsula convexa)
![Page 75: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/75.jpg)
CHULL
![Page 76: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/76.jpg)
CHULL
![Page 77: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/77.jpg)
Algoritmo de Graham
![Page 78: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/78.jpg)
Algoritmo de Graham
p0
p1
p2
p3
p4p5p6
p7
p8
or
![Page 79: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/79.jpg)
Algoritmo de Graham
p0
p1
p2
p3
p4p5p6
p7
p8
![Page 80: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/80.jpg)
Algoritmo de Graham
p0
p1
p2
p3
p4p5p6
p7
p8
![Page 81: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/81.jpg)
Algoritmo de Graham
p0
p1
p2
p3
p4p5p6
p7
p8
![Page 82: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/82.jpg)
Algoritmo de Graham
p0
p1
p2
p3
p4p5p6
p7
p8
![Page 83: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/83.jpg)
Algoritmo de Graham
p0
p1
p2
p3
p4p5p6
p7
p8
![Page 84: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/84.jpg)
Algoritmo de Graham
p0
p1
p2
p3
p4p5p6
p7
p8
![Page 85: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/85.jpg)
Algoritmo de Graham
p0
p1
p2
p3
p4p5p6
p7
p8
![Page 86: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/86.jpg)
Algoritmo de Graham
p0
p1
p2
p3
p4p5p6
p7
p8
![Page 87: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/87.jpg)
Algoritmo de Graham
p0
p1
p2
p3
p4p5p6
p7
p8
![Page 88: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/88.jpg)
Algoritmo de Graham
p0
p1
p2
p3
p4p5p6
p7
p8
![Page 89: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/89.jpg)
Algoritmo de Graham
p0
p1
p2
p3
p4p5p6
p7
p8
![Page 90: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/90.jpg)
Algoritmo de Graham
p0
p1
p2
p3
p4p5p6
p7
p8
![Page 91: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/91.jpg)
Algoritmo de Graham
p0
p1
p2
p3
p4p5p6
p7
p8
![Page 92: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/92.jpg)
Algoritmo de Graham poligono GS(vector<point> p){
intercambiar p[0] con un punto extremoordenar p[1..N-1] polarmente (por ángulo)poligono chull = vacioforn(i, N)
int m = chull.size()while(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha)
chull.pop_back() // borro el penultimo consideradom--
chull.push_back(p[i]) // agrego el ultimo return chull
}
Complejidad O(N) + sort = O(N log N)
![Page 93: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/93.jpg)
PPMA(par de puntos más alejado)
![Page 94: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/94.jpg)
Par de puntos más alejado
![Page 95: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/95.jpg)
Par de puntos más alejado
![Page 96: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/96.jpg)
Cuidado
Sea P[0..n-1] un polígono convexo
// hallar q (=P[j]) inicial (aquél correspondiente a p = P[0])j = 0for(i = 1 .. n-1)
if( norma(P[i]-P[0]) > norma(P[j]-P[0]) )j = i
// para cada p (=P[i]) hacerfor(i = 0 .. n-1)
while(j' = j+1 mod n; norma(P[j']-P[i]) ≥ norma(P[j]-P[i]); j'++ mod n)j = j'
considerar par i-j
![Page 97: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/97.jpg)
Cuidado
fuente imagen: ToMmyDong, codeforces.com
el t A u c on ra co n i t a q, a p de n ar ás a do
p u C.
p
![Page 98: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/98.jpg)
Solución
fuente imagen: ToMmyDong, codeforces.com
e
p
![Page 99: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/99.jpg)
Par de puntos más alejadopar<punto, punto> PPMA(vector<point> nube){
chull = GS(nube) // calculamos la chullrespuesta = (chull[0], chull[1])n = chull.size(), j = 0for(i = 0 .. n-1)
while( chull[j+1] no se acerca a la recta chull[i]chull[i+1] )j++; // recordemos j++, j+1, y i+1 siempre en mod n
if( distancia(chull[i], chull[j]) > distancia(respuesta) )respuesta = (chull[i], chull[j])
if( distancia(chull[i+1], chull[j]) > distancia(respuesta) )respuesta = (chull[i+1], chull[j])
return respuesta}
Complejidad O(N) + chull = O(N log N)
![Page 100: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/100.jpg)
PPMC(par de puntos más cercano)
![Page 101: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/101.jpg)
PPMC
![Page 102: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/102.jpg)
PPMC
![Page 103: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/103.jpg)
●●
●
PPMC
dd
![Page 104: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/104.jpg)
PPMCpar<punto, punto> ppmc(vector<point> p){ respuesta = (p[0], p[1])
double d = distancia(respuesta) set<point> S = vacío (ordenado por coordenada y)
ordeno p[0..N-1] por xint a = 0for(int b = 0..N-1)
while( p[b].x - p[a].x > d )S.erase(p[a++])
for( q = S.lower_bound(p[b].y - d); q.y - p[b].y < d; sig(q))if( d > largo(q, p[b]) )
d = largo(q, p[b])respuesta = (q, p[b])
S.insert(p[b])return respuesta
}
![Page 105: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/105.jpg)
Problemas
![Page 106: Geometría Computacional - UNSAMwhile(m >= 2 and chull[m-2],chull[m-1],p[i] es giro a la derecha) chull.pop_back() // borro el penultimo considerado m--chull.push_back(p[i]) // agrego](https://reader035.vdocuments.co/reader035/viewer/2022070906/5f786a2d6d77c33d1d6b3b2e/html5/thumbnails/106.jpg)
Problemas●●
●
●
●
●●
●
●
●