From 4073a93f449e8c46d22ca84b42a9dc263928b46e Mon Sep 17 00:00:00 2001 From: Pascal Date: Wed, 29 Jan 2020 01:19:11 -0600 Subject: [PATCH] [add][fix] added distance func to Cell and fixed missing import in library --- src/main/scala/scim/datastruct/Configuration.scala | 6 +++++- src/main/scala/scim/lib/Library.scala | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/scala/scim/datastruct/Configuration.scala b/src/main/scala/scim/datastruct/Configuration.scala index 6ef6eac..8b011c2 100644 --- a/src/main/scala/scim/datastruct/Configuration.scala +++ b/src/main/scala/scim/datastruct/Configuration.scala @@ -102,7 +102,11 @@ case class SensorResult() extends Result[(Group, Cell, Option[Double])] case class SensorID(group: Group, Id: Int) case class Duration(simDuration: Int) case class TickFactor(factor: Int) // processed when parsing configuration, artifically place timings -case class Cell(x: Int, y: Int) +case class Cell(x: Int, y: Int) { + def distance(otherCell: Cell): Double = { + Math.sqrt(Math.pow(x - otherCell.x, 2) + Math.pow(y - otherCell.y, 2)) + } +} case class Group(name: String, sensorParent: Option[String] = None){ // the sensorParent serves as indicator for the parser that a ground truth is not required // TODO: use parent as get function and parent.set as setter to make var private diff --git a/src/main/scala/scim/lib/Library.scala b/src/main/scala/scim/lib/Library.scala index d94f7b2..7c9e43d 100644 --- a/src/main/scala/scim/lib/Library.scala +++ b/src/main/scala/scim/lib/Library.scala @@ -3,6 +3,8 @@ package scim.lib // java imports import java.io.{File, FileInputStream} +import scim.datastruct.FunctionArgs + import scala.collection.immutable.ListMap