Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
Version 0.0.1
Browse files Browse the repository at this point in the history
publish ready

Version 0.0.1 reformat

fixed warnings
  • Loading branch information
ToluAta committed Apr 6, 2022
1 parent 2c3a78f commit 548886b
Show file tree
Hide file tree
Showing 40 changed files with 731 additions and 955 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ The tracking system consists of multiple modules that can theoretically be used
- **Mapper** (inherits from Tracker) - module for tracking a user's position on a map (with correlating graph, nodes and edges)

#### Calculator (abstract)
- consists of `Coordinate calculate(List<Beacon>)`
- consists of `Point calculate(List<Beacon>)`
- reads certain values from said list and calculates a position using those values
- Epitaph IPS provides an implemented (nonlinear trilateration) Calculator, which uses a simple Levenberg-Marquardt algorithm

#### Filter (abstract)
- consists of `Coordinate filter(Coordinate)`, `void configFilter(Coordinate)`, `void reset()`
- an implemented filter should continuously take in a coordinate, process it and save the result for upcoming processing
- consists of `Point filter(Point)`, `void configFilter(Point)`, `void reset()`
- an implemented filter should continuously take in a point, process it and save the result for upcoming processing
- Epitaph IPS provieds an implemented filter in the form of simple unscented Kalmen filter

#### Tracker
Expand Down Expand Up @@ -115,7 +115,7 @@ tracker.finalPosition;
tracker.calculatedPosition;
tracker.filteredPosition;

//Filter can be used independently from tracker; provide Coordinate instance for filter method
//Filter can be used independently from tracker; provide Point instance for filter method
filter.filter(...);

//Calculator can be used independently from tracker; provide a list with at least 3 Beacon instances
Expand Down
Empty file removed docs/.gitkeep
Empty file.
11 changes: 5 additions & 6 deletions lib/epitaph_graphs/nodes/epitaph_edge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ class EpitaphEdge extends DirectedEdge {
double scale = shadowScale(position);

if (scale <= 0) {
return source.coordinate.toVector() - position;
return source.point.toVector() - position;
} else if (scale >= 1) {
return target.coordinate.toVector() - position;
return target.point.toVector() - position;
} else {
Vector shadow = source.coordinate.toVector() + toVector() * scale;
Vector shadow = source.point.toVector() + toVector() * scale;
return shadow - position;
}
}

/// Returns the relative scale of the shortest source-position vector to this edge
double shadowScale(Vector position) {
Vector sourcePosition = position - source.coordinate.toVector();
Vector sourcePosition = position - source.point.toVector();
return sourcePosition.dot(toVector()) / pow(weight, 2);
}

Expand All @@ -61,8 +61,7 @@ class EpitaphEdge extends DirectedEdge {
return userTarget.abs() <= userSource.abs();
}

Vector toVector() =>
target.coordinate.toVector() - source.coordinate.toVector();
Vector toVector() => target.point.toVector() - source.point.toVector();

@override
EpitaphEdge copy() => this;
Expand Down
17 changes: 7 additions & 10 deletions lib/epitaph_graphs/nodes/epitaph_vertex.dart
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
import 'package:epitaph_ips/epitaph_graphs/nodes/vertex.dart';
import 'package:epitaph_ips/epitaph_ips/buildings/coordinate.dart';
import 'package:epitaph_ips/epitaph_ips/buildings/point.dart';

/// The specific [Vertex] implementation for this library to make navigation possible.
class EpitaphVertex extends Vertex {
EpitaphVertex(String id, this.coordinate) : super(id);
EpitaphVertex(String id, this.point) : super(id);

EpitaphVertex.fromJson(Map<String, dynamic> json)
: coordinate = Coordinate.fromJson(json['coordinate']),
: point = Point.fromJson(json['Point']),
super(json['id']);

final Coordinate coordinate;
final Point point;

/// Returns the euclidean distance from this [EpitaphVertex] to another.
double distanceTo(EpitaphVertex other) =>
coordinate.distanceTo(other.coordinate);
double distanceTo(EpitaphVertex other) => point.distanceTo(other.point);

@override
Vertex copy() => this;

@override
Map<String, dynamic> toJson() =>
{'id': id, 'coordinate': coordinate.toJson()};
Map<String, dynamic> toJson() => {'id': id, 'Point': point.toJson()};

@override
String toString() =>
'EpitaphVertex(id: $id, coordinate: ${coordinate.toString()})';
String toString() => 'EpitaphVertex(id: $id, Point: ${point.toString()})';
}
8 changes: 4 additions & 4 deletions lib/epitaph_ips/buildings/area.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:epitaph_ips/epitaph_ips/buildings/coordinate.dart';
import 'package:epitaph_ips/epitaph_ips/buildings/point.dart';

/// An abstract definition for areas. A cluster of [Coordinate] saved in [points] defines it.
/// An abstract definition for areas. A cluster of [Point] saved in [points] defines it.
/// If your area is supposed to not be enterable, set [passable] to false.
abstract class Area {
Area({required this.points, this.passable = true}) {
Expand All @@ -9,12 +9,12 @@ abstract class Area {
}
}

final List<Coordinate> points;
final List<Point> points;

final bool passable;

/// A method which checks if a certain [point] is in the [Area]
bool pointInArea(Coordinate point);
bool pointInArea(Point point);

Area copy();

Expand Down
8 changes: 4 additions & 4 deletions lib/epitaph_ips/buildings/building.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:epitaph_ips/epitaph_ips/buildings/coordinate.dart';
import 'package:epitaph_ips/epitaph_ips/buildings/point.dart';
import 'package:flutter/foundation.dart';
import 'package:epitaph_ips/epitaph_ips/buildings/floor.dart';
import 'package:epitaph_ips/epitaph_ips/buildings/polygonal_area.dart';
Expand Down Expand Up @@ -69,14 +69,14 @@ class Building {
};
}

