This repository has been archived by the owner on Dec 11, 2024. It is now read-only.
generated from it-at-m/oss-repository-en-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
publish ready Version 0.0.1 reformat fixed warnings
- Loading branch information
Showing
40 changed files
with
731 additions
and
955 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()})'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
Oops, something went wrong.