Skip to content

Commit

Permalink
update version -> v0.9.8
Browse files Browse the repository at this point in the history
  • Loading branch information
johnprif committed Feb 17, 2023
1 parent f323bda commit b5c6b33
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 137 deletions.
138 changes: 2 additions & 136 deletions src/Model/DataBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -448,100 +448,6 @@ public Point2D getUp8(Point2D p)
return new Point2D(ux, uy);
}

public Point2D getUp5(Point2D p)
{
int size = convexPoints.size();
Point2D nextP = neighbours.get(p).get(1); //O(1)
double mx = (p.getX() + nextP.getX()) / 2.0;
double my = (p.getY() + nextP.getY()) / 2.0;
Point2D midPoint = new Point2D(mx, my);
double slope = (nextP.getY()-p.getY())/(nextP.getX()-p.getX());
double invSlope = -1/slope;
//y-my = invSlope*(x-mx)
//y = invSlope*(x-mx)+my;
double distance = 0;
Point2D tempUp = null;
Point2D Up = null;
//find farthest point
for(int i=0; i<size; i++)
{
Point2D nextPoint = convexPoints.get((i + 1) % size);
if(!nextPoint.equals(p) || !nextPoint.equals(nextP))
{
if(getCenter(p, nextP, nextPoint).distance(midPoint)>distance)
{
tempUp = getCenter(p, nextP, nextPoint);
distance = getCenter(p, nextP, nextPoint).distance(midPoint);
}
}

}

//increase by 5%
Point2D candidate1 = new Point2D(1.05*tempUp.getX(), (invSlope*(1.05*tempUp.getX()-mx)+my));
//y-my = invSlope*(x-mx);
//y-my = invSlope*x-invSlope*mx;
//x = (y-my+invSlope*mx)/invSlope;
//increase by 5%
Point2D candidate2 = new Point2D(((1.05*tempUp.getY()-my+invSlope*mx)/invSlope), 1.05*tempUp.getY());
if(candidate1.distance(midPoint)>candidate2.distance(midPoint))
{
Up = candidate1;
}else
{
Up = candidate2;
}
return Up;
}

public Point2D getUp11(Point2D p)
{
int size = convexPoints.size();
Point2D nextP = neighbours.get(p).get(1); //O(1)
double mx = (p.getX() + nextP.getX()) / 2.0;
double my = (p.getY() + nextP.getY()) / 2.0;
double slope = (nextP.getY()-p.getY())/(nextP.getX()-p.getX());
double invSlope = -1/slope;
//y-my = invSlope*(x-mx)
//y = invSlope*(x-mx)+my;
double maxRadius = 0;
Point2D max=null;
Point2D center = new Point2D(circle.getCenterX(), circle.getCenterY());
//find farthest point
for(int i=0; i<size; i++)
{
Point2D nextPoint = convexPoints.get((i + 1) % size);
if(!nextPoint.equals(p) || !nextPoint.equals(nextP))
{
double currentRadius = getRadius(p, nextP, nextPoint);
if(currentRadius>=maxRadius)
{
maxRadius = currentRadius;
max = getU(nextP, p, nextPoint);
}
}
return max;
}

// define the distance to travel
double d = maxRadius/100.0;
// calculate the change in x-coordinate
double dx = Math.sqrt(d * d / (1 + invSlope * invSlope));
if (invSlope < 0)
{
dx = -dx;
}
// calculate the change in y-coordinate
double dy = invSlope * dx;

// calculate the new coordinates of the point
double x2 = mx + dx;
double y2 = my + dy;
Point2D tempUp = new Point2D(x2, y2);

return tempUp;
}

public Point2D getUp(Point2D p)
{
Point2D nextP = neighbours.get(p).get(1); //O(1)
Expand All @@ -555,7 +461,7 @@ public Point2D getUp(Point2D p)
//find farthest point
double maxRadius = getRadius(p, nextP, nextNextP);
// define the distance to travel
double d = 2.05*maxRadius/10000.0;
double d = maxRadius/1000.0;
// calculate the change in x-coordinate
double dx = Math.sqrt(d * d / (1 + invSlope * invSlope));
if (invSlope < 0)
Expand All @@ -573,12 +479,9 @@ public Point2D getUp(Point2D p)
// return Up;
if(mode == 1)
{
// return getU2(nextP, p, nextNextP);
return getUp8(p);
// return Up;
}else
{
// return getU(nextP, p, nextNextP);
return getUp8(p);
}

Expand All @@ -590,43 +493,6 @@ public boolean isPointInCircle(Point2D point, Point2D center, double radius)
return distance < radius;
}

public Point2D circumcenter2(Point2D p, Point2D q, Point2D r) {
double a = p.distance(q);
double b = q.distance(r);
double c = r.distance(p);

double d = 2 * (p.getX() * (q.getY() - r.getY()) + q.getX() * (r.getY() - p.getY()) + r.getX() * (p.getY() - q.getY()));
double ux = ((p.getX() * p.getX() + p.getY() * p.getY()) * (q.getY() - r.getY()) + (q.getX() * q.getX() + q.getY() * q.getY()) * (r.getY() - p.getY()) + (r.getX() * r.getX() + r.getY() * r.getY()) * (p.getY() - q.getY())) / d;
double uy = ((p.getX() * p.getX() + p.getY() * p.getY()) * (r.getX() - q.getX()) + (q.getX() * q.getX() + q.getY() * q.getY()) * (p.getX() - r.getX()) + (r.getX() * r.getX() + r.getX() * r.getX()) * (q.getX() - p.getX())) / d;

return new Point2D(ux, uy);
}

public double area(Point2D p, Point2D q, Point2D r) {
return Math.abs(p.getX() * q.getY() + q.getX() * r.getY() + r.getX() * p.getY() - q.getX() * p.getY() - r.getX() * q.getY() - p.getX() * r.getY()) / 2.0;
}

public Point2D getU2(Point2D p, Point2D prev, Point2D next) {
return circumcenter2(p, prev, next);
}

public Point2D circumcenter(Point2D p, Point2D q, Point2D r) {
double a = q.distance(r);
double b = p.distance(r);
double c = p.distance(q);

double s = a + b + c;

double x = (a * p.getX() + b * q.getX() + c * r.getX()) / s;
double y = (a * p.getY() + b * q.getY() + c * r.getY()) / s;

return new Point2D(x, y);
}

public Point2D getU(Point2D p, Point2D prev, Point2D next) {
return circumcenter(p, prev, next);
}


public void updateUp(Point2D p, Point2D c)
{
Expand All @@ -642,7 +508,7 @@ public void addAllUpToK()
for (int i = 0; i < size; i++)
{
Point2D curr = convexPoints.get(i); //O(1)
Point2D Ucurr = getUp(curr);
Point2D Ucurr = getUp8(curr);
u_p.put(curr, Ucurr);
K.add(Ucurr);
}
Expand Down
2 changes: 1 addition & 1 deletion src/View/MainGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class MainGUI extends Application
{
private String javaVersion = System.getProperty("java.version");
private String javafxVersion = System.getProperty("javafx.version");
private String version = "v0.9.7";
private String version = "v0.9.8";

private Stage stage;
private Scene scene;
Expand Down

0 comments on commit b5c6b33

Please sign in to comment.