Está en la página 1de 4

Razonamiento Geomtrico

Bibliotecas geomtricas
! Carctersticas de una biblioteca geomtrica ! Ejemplos: CGAL, GeomLib, java.awt.geom ! La biblioteca java.awt.geom

Bibliotecas geomtricas. La biblioteca java.awt.geom

Libreras Geomtricas

Copyright 2008-2009 Universidad de Alicante

Libreras Geomtricas

Copyright 2008-2009 Universidad de Alicante

Carctersticas de una bib. geomtrica

Correcta
! La correccin se reere a conformidad con la especicacin. ! Una biblioteca es correcta cuando se comporta como est especicado.

! Una buena biblioteca geomtrica debe ser:


" Correcta " Robusta " Flexible " Fcil de usar " Eciente

Libreras Geomtricas

Copyright 2008-2009 Universidad de Alicante

Libreras Geomtricas

Copyright 2008-2009 Universidad de Alicante

Robusta
! Pequeos cambios en los datos de entrada no deben cambiar una solucin correcta ! Se deben tratar correctamente:
" Errores producidos por el redondeo " Casos degenerados

Ejemplos de casos degenerados

! Soluciones:
" Algoritmos ms elaborados " Aritmtica racional exacta

(tomado del tutorial de CGAL)


Libreras Geomtricas Copyright 2008-2009 Universidad de Alicante 5 Libreras Geomtricas Copyright 2008-2009 Universidad de Alicante 6

Flexible
! ! ! ! Modular Adaptable Extensible Abierta

Fcil de usar
! Uniforme en los nombres (de paquetes, clases, interfaces, constantes, parmetros, ) ! Mdulos completos y mnimos ! Funcionalidad completa y rica

Libreras Geomtricas

Copyright 2008-2009 Universidad de Alicante

Libreras Geomtricas

Copyright 2008-2009 Universidad de Alicante

Estructura de CGAL

La librera java.awt.geom
! En el paquete java.awt:
" Interfaz Shape " Clase Polygon

! En el paquete java.awt.geom:
" Interfaz PathIterator " Clases de utilidad matemtica (AfneTransform, Dimension2d) " Objetos geomtricos (Arc2D, CubicCurbe2D, Ellipse2D, Line2D, Point2D, QuadCurve2D, Rectangle2D, RoundRectangle2D) " Clase Area

Libreras Geomtricas

Copyright 2008-2009 Universidad de Alicante

Libreras Geomtricas

Copyright 2008-2009 Universidad de Alicante

10

Clases de la librera java.awt.geom


AfneTransform Arc2D Arc2D.Double Arc2D.Float Area CubicCurve2D CubicCurve2D.Double CubicCurve2D.Float Point2D Dimension2D Point2D.Double Point2D.Float Line2D Line2D.Double Line2D.Float RoundRectangle2D RoundRectangle2D.Double RoundRectangle2D.Float Ellipse2D Ellipse2D.Double Ellipse2D.Float FlatteningPathIterator GeneralPath QuadCurve2D QuadCurve2D.Double QuadCurve2D.Float Rectangle2D Rectangle2D.Double Rectangle2D.Float RectangularShape

Formas bsicas

Shape Shape Shape Shape Shape

line = new Line2D.Float(x1, y1, x2, y2); arc = new Arc2D.Float(x, y, w, h, start, extent, type); oval = new Ellipse2D.Float(x, y, w, h); rectangle = new Rectangle2D.Float(x, y, w, h); roundRectangle = new RoundRectangle2D.Float( x, y, w, h, arcWidth, arcHeight);

Libreras Geomtricas

Copyright 2008-2009 Universidad de Alicante

11

Libreras Geomtricas

Copyright 2008-2009 Universidad de Alicante

12

Interfaz Shape
! La implementan: Area, CubicCurve2D, GeneralPath, Line2D, Polygon, QuadCurve2D, Rectangle, RectangularShape ! Mtodos:

Clase Area
! Implementa el interfaz Shape ! Adems implementa operaciones de CAG (Constructive Area Geometry) con otras reas cerradas como rectngulos, elipses y polgonos: Add, Substract, Intersect, ExclusiveOR
Area shape = new Area(shape1); shape.add(new Area(shape2)); shape.subtract(new Area(shape3)); shape.intersect(new Area(shape4)); shape.exclusiveOr(new Area(shape5));

Libreras Geomtricas

Copyright 2008-2009 Universidad de Alicante

13

Libreras Geomtricas

Copyright 2008-2009 Universidad de Alicante

14

GeneralPath
! Representa un camino geomtrico compuesto de lneas rectas, curvas cuadrticas y cbicas. Puede contener mltiples sub-caminos.
GeneralPath shape = new GeneralPath(); shape.moveTo(x, y); shape.lineTo(x, y); shape.quadTo(controlPointX, controlPointY, x, y); shape.curveTo(controlPointX1, controlPointY1, controlPointX2, controlPointY2, x, y); shape.closePath();

PathIterator
! Interfaz que permite recorrer el borde de cualquier objeto Shape. ! Cualquier objeto que implementa la interfaz Shape debe implementar el mtodo getPathIterator ! Mtodos:
" currentSegment " next " isDone

Libreras Geomtricas

Copyright 2008-2009 Universidad de Alicante

15

Libreras Geomtricas

Copyright 2008-2009 Universidad de Alicante

16

También podría gustarte