package com.zy.asrs.utils; import java.util.ArrayList; import java.util.List; public class Point { public double x; public double y; public Point(double x, double y) { this.x = x; this.y = y; } public double distance(Point other) { double dx = this.x - other.x; double dy = this.y - other.y; return Math.sqrt(dx*dx + dy*dy); } public double angle(Point other) { double dx = other.x - this.x; double dy = other.y - this.y; return Math.atan2(dy, dx); } public Point interpolate(Point other, double t) { double newX = this.x + t * (other.x - this.x); double newY = this.y + t * (other.y - this.y); return new Point(newX, newY); } public static List interpolate(Point p1, Point p2, double interval) { List points = new ArrayList<>(); double distance = p1.distance(p2); double angle = p1.angle(p2); for (double t=interval/distance; t<1; t+=interval/distance) { Point p = p1.interpolate(p2, t); points.add(p); } return points; } }