Package com.deadtroll.model

Examples of com.deadtroll.model.Ponto2d


   * @return
   */
  public static boolean pontoEmPoligono(Ponto2d pontoScanline, Poligono poligono) {
    List<Ponto2d> pontosPoligono = poligono.getPontosTransformacoes();

    Ponto2d ladoPoligono[] = new Ponto2d[2];
    int nIntScanline = 0;
    for (int i=1; i<=pontosPoligono.size(); i++) {
      ladoPoligono[0] = pontosPoligono.get(i-1);
      ladoPoligono[1] = pontosPoligono.get(i<pontosPoligono.size()? i : 0);
     
      if (ladoPoligono[1].getY() != ladoPoligono[0].getY()) {
        Ponto2d pontoInterseccao = pontoInterseccaoScanline(pontoScanline, ladoPoligono);
        if (pontoInterseccao != null) {
          if (pontoInterseccao.getX() == pontoScanline.getX()) {
            break; // ponto est� sobre lado vertical
          } else {
            if (pontoInterseccao.getX() > pontoScanline.getX() &&
              pontoInterseccao.getY() > Math.min(ladoPoligono[0].getY(), ladoPoligono[1].getY()) &&
              pontoInterseccao.getY() <= Math.max(ladoPoligono[0].getY(), ladoPoligono[1].getY())) {
              nIntScanline++;
            }
          }
        }
      } else {
View Full Code Here


   */
  public static Ponto2d pontoInterseccaoScanline(Ponto2d pontoScanline, Ponto2d[] ladoPoligono) {
    float t = (pontoScanline.getY() - ladoPoligono[0].getY()) / (ladoPoligono[1].getY() - ladoPoligono[0].getY());
    if (t >= 0.0f && t <= 1.0f) {
      float xInterseccao = ladoPoligono[0].getX() + (ladoPoligono[1].getX()-ladoPoligono[0].getX())*t;
      return new Ponto2d(xInterseccao, pontoScanline.getY());
    }
    return null;
  }
View Full Code Here

  }
 
  public boolean selecionarVertice(Ponto2d pontoCursor) {
    for (Renderable objeto : objects) {
      if (objeto instanceof Circulo) {
        Ponto2d centro = ((Circulo)objeto).getCentro();
        if (MathUtil.calcularDistancia(centro, pontoCursor) <= 1.5f) {
          this.verticeSelecionado = centro;
          return true;
        }
      } else {
View Full Code Here

    for (int i=0; i< pontos.size(); i++) {
      x[i] = pontos.get(i).getX();
      y[i] = pontos.get(i).getY();
    }
    int n = pontos.size()-1;
    Ponto2d ponto = new Ponto2d();
    ponto.setX(MathUtil.calcularBernstein(x, n, t));
    ponto.setY(MathUtil.calcularBernstein(y, n, t));
    return ponto;
  }
View Full Code Here

    float grauAtual = 0;
   
    for (int i=0; i<pontos; i++) {
      float x = xCirculo(centro.getX(), raio, grauAtual);
      float y = yCirculo(centro.getY(), raio, grauAtual);
      pontosCirculo.add(new Ponto2d(x, y));
      grauAtual += incremento;
    }
    return pontosCirculo;
  }
View Full Code Here

  @Override
  public void mouseDragged(MouseEvent event) {
    mousePos[0] = NDCUtil.xScreenParaOrtho(event.getX(), glDrawable.getWidth(), minOrthoXTransf, maxOrthoXTransf);
    mousePos[1] = NDCUtil.yScreenParaOrtho(event.getY(), glDrawable.getHeight(), minOrthoYTransf, maxOrthoYTransf);
    Ponto2d pontoMouse = new Ponto2d(mousePos[0], mousePos[1]);
    if (this.controller.modoSelecaoVertices()) {
      if (this.movendoPonto) {
        this.controller.getVerticeSelecionado().setX(pontoMouse.getX());
        this.controller.getVerticeSelecionado().setY(pontoMouse.getY());
      }
    } else if (this.controller.modoSelecaoPoligonos()) {
      if (this.controller.movendoPoligono()) {
        Renderable objeto = this.controller.getObjetoSelecionado();
        if (objeto != null) {
          Ponto2d pontoMouseDrag = objeto.getPontoMouseDrag();
          float transX = pontoMouse.getX() - pontoMouseDrag.getX();
          float transY = pontoMouse.getY() - pontoMouseDrag.getY();
          objeto.setTranslacaoX(transX);
          objeto.setTranslacaoY(transY);
        }
      }
    }
View Full Code Here

    if (glDrawable != null) {
      // mudar a posi��o atual do mouse para exibir o cursor
      mousePos[0] = NDCUtil.xScreenParaOrtho(event.getX(), glDrawable.getWidth(), minOrthoXTransf, maxOrthoXTransf);
      mousePos[1] = NDCUtil.yScreenParaOrtho(event.getY(), glDrawable.getHeight(), minOrthoYTransf, maxOrthoYTransf);
     
      Ponto2d pontoMouse = new Ponto2d(this.mousePos[0], this.mousePos[1]);
      if (this.controller.modoAdicaoCirculo()) {
        if (objetoAdicao != null) {
          Circulo circulo = (Circulo)objetoAdicao;
          float raio = MathUtil.calcularDistancia(circulo.getCentro(), pontoMouse);
          circulo.setRaio(raio);
View Full Code Here

  public void mouseExited(MouseEvent e) {
  }

  @Override
  public void mousePressed(MouseEvent e) {
    Ponto2d pontoMouse = new Ponto2d(this.mousePos[0], this.mousePos[1]);
    if (this.controller.modoAdicaoCirculo()) {
      if (this.objetoAdicao == null) {
        this.objetoAdicao = new Circulo(pontoMouse, 0.0f);
        this.controller.addObject(this.objetoAdicao);
      } else {
View Full Code Here

  @Override
  public void mouseReleased(MouseEvent e) {
    float x = NDCUtil.xScreenParaOrtho(e.getX(), glDrawable.getWidth(), minOrthoXTransf, maxOrthoXTransf);
    float y = NDCUtil.yScreenParaOrtho(e.getY(), glDrawable.getHeight(), minOrthoYTransf, maxOrthoYTransf);
    Ponto2d pontoMouse = new Ponto2d(x,y);
    if (this.controller.modoSelecaoVertices()) {
      if (this.movendoPonto) {
        this.controller.getVerticeSelecionado().setX(pontoMouse.getX());
        this.controller.getVerticeSelecionado().setY(pontoMouse.getY());
      }
      this.movendoPonto = false;
    } else if (this.controller.modoSelecaoPoligonos()) {
      if (this.controller.movendoPoligono()) {
        Renderable objeto = this.controller.getObjetoSelecionado();
        if (objeto != null) {         
          Ponto2d pontoMouseDrag = objeto.getPontoMouseDrag();
          float transX = pontoMouse.getX() - pontoMouseDrag.getX();
          float transY = pontoMouse.getY() - pontoMouseDrag.getY();
          objeto.setTranslacaoX(transX);
          objeto.setTranslacaoY(transY);
         
          this.controller.setMovendoPoligono(false);
        }
View Full Code Here

TOP

Related Classes of com.deadtroll.model.Ponto2d

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.