use of com.forstudy.efjava.ch03.item10.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);
}
use of com.forstudy.efjava.ch03.item10.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);
}
}
}
use of com.forstudy.efjava.ch03.item10.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);
}
}
}
use of com.forstudy.efjava.ch03.item10.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;
}
use of com.forstudy.efjava.ch03.item10.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;
}
Aggregations