From e363b438ef6c67e29bdadd5678c98fef76e17349 Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 24 Mar 2014 19:03:22 +0000 Subject: [PATCH] Check for vector norm of 0 --- src/services/SimulationService.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index 9b9a81ab..296cdf40 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -982,6 +982,13 @@ public class SimulationService implements INetworkDispatch { Point3D end = new Point3D(position2.x, position2.y + 1, position2.z); Vector3D direction = new Vector3D(end.x - origin.x, end.y - origin.y, end.z - origin.z).normalize(); + + if (direction.getNorm() != 0) { + direction.normalize(); + } else { + System.out.println("WARNING: checkLineOfSightInBuilding: Vector norm was 0."); + } + float distance = position1.getDistance2D(position2); Ray ray = new Ray(origin, direction);