Java Geometry Algorithm interpol(Point p1, Point p2, float factor)

Here you can find the source of interpol(Point p1, Point p2, float factor)

Description

makes a curvic interpolation between points

License

Open Source License

Parameter

Parameter Description
p1 a parameter
p2 a parameter
factor a parameter

Declaration

private static Point interpol(Point p1, Point p2, float factor) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.Point;

public class Main {
    /**// w  w w  .  ja  va2 s .co m
     * makes a curvic interpolation between points
     *
     * @param p1
     * @param p2
     * @param factor
     * @return
     */
    private static Point interpol(Point p1, Point p2, float factor) {
        Point p = new Point((int) (p1.x * (1 - factor) + p2.x * factor),
                (int) (p1.y * (1 - factor) + p2.y * factor));

        int targety = factor <= 0.5 ? p1.y : p2.y;

        float facy = Math.abs(factor - 0.5f) * 2;

        p.y = (int) (targety * facy + p.y * (1 - facy));

        return p;
    }
}

Related

  1. generateSpline(final Point[] controls)
  2. gridAlign(final Point2D point, final double gridX, final double gridY)
  3. hitsLine(final Point2D p, final Point2D fromPoint, final Point2D toPoint, final double thickness)
  4. insidePoly(Polygon pg, Point p)
  5. interceptLineAndBox(Point2D startPosition, Point2D endPosition, RectangularShape boundingBox)
  6. invVec(final Point2D v)
  7. lonLatToString(Point2D.Double pt)
  8. makeCircle(double xCenter, double yCenter, double r, int nPoints)
  9. makeCornerTo(GeneralPath gp, Point2D cornerPoint, Point2D nextCornerPoint, float radius)