Room? getCurrentRoom(Coordinate coordinate) {
Room? getCurrentRoom(Point point) {
for (Floor floor in floors) {
if (!floor.area.pointInArea(coordinate)) {
if (!floor.area.pointInArea(point)) {
continue;
}

for (Room room in floor.rooms) {
if (room.area.pointInArea(coordinate)) {
if (room.area.pointInArea(point)) {
return room;
}
}
Expand Down
16 changes: 8 additions & 8 deletions lib/epitaph_ips/buildings/circular_area.dart
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import 'package:epitaph_ips/epitaph_ips/buildings/area.dart';
import 'package:epitaph_ips/epitaph_ips/buildings/coordinate.dart';
import 'package:epitaph_ips/epitaph_ips/buildings/point.dart';

///A circular implementation of an [Area]. [m] is the middle point of your circle while [r] is the radius.
///If you have two points instead you can use [CircularArea.fromPoints] to generate it from two points instead.
class CircularArea extends Area {
CircularArea({required Coordinate m, required double r})
: super(points: [m, Coordinate(m.x, (m.y + r))]) {
CircularArea({required Point m, required double r})
: super(points: [m, Point(m.x, (m.y + r))]) {
_r = r;
}

CircularArea.fromPoints({required Coordinate m, required Coordinate rPoint})
CircularArea.fromPoints({required Point m, required Point rPoint})
: super(points: [m, rPoint]) {
_r = m.toVector().distanceTo(rPoint.toVector());
}

CircularArea.fromJson(Map<String, dynamic> json)
: super(points: [
Coordinate.fromJson(json['m']),
Coordinate(json['m']['x'], (json['m']['y'] + json['r']))
Point.fromJson(json['m']),
Point(json['m']['x'], (json['m']['y'] + json['r']))
]) {
_r = json['r'];
}

double _r = 0.0;

Coordinate get m => points[0];
Point get m => points[0];

double get r => _r;

@override
bool pointInArea(Coordinate point) => (m.distanceTo(point) < _r);
bool pointInArea(Point point) => (m.distanceTo(point) < _r);

@override
Area copy() => this;
Expand Down
99 changes: 0 additions & 99 deletions lib/epitaph_ips/buildings/coordinate.dart

This file was deleted.

96 changes: 96 additions & 0 deletions lib/epitaph_ips/buildings/point.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import 'package:ml_linalg/linalg.dart';

///A [Point] object represents a point in a cartesian Point system for a three-dimensional space
class Point {
Point._(this.x, this.y, this.z);

///Factory constructor with parameters for each dimension
factory Point(double x, double y, [double z = 0]) {
return Point._(x, y, z);
}

///Factory constructor which reads x-y-z-values from a list
factory Point.list(List<double> l) {
int length = l.length;
assert(length == 2 || length == 3, 'Point must have 2 or 3 dimensions');

if (length == 2) {
return Point._(l[0], l[1], 0);
}

return Point._(l[0], l[1], l[2]);
}

///Factory constructor which reads x-y-z-values from a vector
factory Point.vector(Vector v) {
int length = v.length;
assert(length == 2 || length == 3, 'Point must have 2 or 3 dimensions');

if (length == 2) {
return Point._(v[0], v[1], 0);
}

return Point._(v[0], v[1], v[2]);
}

///Factory constructor which returns the origin Point
factory Point.origin() {
return Point._(0, 0, 0);
}

///Factory constructor which reads x-y-z-values from a map
factory Point.fromJson(Map<String, dynamic> m) {
int length = m.length;
assert(length == 2 || length == 3, 'Point must have 2 or 3 dimensions');

if (length == 2) {
return Point._(m['x'], m['y'], 0);
}

return Point._(m['x'], m['y'], m['z']);
}

final double x;
final double y;
final double z;

@override
String toString() => 'Point(x: $x, y: $y, z: $z)';

List<double> toList() => [x, y, z];

List<double> to2DList() => [x, y];

Vector toVector() => Vector.fromList([x, y, z]);

Map<String, dynamic> toJson() => {'x': x, 'y': y, 'z': z};

///Returns the Euclidean distance to [other]
double distanceTo(Point other) {
return toVector().distanceTo(other.toVector());
}

///Creates a new Point object with identical x-y-z-values
Point copy() => Point._(x, y, z);

Point operator +(Point summand) =>
Point.vector(toVector() + summand.toVector());

Point operator -(Point subtrahend) =>
Point.vector(toVector() - subtrahend.toVector());

Point operator /(num divisor) => Point.vector(toVector() / divisor);

@override
bool operator ==(Object other) {
if (other is Point) {
return x == other.x && y == other.y && z == other.z;
}

return false;
}

@override
// TODO: implement hashCode
int get hashCode => Object.hash(x, y, z);
}
Loading

0 comments on commit 548886b

Please sign in to comment.