Package gld.utils

Examples of gld.utils.TurnCurve


  public static TurnCurve createCurve(Point p1, Point p2, double a1, double a2) throws CurveException
  {
    Point tp = new Point((int)(p1.x + p1.distance(p2) * Math.cos(a1)),(int)(p1.y - p1.distance(p2) * Math.sin(a1)));
    Rectangle r = new Rectangle(p2.x - 10, p2.y - 10, 20, 20);
    if(r.contains(tp))
      return new TurnCurve(p1,p2);
    Point ip = calcIntersect(p1,p2,a1,a2);
    return new TurnCurve(p1,ip,p2);
  }
View Full Code Here


    Turn[] turns = road.getTurns();
    double pos = 0.0;

    try
    {
      TurnCurve arc = createCurve(alphaCoord,turns[0].getCoord(),alphaAngle,turns[0].getAngle() + Math.PI);
      pos = calcLength(arc,step);
      turns[0].setPosition((int)pos);
    }
    catch(CurveException ce)
    {
    }
   
    for(int i = 0; i < turns.length - 1; i++)
    {
      try
      {
        TurnCurve arc = createCurve(turns[i].getCoord(),turns[i+1].getCoord(),turns[i].getAngle(),turns[i+1].getAngle() + Math.PI);
        pos += calcLength(arc,step);
        turns[i+1].setPosition((int)pos);
      }
      catch(CurveException ce)
      {
      }
    }
 
    try
    {
      TurnCurve arc = createCurve(turns[turns.length-1].getCoord(),betaCoord,turns[turns.length-1].getAngle(),betaAngle);
      pos += calcLength(arc,step);
    }
    catch(CurveException ce)
    {
    }
View Full Code Here

 
      
        try
        {
            TurnCurve arc = CurveUtils.createCurve(alphaCoord,turns[0].getCoord(),alphaAngle,normalize(turns[0].getAngle()));
        len = len + calcLength(arc,step);
        }
        catch(CurveException exc)
        {
      System.out.println("CurveException");
        int dx = alphaCoord.x - turns[0].getCoord().x;
        int dy = alphaCoord.y - turns[0].getCoord().y;
        len = len + (Math.sqrt(dx*dx+dy*dy) / step);
        }
    for(int t = 0; t < turns.length - 1; t++)
      {
            double ta1 = CurveUtils.normalize(turns[t].getAngle());
            double ta2 = CurveUtils.normalize(turns[t+1].getAngle() + Math.PI);
            Point tp1 = turns[t].getCoord();
            Point tp2 = turns[t+1].getCoord();
            try
            {
                TurnCurve arc = createCurve(tp1,tp2,ta1,ta2);
        len = len + calcLength(arc,step);
            }
            catch(CurveException exc)
            {
        System.out.println("CurveException");
        int dx = tp1.x - tp2.x;
        int dy = tp1.y - tp2.y;
        len = len + (Math.sqrt(dx*dx+dy*dy) / step);
            }
    }
        try
        {
            TurnCurve arc = CurveUtils.createCurve(turns[turns.length-1].getCoord(),betaCoord,turns[turns.length-1].getAngle(),betaAngle);
          len = len + calcLength(arc,step);
        }
        catch(CurveException exc)
        {
      System.out.println("CurveException");       
View Full Code Here

TOP

Related Classes of gld.utils.TurnCurve

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.