Search in sources :

Example 31 with Point

use of com.geophile.z.spatialobject.d2.Point in project CoreJava by alekseiiagnenkov.

the class Lab4 method main.

public static void main(String[] args) {
    Line line = new Line(new Point(0, 0), new Point(3, 6));
    Rectangle rectangle = new Rectangle(new Point(0, 10), 20, 10);
    Circle circle = new Circle(new Point(0, 0), 20);
    System.out.println(line);
    System.out.println(rectangle);
    System.out.println(circle);
    Line lineCopy = line.clone();
    Rectangle rectangleCopy = rectangle.clone();
    Circle circleCopy = circle.clone();
    System.out.println(lineCopy);
    System.out.println(rectangleCopy);
    System.out.println(circleCopy);
}
Also used : Line(corejava.chapter4.lab4_5.shape.Line) Circle(corejava.chapter4.lab4_5.shape.Circle) Rectangle(corejava.chapter4.lab4_5.shape.Rectangle) Point(corejava.chapter4.lab1_2_3.Point)

Example 32 with Point

use of com.geophile.z.spatialobject.d2.Point in project imagej-omero by imagej.

the class MaskConversionTest method testImageJToOMERONotDivisibleBy8.

@Test
public void testImageJToOMERONotDivisibleBy8() {
    // 1 0 0 0 0
    // 0 1 0 0 0
    // 0 0 1 0 0
    // 0 0 0 1 0
    // 0 0 0 0 1
    // bytes = -126, 8, 32, -128
    final MaskInterval ijMask = new DefaultMaskInterval(new FinalInterval(new long[] { 0, 0 }, new long[] { 5, 5 }), BoundaryType.UNSPECIFIED, t -> t.getDoublePosition(0) == t.getDoublePosition(1), KnownConstant.UNKNOWN);
    final MaskData omeroMask = convert.convert(ijMask, MaskData.class);
    assertEquals(ROIConverters.UNSPECIFIED_BOUNDARY_TEXT, omeroMask.getText());
    assertEquals(ijMask.min(0), omeroMask.getX(), 0);
    assertEquals(ijMask.min(1), omeroMask.getY(), 0);
    assertEquals(ijMask.max(0), omeroMask.getX() + omeroMask.getWidth(), 0);
    assertEquals(ijMask.max(1), omeroMask.getY() + omeroMask.getHeight(), 0);
    final Point pt = new Point(2);
    final byte[] data = omeroMask.getMask();
    for (long r = ijMask.min(1); r < ijMask.max(1); r++) {
        pt.setPosition(r, 1);
        for (long c = ijMask.min(0); c < ijMask.max(0); c++) {
            pt.setPosition(c, 0);
            final int omeroBitPos = (int) (((r - omeroMask.getY()) * omeroMask.getWidth()) + (c - omeroMask.getX()));
            assertEquals(ijMask.test(pt), omeroMask.getBit(data, omeroBitPos) == 1);
        }
    }
}
Also used : DefaultMaskInterval(net.imglib2.roi.mask.integer.DefaultMaskInterval) MaskInterval(net.imglib2.roi.MaskInterval) DefaultMaskInterval(net.imglib2.roi.mask.integer.DefaultMaskInterval) FinalInterval(net.imglib2.FinalInterval) RealPoint(net.imglib2.RealPoint) Point(net.imglib2.Point) MaskData(omero.gateway.model.MaskData) RealPoint(net.imglib2.RealPoint) Point(net.imglib2.Point) Test(org.junit.Test)

Example 33 with Point

use of com.geophile.z.spatialobject.d2.Point in project imagej-omero by imagej.

the class MaskConversionTest method testImageJToOMERODivisibleBy8.

@Test
public void testImageJToOMERODivisibleBy8() {
    final MaskInterval ijMask = new DefaultMaskInterval(new FinalInterval(new long[] { 18, 36 }, new long[] { 54, 92 }), BoundaryType.UNSPECIFIED, t -> (t.getDoublePosition(0) + t.getDoublePosition(1)) % 2 == 0, KnownConstant.UNKNOWN);
    final MaskData omeroMask = convert.convert(ijMask, MaskData.class);
    assertEquals(ROIConverters.UNSPECIFIED_BOUNDARY_TEXT, omeroMask.getText());
    assertEquals(ijMask.min(0), omeroMask.getX(), 0);
    assertEquals(ijMask.min(1), omeroMask.getY(), 0);
    assertEquals(ijMask.max(0), omeroMask.getX() + omeroMask.getWidth(), 0);
    assertEquals(ijMask.max(1), omeroMask.getY() + omeroMask.getHeight(), 0);
    final Point pt = new Point(2);
    final byte[] data = omeroMask.getMask();
    for (long r = ijMask.min(1); r < ijMask.max(1); r++) {
        pt.setPosition(r, 1);
        for (long c = ijMask.min(0); c < ijMask.max(0); c++) {
            pt.setPosition(c, 0);
            final int omeroBitPos = (int) (((r - omeroMask.getY()) * omeroMask.getWidth()) + (c - omeroMask.getX()));
            assertEquals(ijMask.test(pt), omeroMask.getBit(data, omeroBitPos) == 1);
        }
    }
}
Also used : DefaultMaskInterval(net.imglib2.roi.mask.integer.DefaultMaskInterval) MaskInterval(net.imglib2.roi.MaskInterval) DefaultMaskInterval(net.imglib2.roi.mask.integer.DefaultMaskInterval) FinalInterval(net.imglib2.FinalInterval) RealPoint(net.imglib2.RealPoint) Point(net.imglib2.Point) MaskData(omero.gateway.model.MaskData) RealPoint(net.imglib2.RealPoint) Point(net.imglib2.Point) Test(org.junit.Test)

