Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Point getIntersection(Point a, Point b) {
- float d = (x1 - x2) * (a.y - b.y) - (y1 - y2) * (a.x - b.x);
- float newX = ((a.x - b.x) * (x1 * y2 - y1 * x2) - (x1 - x2) * (a.x * b.y - a.y * b.x)) / d;
- float newY = ((a.y - b.y) * (x1 * y2 - y1 * x2) - (y1 - y2) * (a.x * b.y - a.y * b.x)) / d;
- return new Point(Math.round(newX), Math.round(newY));
- }
- public boolean isInside(Point p) {
- return ((x2 - x1) * (p.y - y1) - (y2 - y1) * (p.x - x1)) < 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement