Note that there are some explanatory texts on larger screens.

plurals
  1. POMove Point - Centroid
    primarykey
    data
    text
    <p>The purpose of the method is to take in a Point (c), then move the current centroid (x,y) to the new coordinated provided. This is done through finding the difference of the two and then translating the point to the new coordinate. However, I do not know how to set the new centroid value since I am setting the methods as voids.... Any ideas? Sorry for all of the code, tried to put as little as possible. Translate takes the point(x,y) and adds the values given (dx,dy).</p> <pre><code>private Point centroid; Triangle(Point a, Point b, Point c) { this.a = a; this.b = b; this.c = c; triPoints = new Point[] { a, b, c }; } public Point getCentroid() { Point centroid; double x = 0.0; double y = 0.0; x = (a.getX() + b.getX() + c.getX()) / 3; y = (a.getY() + b.getY() + c.getY()) / 3; centroid = new Point(x, y); return centroid; } public void move(double dx, double dy) { centroid = getCentroid(); System.out.println(centroid.getX() + " "+ centroid.getY()); centroid = centroid.translate(dx, dy); Point newCentroid = new Point(centroid.getX(),centroid.getY()); System.out.println(newCentroid.getX() + " "+ newCentroid.getY()); if(getCentroid().equals(newCentroid)){ }else{ } for (int index = 0; index &lt; triPoints.length - 1; index++) { triPoints[index].translate(dx, dy); } } public void move(Point c) { double firstx = 0.0; double firsty = 0.0; Point f = getCentroid(); System.out.println(f.getX()+ " "+ f.getY() + " "+ c.getX()+ " "+ c.getY()); if (f.getX() &gt;= c.getX()) { firstx = c.getX() - f.getX();} else{ firstx = Math.abs(f.getX() - c.getX()); } if (f.getY()&gt;= c.getY()){ firsty = c.getY() - f.getY(); } else { firsty = Math.abs(f.getY() -c.getY()); } move(firstx, firsty); //System.out.println(centroid.getX() + " " + centroid.getY()); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload