@Test public void calculateTimeToConflictPoint() throws Exception { Vector2D curPosition, curVelocity, othPosition, othVelocity; curPosition = GeometryFactory.createVector(0, 0); curVelocity = GeometryFactory.createVector(0, 1); othPosition = GeometryFactory.createVector(2, 2); othVelocity = GeometryFactory.createVector(-1, 0); Assert.assertEquals(0.0, ZengAdditionalComputations.calculateTimeToConflictPoint(curPosition, curVelocity, othPosition, othVelocity), PRECISION); curPosition = GeometryFactory.createVector(0, 0); curVelocity = GeometryFactory.createVector(1, 1); othPosition = GeometryFactory.createVector(2, 0); othVelocity = GeometryFactory.createVector(-1, 1); Assert.assertEquals(0.0, ZengAdditionalComputations.calculateTimeToConflictPoint(curPosition, curVelocity, othPosition, othVelocity), PRECISION); curPosition = GeometryFactory.createVector(0, 0); curVelocity = GeometryFactory.createVector(0, 1); othPosition = GeometryFactory.createVector(1, 0); othVelocity = GeometryFactory.createVector(-1, -1); Assert.assertEquals(Double.POSITIVE_INFINITY, ZengAdditionalComputations.calculateTimeToConflictPoint(curPosition, curVelocity, othPosition, othVelocity), PRECISION); curPosition = GeometryFactory.createVector(0, 0); curVelocity = GeometryFactory.createVector(1, 0); othPosition = GeometryFactory.createVector(11, 1); othVelocity = GeometryFactory.createVector(0, -1); Assert.assertEquals(10.0, ZengAdditionalComputations.calculateTimeToConflictPoint(curPosition, curVelocity, othPosition, othVelocity), PRECISION); curPosition = GeometryFactory.createVector(0, 0); curVelocity = GeometryFactory.createVector(0, 1); othPosition = GeometryFactory.createVector(0, 10); othVelocity = GeometryFactory.createVector(0, -1); Assert.assertEquals(0.0, ZengAdditionalComputations.calculateTimeToConflictPoint(curPosition, curVelocity, othPosition, othVelocity), PRECISION); }
public static Double calculateTimeToConflictPoint(Vector2D currentPosition, Vector2D currentVelocity, Vector2D otherPosition, Vector2D otherVelocity) { if(currentVelocity.isZero() || otherVelocity.isZero()) { return Double.POSITIVE_INFINITY; } Ray2D currentRay = GeometryFactory.createRay2D(currentPosition, currentVelocity); Ray2D otherRay = GeometryFactory.createRay2D(otherPosition, otherVelocity); Vector2D conflictPoint = currentRay.intersectionPoint(otherRay); if(conflictPoint != null) { double curTimeToConflictPoint = (conflictPoint.subtract(currentPosition).getMagnitude() / currentVelocity.getMagnitude()); double othTimeToConflictPoint = (conflictPoint.subtract(otherPosition).getMagnitude() / otherVelocity.getMagnitude()); return Math.abs(curTimeToConflictPoint - othTimeToConflictPoint); } Segment2D conflictSegment = currentRay.intersectionSegment(otherRay); if(conflictSegment != null) { return 0.0; } Ray2D conflictRay = currentRay.intersectionRay(otherRay); if(conflictRay != null) { return 0.0; } return Double.POSITIVE_INFINITY; }
ZengAdditionalComputations { public static Double calculateTimeToConflictPoint(Vector2D currentPosition, Vector2D currentVelocity, Vector2D otherPosition, Vector2D otherVelocity) { if(currentVelocity.isZero() || otherVelocity.isZero()) { return Double.POSITIVE_INFINITY; } Ray2D currentRay = GeometryFactory.createRay2D(currentPosition, currentVelocity); Ray2D otherRay = GeometryFactory.createRay2D(otherPosition, otherVelocity); Vector2D conflictPoint = currentRay.intersectionPoint(otherRay); if(conflictPoint != null) { double curTimeToConflictPoint = (conflictPoint.subtract(currentPosition).getMagnitude() / currentVelocity.getMagnitude()); double othTimeToConflictPoint = (conflictPoint.subtract(otherPosition).getMagnitude() / otherVelocity.getMagnitude()); return Math.abs(curTimeToConflictPoint - othTimeToConflictPoint); } Segment2D conflictSegment = currentRay.intersectionSegment(otherRay); if(conflictSegment != null) { return 0.0; } Ray2D conflictRay = currentRay.intersectionRay(otherRay); if(conflictRay != null) { return 0.0; } return Double.POSITIVE_INFINITY; } }
ZengAdditionalComputations { public static Double calculateTimeToConflictPoint(Vector2D currentPosition, Vector2D currentVelocity, Vector2D otherPosition, Vector2D otherVelocity) { if(currentVelocity.isZero() || otherVelocity.isZero()) { return Double.POSITIVE_INFINITY; } Ray2D currentRay = GeometryFactory.createRay2D(currentPosition, currentVelocity); Ray2D otherRay = GeometryFactory.createRay2D(otherPosition, otherVelocity); Vector2D conflictPoint = currentRay.intersectionPoint(otherRay); if(conflictPoint != null) { double curTimeToConflictPoint = (conflictPoint.subtract(currentPosition).getMagnitude() / currentVelocity.getMagnitude()); double othTimeToConflictPoint = (conflictPoint.subtract(otherPosition).getMagnitude() / otherVelocity.getMagnitude()); return Math.abs(curTimeToConflictPoint - othTimeToConflictPoint); } Segment2D conflictSegment = currentRay.intersectionSegment(otherRay); if(conflictSegment != null) { return 0.0; } Ray2D conflictRay = currentRay.intersectionRay(otherRay); if(conflictRay != null) { return 0.0; } return Double.POSITIVE_INFINITY; }  }
ZengAdditionalComputations { public static Double calculateTimeToConflictPoint(Vector2D currentPosition, Vector2D currentVelocity, Vector2D otherPosition, Vector2D otherVelocity) { if(currentVelocity.isZero() || otherVelocity.isZero()) { return Double.POSITIVE_INFINITY; } Ray2D currentRay = GeometryFactory.createRay2D(currentPosition, currentVelocity); Ray2D otherRay = GeometryFactory.createRay2D(otherPosition, otherVelocity); Vector2D conflictPoint = currentRay.intersectionPoint(otherRay); if(conflictPoint != null) { double curTimeToConflictPoint = (conflictPoint.subtract(currentPosition).getMagnitude() / currentVelocity.getMagnitude()); double othTimeToConflictPoint = (conflictPoint.subtract(otherPosition).getMagnitude() / otherVelocity.getMagnitude()); return Math.abs(curTimeToConflictPoint - othTimeToConflictPoint); } Segment2D conflictSegment = currentRay.intersectionSegment(otherRay); if(conflictSegment != null) { return 0.0; } Ray2D conflictRay = currentRay.intersectionRay(otherRay); if(conflictRay != null) { return 0.0; } return Double.POSITIVE_INFINITY; }  static Vector2D computeRepulsiveForceConflictingPedestrians(IOperationalPedestrian pedestrian, Collection<IPedestrian> otherPedestrians, double timeStepDuration,
																	   double interaction_strength_for_repulsive_force_from_surrounding_pedestrians, double interaction_range_for_relative_distance,
																	   double range_for_relative_conflicting_time, double strength_of_forces_exerted_from_other_pedestrians); static Double calculateTimeToConflictPoint(Vector2D currentPosition, Vector2D currentVelocity, Vector2D otherPosition, Vector2D otherVelocity); static double calculateInteractionAngleFactor(Vector2D currentVelocity, Vector2D distance, double influenceStrength); static TaggedArea findCorrespondingCrosswalk(IOperationalPedestrian pedestrian, List<TaggedArea> crosswalkAreas); static Vector2D findNearestCrosswalkBoundaryPoint(IOperationalPedestrian pedestrian, TaggedArea nextCrosswalk, double epsilon); }
