Update to Worldwind release 0.4.1
[worldwind-tracker.git] / gov / nasa / worldwind / geom / Intersection.java
blobd835cd50986b46b994745b247103a7c61dd52655
1 /*
2 Copyright (C) 2001, 2006 United States Government
3 as represented by the Administrator of the
4 National Aeronautics and Space Administration.
5 All Rights Reserved.
6 */
7 package gov.nasa.worldwind.geom;
9 import gov.nasa.worldwind.util.Logging;
11 /**
12 * @author Tom Gaskins
13 * @version $Id: Intersection.java 2471 2007-07-31 21:50:57Z tgaskins $
15 public final class Intersection // Instances are immutable
18 private final Vec4 intersectionPoint;
19 private final boolean isTangent;
21 /**
22 * @param intersectionPoint
23 * @param isTangent
24 * @throws IllegalArgumentException if <code>intersectionpoint</code> is null
26 public Intersection(Vec4 intersectionPoint, boolean isTangent)
28 if (intersectionPoint == null)
30 String message = Logging.getMessage("nullValue.IntersectionPointIsNull");
31 Logging.logger().severe(message);
32 throw new IllegalArgumentException(message);
34 this.intersectionPoint = intersectionPoint;
35 this.isTangent = isTangent;
38 public final Vec4 getIntersectionPoint()
40 return intersectionPoint;
43 public final boolean isTangent()
45 return isTangent;
48 @Override
49 public boolean equals(Object o)
51 if (this == o)
52 return true;
53 if (o == null || getClass() != o.getClass())
54 return false;
56 final gov.nasa.worldwind.geom.Intersection that = (gov.nasa.worldwind.geom.Intersection) o;
58 if (isTangent != that.isTangent)
59 return false;
60 //noinspection RedundantIfStatement
61 if (!intersectionPoint.equals(that.intersectionPoint))
62 return false;
64 return true;
67 @Override
68 public int hashCode()
70 int result;
71 result = intersectionPoint.hashCode();
72 result = 29 * result + (isTangent ? 1 : 0);
73 return result;
76 @Override
77 public String toString()
79 String pt = "Intersection Point: " + this.intersectionPoint;
80 String tang = this.isTangent ? " is a tangent." : " not a tangent";
81 return pt + tang;