Example 34 with Point

use of com.geophile.z.spatialobject.d2.Point in project java-docs-samples by GoogleCloudPlatform.

the class TimeSeriesSummary method getMostRecentPoint.

Point getMostRecentPoint(TimeSeries timeSeries) {
    Point max = Collections.max(timeSeries.getPointsList(), Comparator.comparingLong(p -> p.getInterval().getEndTime().getSeconds()));
    mostRecentRunTime = max.getInterval().getEndTime();
    return max;
}
Also used : List(java.util.List) Lists(com.google.common.collect.Lists) TimeSeries(com.google.monitoring.v3.TimeSeries) Collections2(com.google.common.collect.Collections2) Point(com.google.monitoring.v3.Point) Comparator(java.util.Comparator) Timestamp(com.google.protobuf.Timestamp) Collections(java.util.Collections) Collectors(java.util.stream.Collectors) Point(com.google.monitoring.v3.Point)

Example 35 with Point

use of com.geophile.z.spatialobject.d2.Point in project cg by nmahoude.

the class Simulation method collisionCheck.

private boolean collisionCheck(double acceptableGap) {
    boolean hasCollision = false;
    // [  sites(numSites) .. queen0 queen1 creeps...]
    for (int i = 0; i < Player.creepsFE; i++) {
        Unit u1 = Player.all[i];
        if (u1.health <= 0)
            continue;
        double radius = u1.radius;
        double clampDist = u1.mass == 0 ? Constants.OBSTACLE_GAP + radius : radius;
        u1.location.clampWithin(clampDist, Constants.WORLD_WIDTH - clampDist, clampDist, Constants.WORLD_HEIGHT - clampDist);
        for (int i2 = i + 1; i2 < Player.creepsFE; i2++) {
            Unit u2 = Player.all[i2];
            if (u2.health <= 0)
                continue;
            if (u2 == u1)
                continue;
            boolean distant = u1.radius + u2.radius + acceptableGap - u1.location.distanceTo(u2.location) <= 1e-6;
            if (!distant) {
                double d1, d2;
                if (u1.mass == 0 && u2.mass == 0) {
                    d1 = d2 = 0.5;
                } else if (u1.mass == 0) {
                    d1 = 0.0;
                    d2 = 1.0;
                } else if (u2.mass == 0) {
                    d1 = 1.0;
                    d2 = 0.0;
                } else {
                    d1 = u2.mass / (u1.mass + u2.mass);
                    d2 = u1.mass / (u1.mass + u2.mass);
                }
                Point u1tou2 = new Point();
                u1tou2.x = u2.location.x - u1.location.x;
                u1tou2.y = u2.location.y - u1.location.y;
                u1.location.x -= d1 * u1tou2.x;
                u1.location.y -= d1 * u1tou2.y;
                u2.location.x += d2 * u1tou2.x;
                u2.location.y += d2 * u1tou2.y;
                hasCollision = true;
            }
        }
    }
    return hasCollision;
}
Also used : Point(coderoyale2.Point) Unit(coderoyale2.units.Unit) Point(coderoyale2.Point)

Aggregations

Point (net.imglib2.Point)33 ArrayList (java.util.ArrayList)16 FloatType (net.imglib2.type.numeric.real.FloatType)11 Test (org.junit.Test)9 List (java.util.List)8 Point (com.google.monitoring.v3.Point)7 Point (hr.fer.oop.recap2.task2.Point)7 FinalInterval (net.imglib2.FinalInterval)7 RealPoint (net.imglib2.RealPoint)7 TimeSeries (com.google.monitoring.v3.TimeSeries)6 Point (de.micromata.opengis.kml.v_2_2_0.Point)6 Interval (net.imglib2.Interval)6 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)6 HyperSphere (net.imglib2.algorithm.region.hypersphere.HyperSphere)6 AffineTransform3D (net.imglib2.realtransform.AffineTransform3D)6 HashMap (java.util.HashMap)5 Metric (com.google.api.Metric)4 TimeInterval (com.google.monitoring.v3.TimeInterval)4 TypedValue (com.google.monitoring.v3.TypedValue)4 Map (java.util.Map)4