Java Geometry Algorithm generatePoint(Shape region)

Here you can find the source of generatePoint(Shape region)

Description

generate Point

License

Open Source License

Declaration

public static Point generatePoint(Shape region) 

Method Source Code

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

import java.awt.*;

public class Main {
    public static Point generatePoint(Shape region) {
        Rectangle r = region.getBounds();
        double x, y;
        do {//from  www .j  a va  2  s.c o m
            x = r.getX() + r.getWidth() * Math.random();
            y = r.getY() + r.getHeight() * Math.random();
        } while (!region.contains(x, y));

        return new Point((int) x, (int) y);
    }
}

Related

  1. findMiddlePoint(Point2D p1, Point2D p2)
  2. fitCircle(final Point2D P1, final Point2D P2, final Point2D P3)
  3. forceMouseMove(Point pos)
  4. generateLine(Point2D.Double point, double length, double angle)
  5. generateLookAtTag(ArrayList geoCoords, ArrayList modsAM)
  6. generateRobotPositions(Point start, Point end, int stepSize)
  7. generateSpline(final Point[] controls)
  8. gridAlign(final Point2D point, final double gridX, final double gridY)
  9. hitsLine(final Point2D p, final Point2D fromPoint, final Point2D toPoint, final double thickness)