Package com.vividsolutions.jts.math

Examples of com.vividsolutions.jts.math.Vector2D


  public void addSide(int level, Coordinate p0, Coordinate p1) {
    if (level == 0)
      addSegment(p0, p1);
    else {
      Vector2D base = Vector2D.create(p0, p1);
      Coordinate midPt = base.multiply(0.5).translate(p0);
     
      Vector2D heightVec = base.multiply(THIRD_HEIGHT);
      Vector2D offsetVec = heightVec.rotateByQuarterCircle(1);
      Coordinate offsetPt = offsetVec.translate(midPt);
     
      int n2 = level - 1;
      Coordinate thirdPt = base.multiply(ONE_THIRD).translate(p0);
      Coordinate twoThirdPt = base.multiply(TWO_THIRDS).translate(p0);
     
View Full Code Here


  public void addSide(int level, Coordinate p0, Coordinate p1) {
    if (level == 0)
      addSegment(p0, p1);
    else {
      Vector2D base = Vector2D.create(p0, p1);
      Coordinate midPt = base.multiply(0.5).translate(p0);
     
      Vector2D heightVec = base.multiply(THIRD_HEIGHT);
      Vector2D offsetVec = heightVec.rotateByQuarterCircle(1);
      Coordinate offsetPt = offsetVec.translate(midPt);
     
      int n2 = level - 1;
      Coordinate thirdPt = base.multiply(ONE_THIRD).translate(p0);
      Coordinate twoThirdPt = base.multiply(TWO_THIRDS).translate(p0);
     
View Full Code Here

    Coordinate[] corner = orientCorner(nearPt, p1, p2);
   
    // find quadrant of corner that vertex pt lies in
    int quadrant = quadrant(vertexPt, nearPt, corner);
   
    Vector2D normOffset = normalizedOffset(nearPt, p1, p2);
    Vector2D baseOffset = normOffset.multiply(dist);
    Vector2D rotatedOffset = baseOffset.rotateByQuarterCircle(quadrant);
   
    return rotatedOffset.translate(vertexPt);
    //return null;
  }
View Full Code Here

  private Coordinate displaceFromCorner(Coordinate nearPt, Coordinate p1, Coordinate p2, double dist)
  {
    Coordinate[] corner = orientCorner(nearPt, p1, p2);
      // compute perpendicular bisector of p1-p2
    Vector2D u1 = Vector2D.create(nearPt, corner[0]).normalize();
    Vector2D u2 = Vector2D.create(nearPt, corner[1]).normalize();
    double ang = u1.angle(u2);
    Vector2D innerBisec = u2.rotate(ang / 2);
        Vector2D offset = innerBisec.multiply(dist);
    if (! isInsideCorner(vertexPt, nearPt, corner[0], corner[1])) {
        offset = offset.multiply(-1);
    }
    return offset.translate(vertexPt);
  }
View Full Code Here

  private Coordinate displaceFromCornerAwayFromArms(Coordinate nearPt, Coordinate p1, Coordinate p2, double dist)
  {
    Coordinate[] corner = orientCorner(nearPt, p1, p2);
    boolean isInsideCorner = isInsideCorner(vertexPt, nearPt, corner[0], corner[1]);
   
    Vector2D u1 = Vector2D.create(nearPt, corner[0]).normalize();
    Vector2D u2 = Vector2D.create(nearPt, corner[1]).normalize();
    double cornerAng = u1.angle(u2);
   
    double maxAngToBisec = maxAngleToBisector(cornerAng);
   
    Vector2D bisec = u2.rotate(cornerAng / 2);
    if (! isInsideCorner) {
      bisec = bisec.multiply(-1);
      double outerAng = 2 * Math.PI - cornerAng;
      maxAngToBisec = maxAngleToBisector(outerAng);
    }
   
    Vector2D pointwiseDisplacement = Vector2D.create(nearPt, vertexPt).normalize();
    double stretchAng = pointwiseDisplacement.angleTo(bisec);
    double stretchAngClamp = MathUtil.clamp(stretchAng, -maxAngToBisec, maxAngToBisec);
    Vector2D cornerDisplacement = bisec.rotate(-stretchAngClamp).multiply(dist);
    return cornerDisplacement.translate(vertexPt);
  }
View Full Code Here

   * @param p2
   * @return
   */
  private static Vector2D normalizedOffset(Coordinate p0, Coordinate p1, Coordinate p2)
  {
    Vector2D u1 = Vector2D.create(p0, p1).normalize();
    Vector2D u2 = Vector2D.create(p0, p2).normalize();
    Vector2D offset = u1.add(u2).normalize();
    return offset;
  }
View Full Code Here

  }
 
  private Coordinate displaceFromFlatCorner(Coordinate nearPt, Coordinate p1, Coordinate p2, double dist)
  {
    // compute perpendicular bisector of p1-p2
    Vector2D bisecVec = Vector2D.create(p2, p1).rotateByQuarterCircle(1);
    Vector2D offset = bisecVec.normalize().multiply(dist);
    return offset.translate(vertexPt);
  }
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.math.Vector2D

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.