/** * 由标准的直线方程ax+by+c=0确定的两条直线,得到交点 * * @return 两条直线平行的时候返回null */ public static Point2 crossPoint2( double a1, double b1, double c1, double a2, double b2, double c2) { if (isParallel2(a1, b1, a2, b2)) return null; Point2 p = new Point2(); double fenMu = a1 * b2 - a2 * b1; p.setX(-(c1 * b2 - c2 * b1) / fenMu); p.setY(-(a1 * c2 - a2 * c1) / fenMu); return p; }
@Override public Point2 getScreenPosition(final IsoWorldScene scene, final IsoCamera isoCamera) { final float sensibility = 1.0f / isoCamera.getZoomFactor(); final Point2 delta = this.computeDeltaMouse(sensibility); final float maxDistance = 500.0f; delta.m_x = MathHelper.clamp(delta.m_x, -500.0f, 500.0f); delta.m_y = MathHelper.clamp(delta.m_y, -500.0f, 500.0f); Point2 point2 = delta; point2.m_x += this.m_startCameraScreenX; point2 = delta; point2.m_y += this.m_startCameraScreenY; return delta; }
public double distanceTo(Point2 b) { double dx = b.getX() - this.getX(); double dy = b.getY() - this.getY(); return Math.sqrt(dx * dx + dy * dy); }
/** * 计算两个点之间的距离 * * @return */ public static double distance(Point2 a, Point2 b) { return Math.sqrt( (a.getX() - b.getX()) * (a.getX() - b.getX()) + (a.getY() - b.getY()) * (a.getY() - b.getY())); }
/** * Evaluate a cubic Bézier curve according to control points `p0`, `p1`, `p2` and `p3` and store * the position at parametric position `t` of the curve in `result`. * * @return the given reference to `result`. */ public static Point2 eval(Point2 p0, Point2 p1, Point2 p2, Point2 p3, double t, Point2 result) { result.set(eval(p0.x, p1.x, p2.x, p3.x, t), eval(p0.y, p1.y, p2.y, p3.y, t)); return result; }
/** * Store in `result` the derivative point of a cubic Bézier curve according to control points * `x0`, `x1`, `x2` and `x3` at parametric position `t` of the curve. * * @return the given reference to `result`. */ public static Point2 derivative( Point2 p0, Point2 p1, Point2 p2, Point3 p3, double t, Point2 result) { result.set(derivative(p0.x, p1.x, p2.x, p3.x, t), derivative(p0.y, p1.y, p2.y, p3.y, t)); return result; }