コード例 #1
0
ファイル: Exercise9_2.java プロジェクト: ByeongUnSon/study
  public static void main(String[] args) {
    Point3D p1 = new Point3D(1, 2, 3);
    Point3D p2 = new Point3D(1, 2, 3);

    System.out.println(p1);
    System.out.println(p2);
    System.out.println("p1==p2?" + (p1 == p2));
    System.out.println("p1.equals(p2)?" + (p1.equals(p2)));
  }
コード例 #2
0
ファイル: Line3D.java プロジェクト: cmaureir/trending-paper
 public Line3D(Point3D start, Point3D end) {
   if (start.equals(end))
     throw new IllegalArgumentException("Given arguments are a Point not a line!");
   // finding gradeY and gradeZ.
   if (start.x < end.x) {
     this.start = start;
     this.end = end;
   } else {
     this.end = start;
     this.start = end;
   }
   this.gradeY = (this.end.y - this.start.y) / (this.end.x - this.start.x);
   this.gradeZ = (this.end.z - this.start.z) / (this.end.x - this.start.x);
   this.offsetY = this.start.y - this.gradeY * this.start.x;
   this.offsetZ = this.start.z - this.gradeZ * this.start.x;
 }