ZengAdditionalComputations { public static Double calculateTimeToConflictPoint(Vector2D currentPosition, Vector2D currentVelocity, Vector2D otherPosition, Vector2D otherVelocity) { if(currentVelocity.isZero() || otherVelocity.isZero()) { return Double.POSITIVE_INFINITY; } Ray2D currentRay = GeometryFactory.createRay2D(currentPosition, currentVelocity); Ray2D otherRay = GeometryFactory.createRay2D(otherPosition, otherVelocity); Vector2D conflictPoint = currentRay.intersectionPoint(otherRay); if(conflictPoint != null) { double curTimeToConflictPoint = (conflictPoint.subtract(currentPosition).getMagnitude() / currentVelocity.getMagnitude()); double othTimeToConflictPoint = (conflictPoint.subtract(otherPosition).getMagnitude() / otherVelocity.getMagnitude()); return Math.abs(curTimeToConflictPoint - othTimeToConflictPoint); } Segment2D conflictSegment = currentRay.intersectionSegment(otherRay); if(conflictSegment != null) { return 0.0; } Ray2D conflictRay = currentRay.intersectionRay(otherRay); if(conflictRay != null) { return 0.0; } return Double.POSITIVE_INFINITY; }  static Vector2D computeRepulsiveForceConflictingPedestrians(IOperationalPedestrian pedestrian, Collection<IPedestrian> otherPedestrians, double timeStepDuration,
																	   double interaction_strength_for_repulsive_force_from_surrounding_pedestrians, double interaction_range_for_relative_distance,
																	   double range_for_relative_conflicting_time, double strength_of_forces_exerted_from_other_pedestrians); static Double calculateTimeToConflictPoint(Vector2D currentPosition, Vector2D currentVelocity, Vector2D otherPosition, Vector2D otherVelocity); static double calculateInteractionAngleFactor(Vector2D currentVelocity, Vector2D distance, double influenceStrength); static TaggedArea findCorrespondingCrosswalk(IOperationalPedestrian pedestrian, List<TaggedArea> crosswalkAreas); static Vector2D findNearestCrosswalkBoundaryPoint(IOperationalPedestrian pedestrian, TaggedArea nextCrosswalk, double epsilon);  }